有指针错误

This commit is contained in:
2022-07-19 12:09:44 +08:00
parent 569e303a74
commit 39b4f61916
9 changed files with 90 additions and 192 deletions

37
main.go
View File

@@ -2,23 +2,17 @@ package main
import (
"fmt"
"go-bot/bot/controller"
"github.com/eatmoreapple/openwechat"
"go-bot/bot/controller"
"go-bot/bot/tool"
)
func main() {
// //创建热存储容器对象
// reloadStorage := openwechat.NewJsonFileHotReloadStorage("storage.json")
// //执行热登录
// bot.HotLogin(reloadStorage)
// os.File("storage.json")
// 创建bot 对象
bot := openwechat.DefaultBot(openwechat.Desktop)
// 创建热存储容器对象
reloadStorage := openwechat.NewJsonFileHotReloadStorage("storage.json")
// 注册消息处理函数
bot.MessageHandler = func(msg *openwechat.Message) {
@@ -35,15 +29,20 @@ func main() {
controller.SignInEnd(msg)
}
}
// 注册登陆二维码回调
bot.UUIDCallback = openwechat.PrintlnQrcodeUrl
// 登陆
if err := bot.Login(); err != nil {
fmt.Println(err)
//if err := bot.Login(); err != nil {
// fmt.Println(err)
// return
//}
// 执行热登录
err := bot.HotLogin(reloadStorage)
if err != nil {
return
}
@@ -51,12 +50,9 @@ func main() {
self, err := bot.GetCurrentUser()
if err != nil {
fmt.Println(err)
tool.SetCurrentUser(*self)
return
}
func getCurrentUser(){
return self
}
// 获取所有的好友
friends, err := self.Friends()
@@ -67,5 +63,8 @@ func main() {
fmt.Println(groups, err)
// 阻塞主goroutine, 直到发生异常或者用户主动退出
bot.Block()
err = bot.Block()
if err != nil {
return
}
}