添加消息处理
This commit is contained in:
9
controller/msg.go
Normal file
9
controller/msg.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/eatmoreapple/openwechat"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SingleChoice(msg *openwechat.Message) {
|
||||||
|
msg.ReplyText("我执行成功了")
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@@ -2,4 +2,4 @@ module go-bot/bot
|
|||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require github.com/eatmoreapple/openwechat v1.1.11 // indirect
|
require github.com/eatmoreapple/openwechat v1.1.11
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -2,17 +2,19 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go-bot/bot/controller"
|
||||||
|
|
||||||
"github.com/eatmoreapple/openwechat"
|
"github.com/eatmoreapple/openwechat"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
bot := openwechat.DefaultBot(openwechat.Desktop)
|
bot := openwechat.DefaultBot(openwechat.Desktop)
|
||||||
// bot := openwechat.DefaultBot(openwechat.Desktop) // 桌面模式,上面登录不上的可以尝试切换这种模式
|
|
||||||
|
|
||||||
// 注册消息处理函数
|
// 注册消息处理函数
|
||||||
bot.MessageHandler = func(msg *openwechat.Message) {
|
bot.MessageHandler = func(msg *openwechat.Message) {
|
||||||
if msg.IsText() && msg.Content == "ping" {
|
if msg.IsText() && msg.Content == "专升本英语选择题" {
|
||||||
msg.ReplyText("pong")
|
controller.SingleChoice(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 注册登陆二维码回调
|
// 注册登陆二维码回调
|
||||||
|
|||||||
Reference in New Issue
Block a user