forked from lxh/go-wxhelper
🆕 新增迎新开关
This commit is contained in:
parent
d4fcfda112
commit
14d407eff1
@ -14,6 +14,7 @@ type Friend struct {
|
||||
PinyinAll string `json:"pinyinAll"` // 昵称全拼
|
||||
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
||||
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
||||
EnableWelcome bool `json:"enableWelcome" gorm:"type:tinyint(1) default 0 not null"` // 是否启用迎新
|
||||
IsOk bool `json:"isOk" gorm:"type:tinyint(1) default 0 not null"` // 是否正常
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,25 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model"
|
||||
"go-wechat/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// handleSysMessage
|
||||
// @description: 系统消息处理
|
||||
// handleNewUserJoin
|
||||
// @description: 欢迎新成员
|
||||
// @param m
|
||||
func handleSysMessage(m model.Message) {
|
||||
// 有人进群
|
||||
if strings.Contains(m.Content, "\"邀请\"") && strings.Contains(m.Content, "\"加入了群聊") {
|
||||
func handleNewUserJoin(m model.Message) {
|
||||
// 判断是否开启迎新
|
||||
var count int64
|
||||
client.MySQL.Model(&entity.Friend{}).Where("enable_welcome IS TRUE").Where("wxid = ?", m.FromUser).Count(&count)
|
||||
if count < 1 {
|
||||
return
|
||||
}
|
||||
|
||||
// 发一张图乐呵乐呵
|
||||
|
||||
// 自己欢迎自己图片地址 D:\Share\emoticon\welcome-yourself.gif
|
||||
utils.SendImage(m.FromUser, "D:\\Share\\emoticon\\welcome-yourself.gif", 0)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user