fix: optimize database performance and improve LLM reply/mention handling

This commit is contained in:
AkashiNeko
2025-07-22 21:12:44 +08:00
parent f5d3fa2f90
commit 9747c44e28
9 changed files with 27 additions and 7 deletions

BIN
bin/go-hurobot Executable file

Binary file not shown.

View File

@@ -158,6 +158,8 @@ func decodeSpecialChars(raw string) string {
"[", "[",
"]", "]",
"&", "&",
"&lt;", "<",
"&gt;", ">",
)
return replacer.Replace(raw)
}
@@ -167,6 +169,8 @@ func encodeSpecialChars(raw string) string {
"[", "&#91;",
"]", "&#93;",
"&", "&amp;",
"<", "&lt;",
">", "&gt;",
)
return replacer.Replace(raw)
}

View File

@@ -1,12 +1,14 @@
package cmds
import (
"go-hurobot/config"
"go-hurobot/qbot"
"slices"
"strconv"
)
func cmd_essence(c *qbot.Client, raw *qbot.Message, args *ArgsList) {
if raw.GroupID != 948697448 {
if !slices.Contains(config.BotOwnerGroupIDs, raw.GroupID) {
return
}
help := "请回复一条消息,再使用 essence [set|delete]"

View File

@@ -2,13 +2,15 @@ package cmds
import (
"fmt"
"go-hurobot/config"
"go-hurobot/qbot"
"slices"
"strconv"
"strings"
)
func cmd_group(c *qbot.Client, raw *qbot.Message, args *ArgsList) {
if raw.GroupID != 948697448 {
if !slices.Contains(config.BotOwnerGroupIDs, raw.GroupID) {
return
}
const help = "Usage: group [rename <group name> | op | deop | banme <time>]"

View File

@@ -1,11 +1,17 @@
package cmds
import (
"go-hurobot/config"
"go-hurobot/qbot"
"slices"
"strconv"
)
func cmd_specialtitle(c *qbot.Client, msg *qbot.Message, args *ArgsList) {
if !slices.Contains(config.BotOwnerGroupIDs, msg.GroupID) {
return
}
if args.Size == 1 {
c.SendReplyMsg(msg, "Usage: specialtitle <specialtitle>")
} else if len(msg.Array) > 1 && msg.Array[1].Type != qbot.At {
@@ -15,7 +21,7 @@ func cmd_specialtitle(c *qbot.Client, msg *qbot.Message, args *ArgsList) {
} else {
if len(msg.Array) > 1 {
id := str2uin64(msg.Array[1].Content)
c.SetGroupSpecialTitle(msg.GroupID, id, args.Contents[1])
c.SetGroupSpecialTitle(msg.GroupID, id, decodeSpecialChars(args.Contents[1]))
return
}
c.SetGroupSpecialTitle(msg.GroupID, msg.UserID, args.Contents[1])

View File

@@ -41,6 +41,11 @@ const (
env_OKX_MIRROR_API_KEY = "OKX_MIRROR_API_KEY"
)
var BotOwnerGroupIDs = []uint64{
948697448,
866738031,
}
func getEnvString(env string, def string) string {
val := os.Getenv(env)
if val == "" {

View File

@@ -31,3 +31,5 @@ CREATE TABLE group_llm_configs (
"model" TEXT,
PRIMARY KEY ("group_id")
);
CREATE INDEX idx_messages_covering ON messages("group_id", "is_cmd", "time" DESC, "user_id", "content", "msg_id");

View File

@@ -81,7 +81,7 @@ add将追加你对当前群聊的认知del将删除指定索引的信息。
4. 普通的回复应简短,如果你的回复比较长(比如有人问一些专业的问题),可以在一次回复中将长文本拆成多条信息(每一段都作为一条回复)。请保证每次至少发送一条消息。
msg <消息内容>
如果一个msg命令的消息中包含换行使用\n而不是实际的换行符。但是不同的msg命令之间一定使用换行符分隔。
使用 [CQ:at,qq=<用户id>] 可以@指定用户。例如:[CQ:at,qq=1006554341]
只能通过 [CQ:at,qq=<用户id>] @指定用户。例如:[CQ:at,qq=1006554341]
使用 [CQ:reply,id=<消息id>] 可以回复指定消息。消息id位于每条消息内容前面的<>中。这个用法必须放在每条消息文本的前面,而不能在中间或结尾。
下面是一个示例,这段示例将更新记忆中的用户昵称、用户信息和群聊信息,并发送三条消息:
@@ -89,8 +89,7 @@ nickname 1006554341 氟氟
userinfo 1006554341 add 喜欢编程
userinfo 1006554341 add 喜欢狐狸
groupinfo add 群内经常讨论技术问题
msg 你好氟氟!
msg 看起来你很喜欢编程呢
msg 你好氟氟!\n看起来你很喜欢编程呢
msg 有什么技术问题可以一起讨论哦
对于简短的内容只发送一条消息即一个msg命令。如果要发送的内容比较多可以拆分成多条消息发送。

View File

@@ -22,7 +22,7 @@ func parseContent(msgarr *[]MsgItem) (result string) {
case Record:
result = "[语音(无法查看)]"
case Reply:
result = ""
result = "[CQ:reply,id=" + item.Content + "]"
case File:
result = "[文件(无法查看)]"
case Forward: