package main import ( "fmt" "go-bot/bot/controller" "github.com/eatmoreapple/openwechat" ) func main() { // //创建热存储容器对象 // reloadStorage := openwechat.NewJsonFileHotReloadStorage("storage.json") // //执行热登录 // bot.HotLogin(reloadStorage) // os.File("storage.json") bot := openwechat.DefaultBot(openwechat.Desktop) // 注册消息处理函数 bot.MessageHandler = func(msg *openwechat.Message) { if msg.IsText() && msg.Content == "专升本英语" { controller.SingleChoice(msg) } if msg.IsText() && msg.Content == "打卡开启" { module.SignInBegin(msg) } if msg.IsText() && msg.Content == "打卡关闭" { module.SignInEnd(msg) } } // 注册登陆二维码回调 bot.UUIDCallback = openwechat.PrintlnQrcodeUrl // 登陆 if err := bot.Login(); err != nil { fmt.Println(err) return } // 获取登陆的用户 self, err := bot.GetCurrentUser() if err != nil { fmt.Println(err) return } // 获取所有的好友 friends, err := self.Friends() fmt.Println(friends, err) // 获取所有的群组 groups, err := self.Groups() fmt.Println(groups, err) // 阻塞主goroutine, 直到发生异常或者用户主动退出 bot.Block() }