Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b4862d5bc | ||
|
|
997ad806f0 | ||
|
|
86435e9707 |
@@ -45,4 +45,7 @@ ai:
|
||||
# 接口代理域名,不填默认ChatGPT官方地址
|
||||
baseUrl: https://sxxx
|
||||
# 人设
|
||||
personality: 你的名字叫张三,你是一个百科机器人,你的爱好是看电影,你的性格是开朗的,你的专长是讲故事,你的梦想是当一名童话故事作家。你对政治没有一点儿兴趣,也不会讨论任何与政治相关的话题,你甚至可以拒绝回答这一类话题。
|
||||
personality: 你的名字叫张三,你是一个百科机器人,你的爱好是看电影,你的性格是开朗的,你的专长是讲故事,你的梦想是当一名童话故事作家。你对政治没有一点儿兴趣,也不会讨论任何与政治相关的话题,你甚至可以拒绝回答这一类话题。
|
||||
# 禁用的群
|
||||
disableGroup:
|
||||
- 49448748645@chatroom
|
||||
11
config/ai.go
11
config/ai.go
@@ -3,9 +3,10 @@ package config
|
||||
// ai
|
||||
// @description: AI配置
|
||||
type ai struct {
|
||||
Enable bool `json:"enable" yaml:"enable"` // 是否启用AI
|
||||
Model string `json:"model" yaml:"model"` // 模型
|
||||
ApiKey string `json:"apiKey" yaml:"apiKey"` // API Key
|
||||
BaseUrl string `json:"baseUrl" yaml:"baseUrl"` // API地址
|
||||
Personality string `json:"personality" yaml:"personality"` // 人设
|
||||
Enable bool `json:"enable" yaml:"enable"` // 是否启用AI
|
||||
Model string `json:"model" yaml:"model"` // 模型
|
||||
ApiKey string `json:"apiKey" yaml:"apiKey"` // API Key
|
||||
BaseUrl string `json:"baseUrl" yaml:"baseUrl"` // API地址
|
||||
Personality string `json:"personality" yaml:"personality"` // 人设
|
||||
DisableGroup []string `json:"disableGroup" yaml:"disableGroup"` // 禁用群组
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
@@ -20,6 +21,11 @@ func handleAtMessage(m entity.Message) {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果在禁用的群组里面,就不处理
|
||||
if slice.Contain(config.Conf.Ai.DisableGroup, m.FromUser) {
|
||||
return
|
||||
}
|
||||
|
||||
// 预处理一下发送的消息,用正则去掉@机器人的内容
|
||||
re := regexp.MustCompile(`@([^ ]+)`)
|
||||
matches := re.FindStringSubmatch(m.Content)
|
||||
|
||||
@@ -8,13 +8,20 @@ import (
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// month
|
||||
// @description: 月排行榜
|
||||
func month() {
|
||||
for _, id := range config.Conf.Task.WaterGroup.Groups {
|
||||
// 消息统计
|
||||
dealMonth(id)
|
||||
// 获取上个月月份
|
||||
yd := time.Now().Local().AddDate(0, 0, -1).Format("200601")
|
||||
// 发送词云
|
||||
fileName := fmt.Sprintf("%s_%s.png", yd, id)
|
||||
utils.SendImage(id, "D:\\Share\\wordcloud\\"+fileName, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +36,7 @@ func dealMonth(gid string) {
|
||||
err := client.MySQL.Model(&entity.Message{}).
|
||||
Where("from_user = ?", gid).
|
||||
Where("`type` < 10000").
|
||||
Where("YEARWEEK(date_format(create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1").
|
||||
Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1").
|
||||
Count(&yesterdayMsgCount).Error
|
||||
if err != nil {
|
||||
log.Printf("获取上月消息总数失败, 错误信息: %v", err)
|
||||
@@ -56,7 +63,7 @@ func dealMonth(gid string) {
|
||||
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
|
||||
Where("tm.from_user = ?", gid).
|
||||
Where("tm.type < 10000").
|
||||
Where("YEARWEEK(date_format(tm.create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1").
|
||||
Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1").
|
||||
Group("tm.group_user, tgu.nickname").Order("`count` DESC").
|
||||
Limit(10)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 水群排行榜
|
||||
@@ -16,7 +17,13 @@ import (
|
||||
// @description: 昨日排行榜
|
||||
func yesterday() {
|
||||
for _, id := range config.Conf.Task.WaterGroup.Groups {
|
||||
// 消息统计
|
||||
dealYesterday(id)
|
||||
// 获取昨日日期
|
||||
yd := time.Now().Local().AddDate(0, 0, -1).Format("20060102")
|
||||
// 发送词云
|
||||
fileName := fmt.Sprintf("%s_%s.png", yd, id)
|
||||
utils.SendImage(id, "D:\\Share\\wordcloud\\"+fileName, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,20 @@ import (
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// week
|
||||
// @description: 周排行榜
|
||||
func week() {
|
||||
for _, id := range config.Conf.Task.WaterGroup.Groups {
|
||||
// 消息统计
|
||||
dealWeek(id)
|
||||
// 获取上周周数
|
||||
year, weekNo := time.Now().Local().AddDate(0, 0, -1).ISOWeek()
|
||||
// 发送词云
|
||||
fileName := fmt.Sprintf("%d%d_%s.png", year, weekNo, id)
|
||||
utils.SendImage(id, "D:\\Share\\wordcloud\\"+fileName, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user