1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 19:43:49 +08:00

feat: custom online status.

This commit is contained in:
Mrs4s 2021-04-08 16:42:41 +08:00
parent 08fd86493d
commit af46324dd9
3 changed files with 19 additions and 5 deletions

View File

@ -25,6 +25,7 @@ type Config struct {
Uin int64 `yaml:"uin"` Uin int64 `yaml:"uin"`
Password string `yaml:"password"` Password string `yaml:"password"`
Encrypt bool `yaml:"encrypt"` Encrypt bool `yaml:"encrypt"`
Status int32 `yaml:"status"`
ReLogin struct { ReLogin struct {
Disabled bool `yaml:"disabled"` Disabled bool `yaml:"disabled"`
Delay int `yaml:"delay"` Delay int `yaml:"delay"`

View File

@ -4,6 +4,7 @@ account: # 账号相关
uin: 1233456 # QQ账号 uin: 1233456 # QQ账号
password: '' # 密码为空时使用扫码登录 password: '' # 密码为空时使用扫码登录
encrypt: false # 是否开启密码加密 encrypt: false # 是否开启密码加密
status: 0 # 在线状态 0->在线 2->离开 3->隐身 4->忙
relogin: # 重连设置 relogin: # 重连设置
disabled: false disabled: false
delay: 3 # 重连延迟, 单位秒 delay: 3 # 重连延迟, 单位秒

12
main.go
View File

@ -41,6 +41,14 @@ var (
c string c string
d bool d bool
h bool h bool
// 允许通过配置文件设置的状态列表
allowStatus = [23]client.UserOnlineStatus{client.StatusOnline, client.StatusAway, client.StatusInvisible, client.StatusBusy,
client.StatusBattery, client.StatusListening, client.StatusConstellation, client.StatusWeather, client.StatusMeetSpring,
client.StatusTimi, client.StatusEatChicken, client.StatusLoving, client.StatusWangWang, client.StatusCookedRice,
client.StatusStudy, client.StatusStayUp, client.StatusPlayBall, client.StatusSignal, client.StatusStudyOnline,
client.StatusGaming, client.StatusVacationing, client.StatusWatchingTV, client.StatusFitness,
}
) )
func init() { func init() {
@ -355,6 +363,10 @@ func main() {
log.Infof("开始加载群列表...") log.Infof("开始加载群列表...")
global.Check(cli.ReloadGroupList(), true) global.Check(cli.ReloadGroupList(), true)
log.Infof("共加载 %v 个群.", len(cli.GroupList)) log.Infof("共加载 %v 个群.", len(cli.GroupList))
if conf.Account.Status >= int32(len(allowStatus)) || conf.Account.Status < 0 {
conf.Account.Status = 0
}
cli.SetOnlineStatus(allowStatus[int(conf.Account.Status)])
bot := coolq.NewQQBot(cli, conf) bot := coolq.NewQQBot(cli, conf)
_ = bot.Client _ = bot.Client
if conf.Message.PostFormat != "string" && conf.Message.PostFormat != "array" { if conf.Message.PostFormat != "string" && conf.Message.PostFormat != "array" {