| 17 | } |
| 18 | |
| 19 | func TestLogout(t *testing.T) { |
| 20 | bot := DefaultBot(Desktop) |
| 21 | bot.LoginCallBack = func(body CheckLoginResponse) { |
| 22 | t.Log("login") |
| 23 | } |
| 24 | bot.LogoutCallBack = func(bot *Bot) { |
| 25 | t.Log("logout") |
| 26 | } |
| 27 | bot.MessageHandler = func(msg *Message) { |
| 28 | if msg.IsText() && msg.Content == "logout" { |
| 29 | if err := bot.Logout(); err != nil { |
| 30 | t.Error(err) |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | if err := bot.Login(); err != nil { |
| 35 | t.Error(err) |
| 36 | return |
| 37 | } |
| 38 | _ = bot.Block() |
| 39 | } |
| 40 | |
| 41 | func TestMessageHandle(t *testing.T) { |
| 42 | bot := DefaultBot(Desktop) |