mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
feature client status updated event.
This commit is contained in:
parent
8a81b67511
commit
61625f2e32
@ -77,6 +77,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JSONConfig) *CQBot {
|
||||
bot.Client.OnNewFriendAdded(bot.friendAddedEvent)
|
||||
bot.Client.OnGroupInvited(bot.groupInvitedEvent)
|
||||
bot.Client.OnUserWantJoinGroup(bot.groupJoinReqEvent)
|
||||
bot.Client.OnOtherClientStatusChanged(bot.otherClientStatusChangedEvent)
|
||||
go func() {
|
||||
i := conf.HeartbeatInterval
|
||||
if i < 0 {
|
||||
|
@ -413,6 +413,27 @@ func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *client.UserJoinGroupR
|
||||
})
|
||||
}
|
||||
|
||||
func (bot *CQBot) otherClientStatusChangedEvent(c *client.QQClient, e *client.OtherClientStatusChangedEvent) {
|
||||
if e.Online {
|
||||
log.Infof("Bot 账号在客户端 %v (%v) 登录.", e.Client.DeviceName, e.Client.DeviceKind)
|
||||
} else {
|
||||
log.Infof("Bot 账号在客户端 %v (%v) 登出.", e.Client.DeviceName, e.Client.DeviceKind)
|
||||
}
|
||||
bot.dispatchEventMessage(MSG{
|
||||
"post_type": "notice",
|
||||
"notice_type": "client_status",
|
||||
"client": MSG{
|
||||
"online": e.Online,
|
||||
"app_id": e.Client.AppId,
|
||||
"device_name": e.Client.DeviceName,
|
||||
"device_kind": e.Client.DeviceKind,
|
||||
},
|
||||
"self_id": c.Uin,
|
||||
"time": time.Now().Unix(),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (bot *CQBot) groupIncrease(groupCode, operatorUin, userUin int64) MSG {
|
||||
return MSG{
|
||||
"post_type": "notice",
|
||||
|
Loading…
x
Reference in New Issue
Block a user