2023-11-03 11:59:40 +08:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2023-12-04 14:17:52 +08:00
|
|
|
"go-wechat/client"
|
2023-12-07 15:58:55 +08:00
|
|
|
"go-wechat/config"
|
2023-12-04 14:17:52 +08:00
|
|
|
"go-wechat/entity"
|
2023-11-03 11:59:40 +08:00
|
|
|
"go-wechat/model"
|
|
|
|
"go-wechat/utils"
|
|
|
|
)
|
|
|
|
|
2023-12-04 14:17:52 +08:00
|
|
|
// handleNewUserJoin
|
|
|
|
// @description: 欢迎新成员
|
2023-11-03 11:59:40 +08:00
|
|
|
// @param m
|
2023-12-04 14:17:52 +08:00
|
|
|
func handleNewUserJoin(m model.Message) {
|
|
|
|
// 判断是否开启迎新
|
|
|
|
var count int64
|
2023-12-07 23:00:57 +08:00
|
|
|
client.MySQL.Model(&entity.Friend{}).Where("enable_welcome IS TRUE").Where("wxid = ?", m.FromUser).Count(&count)
|
|
|
|
if count < 1 {
|
2023-12-07 15:58:55 +08:00
|
|
|
return
|
|
|
|
}
|
2023-12-04 14:17:52 +08:00
|
|
|
|
2023-12-07 15:58:55 +08:00
|
|
|
// 读取欢迎新成员配置
|
2023-12-07 23:27:07 +08:00
|
|
|
conf, ok := config.Conf.Resource["welcome-new"]
|
2023-12-07 15:58:55 +08:00
|
|
|
if !ok {
|
|
|
|
// 未配置,跳过
|
|
|
|
return
|
|
|
|
}
|
|
|
|
switch conf.Type {
|
|
|
|
case "text":
|
|
|
|
// 文字类型
|
|
|
|
utils.SendMessage(m.FromUser, "", conf.Path, 0)
|
|
|
|
case "image":
|
|
|
|
// 图片类型
|
|
|
|
utils.SendImage(m.FromUser, conf.Path, 0)
|
|
|
|
case "emotion":
|
|
|
|
// 表情类型
|
|
|
|
utils.SendEmotion(m.FromUser, conf.Path, 0)
|
|
|
|
}
|
2023-11-03 11:59:40 +08:00
|
|
|
}
|