-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
47 lines (37 loc) · 986 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"wxBot4g/models"
"wxBot4g/pkg/define"
"wxBot4g/wcbot"
"github.com/sirupsen/logrus"
)
var (
Bot *wcbot.WcBot
)
type WeChatBot struct {
}
func (w *WeChatBot)HandleMessage(msg models.RealRecvMsg) {
//过滤不支持消息99
if msg.MsgType == 99 || msg.MsgTypeId == 99 {
return
}
//获取unknown的username
contentUser := msg.Content.User.Name
if msg.Content.User.Name == "unknown" {
contentUser = Bot.GetGroupUserName(msg.Content.User.Uid)
}
logrus.Debug(
"消息类型:", define.MsgIdString(msg.MsgTypeId), " ",
"数据类型:", define.MsgTypeIdString(msg.Content.Type), " ",
"发送者:", msg.FromUserName, " ",
"发送人:", msg.SendMsgUSer.Name, " ",
"发送内容人:", contentUser, " ",
"内容:", msg.Content.Data)
}
func main() {
Bot = wcbot.New()
Bot.Debug = true
//Bot.QrCodeInTerminal() //默认在 wxqr 目录生成二维码,调用此函数,在终端打印二维码
Bot.AddHandler(&WeChatBot{})
Bot.Run()
}