修复登陆逻辑
This commit is contained in:
parent
6dacca9dba
commit
2761e43c49
3
bot.go
3
bot.go
@ -3,6 +3,7 @@ package openwechat
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bot struct {
|
type Bot struct {
|
||||||
@ -91,7 +92,6 @@ func (b *Bot) login(data []byte) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将LoginInfo存到storage里面
|
// 将LoginInfo存到storage里面
|
||||||
b.storage.LoginInfo = info
|
b.storage.LoginInfo = info
|
||||||
|
|
||||||
@ -158,6 +158,7 @@ func (b *Bot) stopAsyncCALL(err error) {
|
|||||||
b.exit <- true
|
b.exit <- true
|
||||||
b.err = err
|
b.err = err
|
||||||
b.self = nil
|
b.self = nil
|
||||||
|
log.Printf("exit with : %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取新的消息
|
// 获取新的消息
|
||||||
|
@ -80,6 +80,9 @@ func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error) {
|
|||||||
if err := resp.ScanXML(&loginInfo); err != nil {
|
if err := resp.ScanXML(&loginInfo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !loginInfo.Ok() {
|
||||||
|
return nil, loginInfo
|
||||||
|
}
|
||||||
return &loginInfo, nil
|
return &loginInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
items.go
8
items.go
@ -17,6 +17,14 @@ type LoginInfo struct {
|
|||||||
PassTicket string `xml:"pass_ticket"`
|
PassTicket string `xml:"pass_ticket"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l LoginInfo) Ok() bool {
|
||||||
|
return l.Ret == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l LoginInfo) Error() string {
|
||||||
|
return l.Message
|
||||||
|
}
|
||||||
|
|
||||||
// 初始的请求信息
|
// 初始的请求信息
|
||||||
// 几乎所有的请求都要携带该参数
|
// 几乎所有的请求都要携带该参数
|
||||||
type BaseRequest struct {
|
type BaseRequest struct {
|
||||||
|
@ -210,6 +210,11 @@ func (m *Message) IsSysNotice() bool {
|
|||||||
return m.MsgType == 9999
|
return m.MsgType == 9999
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断是否为操作通知消息
|
||||||
|
func (m *Message) StatusNotify() bool {
|
||||||
|
return m.MsgType == 51
|
||||||
|
}
|
||||||
|
|
||||||
// 判断消息是否为文件类型的消息
|
// 判断消息是否为文件类型的消息
|
||||||
func (m *Message) HasFile() bool {
|
func (m *Message) HasFile() bool {
|
||||||
return m.IsPicture() || m.IsVoice() || m.IsVideo() || m.IsMedia()
|
return m.IsPicture() || m.IsVoice() || m.IsVideo() || m.IsMedia()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user