Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ff18c3626 | ||
|
|
6acb3b79ec | ||
|
|
f895d045a7 | ||
|
|
eb2e292e8e | ||
|
|
8f378e7fc9 | ||
|
|
497e17ec62 |
@@ -13,6 +13,7 @@ type Friend struct {
|
|||||||
Pinyin string `json:"pinyin"` // 昵称拼音大写首字母
|
Pinyin string `json:"pinyin"` // 昵称拼音大写首字母
|
||||||
PinyinAll string `json:"pinyinAll"` // 昵称全拼
|
PinyinAll string `json:"pinyinAll"` // 昵称全拼
|
||||||
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
||||||
|
AiModel string `json:"aiModel"` // AI模型
|
||||||
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
||||||
EnableWelcome bool `json:"enableWelcome" 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"` // 是否正常
|
IsOk bool `json:"isOk" gorm:"type:tinyint(1) default 0 not null"` // 是否正常
|
||||||
|
|||||||
@@ -28,9 +28,13 @@ func AI(m *plugin.MessageContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 取出所有启用了AI的好友或群组
|
// 取出所有启用了AI的好友或群组
|
||||||
var count int64
|
var friendInfo entity.Friend
|
||||||
client.MySQL.Model(&entity.Friend{}).Where("enable_ai IS TRUE").Where("wxid = ?", m.FromUser).Count(&count)
|
client.MySQL.Where("wxid = ?", m.FromUser).First(&friendInfo)
|
||||||
if count < 1 {
|
if friendInfo.Wxid == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 判断有没有启用AI
|
||||||
|
if !friendInfo.EnableAi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +97,9 @@ func AI(m *plugin.MessageContext) {
|
|||||||
|
|
||||||
// 配置模型
|
// 配置模型
|
||||||
chatModel := openai.GPT3Dot5Turbo0613
|
chatModel := openai.GPT3Dot5Turbo0613
|
||||||
if config.Conf.Ai.Model != "" {
|
if friendInfo.AiModel != "" {
|
||||||
|
chatModel = friendInfo.AiModel
|
||||||
|
} else if config.Conf.Ai.Model != "" {
|
||||||
chatModel = config.Conf.Ai.Model
|
chatModel = config.Conf.Ai.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +123,12 @@ func AI(m *plugin.MessageContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回消息为空
|
||||||
|
if resp.Choices[0].Message.Content == "" {
|
||||||
|
utils.SendMessage(m.FromUser, m.GroupUser, "AI似乎抽风了,没有告诉我你需要的回答~", 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 保存一下AI 返回的消息,消息 Id 使用传入 Id 的负数
|
// 保存一下AI 返回的消息,消息 Id 使用传入 Id 的负数
|
||||||
var replyMessage entity.Message
|
var replyMessage entity.Message
|
||||||
replyMessage.MsgId = -m.MsgId
|
replyMessage.MsgId = -m.MsgId
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type FriendItem struct {
|
|||||||
PinyinAll string // 昵称全拼
|
PinyinAll string // 昵称全拼
|
||||||
Wxid string // 微信原始Id
|
Wxid string // 微信原始Id
|
||||||
EnableAi bool // 是否使用AI
|
EnableAi bool // 是否使用AI
|
||||||
|
AiModel string // AI模型
|
||||||
EnableChatRank bool // 是否使用聊天排行
|
EnableChatRank bool // 是否使用聊天排行
|
||||||
EnableWelcome bool // 是否使用迎新
|
EnableWelcome bool // 是否使用迎新
|
||||||
EnableCommand bool // 是否启用指令
|
EnableCommand bool // 是否启用指令
|
||||||
|
|||||||
Reference in New Issue
Block a user