Skip to content

Commit

Permalink
beta29
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko committed Nov 13, 2023
1 parent b7de625 commit 24f3344
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions handlers/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,11 @@ func ConvertToSegmentedMessage(data interface{}) []map[string]interface{} {
newImagePattern := "[CQ:image,file=" + attachment.URL + "]"
msg.Content = msg.Content + newImagePattern
}

// 将msg.Content里的BotID替换成AppID
msg.Content = strings.ReplaceAll(msg.Content, BotID, AppID)
// 使用正则表达式查找所有的[@数字]格式
r := regexp.MustCompile(`<@!(\d+)>`)
atMatches := r.FindAllStringSubmatch(msg.Content, -1)
// 将msg.Content里的BotID替换成AppID
msg.Content = strings.ReplaceAll(msg.Content, BotID, AppID)
for _, match := range atMatches {
userID := match[1]

Expand Down

0 comments on commit 24f3344

Please sign in to comment.