修改bot的默认模式为Desktop
This commit is contained in:
parent
76b369be2c
commit
019199831a
15
bot.go
15
bot.go
@ -348,7 +348,9 @@ func (b *Bot) OnLogout(f func(bot *Bot)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewBot Bot的构造方法,需要自己传入Caller
|
// NewBot Bot的构造方法,需要自己传入Caller
|
||||||
func NewBot(caller *Caller) *Bot {
|
func NewBot() *Bot {
|
||||||
|
caller := DefaultCaller()
|
||||||
|
caller.Client.SetMode(Desktop)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
return &Bot{Caller: caller, Storage: &Storage{}, context: ctx, cancel: cancel}
|
return &Bot{Caller: caller, Storage: &Storage{}, context: ctx, cancel: cancel}
|
||||||
}
|
}
|
||||||
@ -357,15 +359,10 @@ func NewBot(caller *Caller) *Bot {
|
|||||||
// mode不传入默认为openwechat.Normal,详情见mode
|
// mode不传入默认为openwechat.Normal,详情见mode
|
||||||
// bot := openwechat.DefaultBot(openwechat.Desktop)
|
// bot := openwechat.DefaultBot(openwechat.Desktop)
|
||||||
func DefaultBot(modes ...mode) *Bot {
|
func DefaultBot(modes ...mode) *Bot {
|
||||||
var m mode
|
bot := NewBot()
|
||||||
if len(modes) == 0 {
|
if len(modes) > 0 {
|
||||||
m = Normal
|
bot.Caller.Client.SetMode(modes[0])
|
||||||
} else {
|
|
||||||
m = modes[0]
|
|
||||||
}
|
}
|
||||||
caller := DefaultCaller()
|
|
||||||
caller.Client.mode = m
|
|
||||||
bot := NewBot(caller)
|
|
||||||
bot.UUIDCallback = PrintlnQrcodeUrl
|
bot.UUIDCallback = PrintlnQrcodeUrl
|
||||||
bot.ScanCallBack = func(body []byte) {
|
bot.ScanCallBack = func(body []byte) {
|
||||||
log.Println("扫码成功,请在手机上确认登录")
|
log.Println("扫码成功,请在手机上确认登录")
|
||||||
|
@ -401,6 +401,11 @@ func (c *Caller) WebWxRenameChatRoom(request *BaseRequest, info *LoginInfo, newT
|
|||||||
return parseBaseResponseError(resp)
|
return parseBaseResponseError(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMode 设置Client的模式
|
||||||
|
func (c *Client) SetMode(mode mode) {
|
||||||
|
c.mode = mode
|
||||||
|
}
|
||||||
|
|
||||||
// 处理响应返回的结果是否正常
|
// 处理响应返回的结果是否正常
|
||||||
func parseBaseResponseError(resp *http.Response) error {
|
func parseBaseResponseError(resp *http.Response) error {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user