refactor: 重构 GetLoginAccountInfo 函数,移除 actionManager 依赖,并更新相关调用;修改 sendAlertMessage 函数为发送合并转发

This commit is contained in:
lixiangwuxian
2025-04-12 01:13:22 +08:00
parent 8af78f8422
commit 46a82e1fef
6 changed files with 45 additions and 78 deletions

View File

@@ -78,23 +78,9 @@ func (msg *NodeMessage) ToCQString() string {
return fmt.Sprintf("[CQ:node,user_id=%s,nickname=%s]", msg.Data.UserID, msg.Data.Nickname)
}
func (msg *NodeMessage) ParseMessage(data string) error {
// 解析已有消息节点
idRe := regexp.MustCompile(`\[CQ:node,id=(.*?)\]`)
matches := idRe.FindStringSubmatch(data)
if len(matches) == 2 {
msg.Data.ID = matches[1]
return nil
}
// 解析自定义消息节点
customRe := regexp.MustCompile(`\[CQ:node,user_id=(.*?),nickname=(.*?)\]`)
matches = customRe.FindStringSubmatch(data)
if len(matches) == 3 {
msg.Data.UserID = matches[1]
msg.Data.Nickname = matches[2]
return nil
}
return fmt.Errorf("转发消息节点格式不正确")
func (msg *NodeMessage) ParseMessage(userId string, nickname string, content []any) *NodeMessage {
msg.Data.UserID = userId
msg.Data.Nickname = nickname
msg.Data.Content = content
return msg
}