添加退出回调

This commit is contained in:
eatMoreApple 2021-04-30 15:24:51 +08:00
parent e2004af0a0
commit 8e1d0e0163

4
bot.go
View File

@ -10,6 +10,7 @@ import (
type Bot struct {
ScanCallBack func(body []byte) // 扫码回调,可获取扫码用户的头像
LoginCallBack func(body []byte) // 登陆回调
LogoutCallBack func(bot *Bot) // 退出回调
UUIDCallback func(uuid string) // 获取UUID的回调函数
MessageHandler func(msg *Message) // 获取消息成功的handle
GetMessageErrorHandler func(err error) // 获取消息发生错误的handle
@ -137,6 +138,9 @@ func (b *Bot) Login() error {
// 用户退出
func (b *Bot) Logout() error {
if b.Alive() {
if b.LogoutCallBack != nil {
b.LogoutCallBack(b)
}
info := b.storage.LoginInfo
if err := b.Caller.Logout(info); err != nil {
return err