Skip to content

Commit

Permalink
Beta134 (#308)
Browse files Browse the repository at this point in the history
* beta122

* beta123

* beta124

* beta124

* beta124

* beta127

* beta128

* beta129

* beta130

* beta131

* beta132

* beta133

* beta134
  • Loading branch information
Hoshinonyaruko authored Jan 17, 2024
1 parent 86a712a commit d3a488e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions handlers/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ func RevertTransformedText(data interface{}, msgtype string, api openapi.OpenAPI
}
}

//从当前信息去掉虚拟前缀(因为是虚拟的),不会实际发给应用端
for i, vp := range visualkPrefixs {
if strings.HasPrefix(messageText, vp.Prefix) {
if _, ok := specialPrefixes[i]; ok {
Expand All @@ -560,8 +561,8 @@ func RevertTransformedText(data interface{}, msgtype string, api openapi.OpenAPI
}
// 检查 messageText 的长度是否大于 prefix 的长度
if len(messageText) > len(vp.Prefix) {
// 移除找到的前缀 且messageText不为空格
if messageText != " " {
// 移除找到的前缀 且messageText不为空
if messageText != "" {
messageText = strings.TrimPrefix(messageText, vp.Prefix)
messageText = strings.TrimSpace(messageText)
matchedPrefix = &vp
Expand Down Expand Up @@ -618,7 +619,20 @@ func RevertTransformedText(data interface{}, msgtype string, api openapi.OpenAPI

// 遍历白名单数组,检查是否有匹配项
for _, prefix := range allPrefixes {
if strings.HasPrefix(messageText, prefix) {
trimmedPrefix := prefix
if strings.HasPrefix(prefix, "*") {
// 如果前缀以 * 开头,则移除 *
trimmedPrefix = strings.TrimPrefix(prefix, "*")
} else if strings.HasPrefix(prefix, "&") {
// 如果前缀以 & 开头,则移除 & 并从 trimmedPrefix 前端去除 matchedPrefix.Prefix
trimmedPrefix = strings.TrimPrefix(prefix, "&")
trimmedPrefix = strings.TrimPrefix(trimmedPrefix, matchedPrefix.Prefix)
}

// 从trimmedPrefix中去除前后空格(可能会有bug)
trimmedPrefix = strings.TrimSpace(trimmedPrefix)

if strings.HasPrefix(messageText, trimmedPrefix) {
matched = true
break
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/send_group_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ func auto_md(message callapi.ActionMessage, messageText string, richMediaMessage
isSpecialType = true
}
if len(msg_on_touch) >= len(vp.Prefix) {
if msg_on_touch != " " {
if msg_on_touch != "" {
transmd = true
matchedPrefix = &vp
break // 匹配到了
Expand Down

0 comments on commit d3a488e

Please sign in to comment.