Skip to content

Commit

Permalink
fixat
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko committed Oct 28, 2023
1 parent 4186970 commit 2f26828
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion handlers/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/hoshinonyaruko/gensokyo/callapi"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/tencent-connect/botgo/dto"
)

Expand Down Expand Up @@ -154,7 +155,12 @@ func transformMessageText(messageText string) string {
return re.ReplaceAllStringFunc(messageText, func(m string) string {
submatches := re.FindStringSubmatch(m)
if len(submatches) > 1 {
return "<@!" + submatches[1] + ">"
realUserID, err := idmap.RetrieveRowByIDv2(submatches[1])
if err != nil {
log.Printf("Error retrieving user ID: %v", err)
return m // 如果出错,返回原始匹配
}
return "<@!" + realUserID + ">"
}
return m
})
Expand Down

0 comments on commit 2f26828

Please sign in to comment.