-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathmain.go
More file actions
32 lines (28 loc) · 865 Bytes
/
Copy pathmain.go
File metadata and controls
32 lines (28 loc) · 865 Bytes
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
package friendAddReq
import (
"strings"
"github.com/yqchilde/wxbot/engine/control"
"github.com/yqchilde/wxbot/engine/pkg/log"
"github.com/yqchilde/wxbot/engine/robot"
)
func init() {
engine := control.Register("friendAddReq", &control.Options{
Alias: "自动通过好友添加请求",
})
// SetBlock(false) 代表不阻断后面的匹配
engine.OnMessage().SetBlock(false).Handle(func(ctx *robot.Ctx) {
// 监听加好友事件
if ctx.IsEventFriendVerify() {
f := ctx.Event.FriendVerifyMessage
// 判断一下好友验证消息是否为"wxbot"
if strings.ToLower(f.Content) != "wxbot" {
return
}
if err := ctx.AgreeFriendVerify(f.V3, f.V4, f.Scene); err != nil {
log.Errorf("同意好友请求失败: %v", err)
return
}
ctx.SendText(f.WxId, "你好,我是wxbot,感谢您发现并使用该项目!")
}
})
}