Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta507 #508

Merged
merged 57 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a6ebe57
beta447
Hoshinonyaruko Jun 29, 2024
1d63fae
beta448
Hoshinonyaruko Jul 1, 2024
cd34627
beta449
Hoshinonyaruko Jul 4, 2024
b790b29
beta450
Hoshinonyaruko Jul 4, 2024
7a9b56a
beta451
Hoshinonyaruko Jul 4, 2024
e17d0d4
beta452
Hoshinonyaruko Jul 4, 2024
1318175
beta453
Hoshinonyaruko Jul 4, 2024
b7f291c
beta454
Hoshinonyaruko Jul 4, 2024
f921895
beta455
Hoshinonyaruko Jul 9, 2024
24108c6
btea455
Hoshinonyaruko Jul 9, 2024
7cdc968
beta456
Hoshinonyaruko Jul 9, 2024
b5d784e
beta457
Hoshinonyaruko Jul 9, 2024
61e4001
beta458
Hoshinonyaruko Jul 9, 2024
6d4116a
beta460
Hoshinonyaruko Jul 9, 2024
2c1f1b7
beta460
Hoshinonyaruko Jul 11, 2024
5c312cd
beta461
Hoshinonyaruko Jul 12, 2024
58304eb
beta462
Hoshinonyaruko Jul 13, 2024
7e7c9f3
beta463
Hoshinonyaruko Jul 15, 2024
188f250
beta464
Hoshinonyaruko Jul 15, 2024
af0296d
beta465
Hoshinonyaruko Jul 18, 2024
500135c
beta467
Hoshinonyaruko Jul 21, 2024
c1a588c
beta468
Hoshinonyaruko Jul 21, 2024
1df8e15
beta469
Hoshinonyaruko Jul 21, 2024
f57ab7b
beta470
Hoshinonyaruko Jul 26, 2024
cd21ad9
beta471
Hoshinonyaruko Aug 1, 2024
6039272
beta472
Hoshinonyaruko Aug 1, 2024
c45b450
beta473
Hoshinonyaruko Aug 1, 2024
f89d6c5
beta473
Hoshinonyaruko Aug 3, 2024
b54fdee
beta475
Hoshinonyaruko Aug 5, 2024
a30a697
beta476
Hoshinonyaruko Aug 8, 2024
ab805cc
beta478
Hoshinonyaruko Aug 8, 2024
6debefd
beta479
Hoshinonyaruko Aug 17, 2024
9cc7e5d
beta479
Hoshinonyaruko Aug 17, 2024
c0fe93c
beta480
Hoshinonyaruko Aug 18, 2024
91cf223
beta481
Hoshinonyaruko Aug 18, 2024
a3aa6c1
beta482
Hoshinonyaruko Aug 18, 2024
0917e56
beta483
Hoshinonyaruko Aug 19, 2024
dd1f774
beta484
Hoshinonyaruko Aug 19, 2024
1c87d61
beta485
Hoshinonyaruko Aug 20, 2024
aac474a
beta486
Hoshinonyaruko Aug 20, 2024
2604eb7
beta486
Hoshinonyaruko Aug 20, 2024
76377be
beta487
Hoshinonyaruko Aug 20, 2024
cb095ec
beta487
Hoshinonyaruko Aug 20, 2024
34c92ae
beta489
Hoshinonyaruko Aug 21, 2024
288cf7a
beta490
Hoshinonyaruko Aug 22, 2024
d3a6eb8
beta491
Hoshinonyaruko Aug 22, 2024
b2de7c5
beta492
Hoshinonyaruko Oct 13, 2024
ec68fb1
beta492-1
Hoshinonyaruko Oct 13, 2024
f4d9229
beta494
Hoshinonyaruko Oct 13, 2024
def45ca
beta495
Hoshinonyaruko Oct 13, 2024
6eb3027
beta496
Hoshinonyaruko Oct 13, 2024
81f3aed
beta497
Hoshinonyaruko Oct 13, 2024
0b4001f
beta498
Hoshinonyaruko Oct 15, 2024
105c5c7
beta505
Hoshinonyaruko Nov 21, 2024
07fcc43
beta506
Hoshinonyaruko Nov 21, 2024
dbcfd58
beta507
Hoshinonyaruko Nov 22, 2024
de087c7
Merge branch 'main' into beta507
Hoshinonyaruko Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Processor/ProcessInlineSearch.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"sync"
"time"

@@ -53,10 +54,27 @@ func (p *Processors) ProcessInlineSearch(data *dto.WSInteractionData) error {
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)

//这里处理自动handle回调回应
// 这里处理自动handle回调回应
if config.GetAutoPutInteraction() {
DelayedPutInteraction(p.Api, data.ID, fromuid, fromgid)
exceptions := config.GetPutInteractionExcept() // 会返回一个string[],即例外列表

shouldCall := true // 默认应该调用DelayedPutInteraction,除非下面的条件匹配

// 判断,data.Data.Resolved.ButtonData 是否以返回的string[]中的任意成员开头
for _, prefix := range exceptions {
if strings.HasPrefix(data.Data.Resolved.ButtonData, prefix) {
shouldCall = false // 如果匹配到任何一个前缀,设置shouldCall为false
break // 找到匹配项,无需继续检查
}
}

// 如果data.Data.Resolved.ButtonData不以返回的string[]中的任意成员开头,
// 则调用DelayedPutInteraction,否则不调用
if shouldCall {
DelayedPutInteraction(p.Api, data.ID, fromuid, fromgid)
}
}

if config.GetIdmapPro() {
//将真实id转为int userid64
GroupID64, userid64, err = idmap.StoreIDv2Pro(fromgid, fromuid)
12 changes: 7 additions & 5 deletions acnode/acnode.go
Original file line number Diff line number Diff line change
@@ -354,12 +354,14 @@ func CheckWordOUT(word string) string {
return "错误:缺少 'word' 参数"
}

//不替换base64
if strings.Contains(word, "base64://") {
// 当word包含特定字符串时原样返回
//fmt.Printf("原样返回的文本:%s", word)
return word
}

if len([]rune(word)) > 5000 {
if strings.Contains(word, "[CQ:image,file=base64://") {
// 当word包含特定字符串时原样返回
fmt.Printf("原样返回的文本:%s", word)
return word
}
log.Printf("错误请求:字符数超过最大限制(5000字符)。内容:%s", word)
return "错误:字符数超过最大限制(5000字符)"
}
12 changes: 12 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -2400,3 +2400,15 @@ func GetDisableErrorChan() bool {
}
return instance.Settings.DisableErrorChan
}

// 获取 PutInteractionExcept 数组
func GetPutInteractionExcept() []string {
mu.RLock()
defer mu.RUnlock()

if instance == nil {
mylog.Println("Warning: instance is nil when trying to get PutInteractionExcept.")
return nil
}
return instance.Settings.PutInteractionExcept
}
63 changes: 33 additions & 30 deletions handlers/message_parser.go
Original file line number Diff line number Diff line change
@@ -1089,43 +1089,46 @@ func RevertTransformedText(data interface{}, msgtype string, api openapi.OpenAPI
}
}

//如果二级指令白名单全部是*(忽略自身,那么不判断二级白名单是否匹配)
if allStarPrefixed {
if len(messageText) == len(matchedPrefix.Prefix) {
// 调用 GetVisualPrefixsBypass 获取前缀数组
visualPrefixes := config.GetVisualPrefixsBypass()
// 判断 messageText 是否以数组中的任一前缀开头
for _, prefix := range visualPrefixes {
if strings.HasPrefix(originmessageText, prefix) {
matched = true
break
}
}

if !matched {
//如果二级指令白名单全部是*(忽略自身,那么不判断二级白名单是否匹配)
if allStarPrefixed {
if len(messageText) == len(matchedPrefix.Prefix) {
matched = true
} else {
matched = false
}
} else {
matched = false
// 调用 GetVisualPrefixsBypass 获取前缀数组
visualPrefixes := config.GetVisualPrefixsBypass()
// 判断 messageText 是否以数组中的任一前缀开头
for _, prefix := range visualPrefixes {
if strings.HasPrefix(originmessageText, prefix) {
// 遍历白名单数组,检查是否有匹配项
for _, prefix := range allPrefixes {
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中去除前后空格
trimmedPrefix = strings.TrimSpace(trimmedPrefix)
// trimmedPrefix如果是""就会导致任意内容都是true,所以不能是""
if strings.HasPrefix(messageText, trimmedPrefix) && trimmedPrefix != "" {
matched = true
break
}
}
}
} else {
// 遍历白名单数组,检查是否有匹配项
for _, prefix := range allPrefixes {
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)
// trimmedPrefix如果是""就会导致任意内容都是true,所以不能是""
if strings.HasPrefix(messageText, trimmedPrefix) && trimmedPrefix != "" {
matched = true
break
}
}
}

// 如果没有匹配项,则将 messageText 置为对应的兜底回复
36 changes: 34 additions & 2 deletions handlers/send_group_msg.go
Original file line number Diff line number Diff line change
@@ -990,8 +990,24 @@ func generateGroupMessage(id string, eventid string, foundItems map[string][]str
fileRecordData = silk.EncoderSilk(fileRecordData)
mylog.Printf("音频转码ing")
}
base64Encoded := base64.StdEncoding.EncodeToString(fileRecordData)
if config.GetUploadPicV2Base64() {
// 直接上传语音返回 MessageToCreate type=7
messageToCreate, err := images.CreateAndUploadMediaMessage(context.TODO(), base64Encoded, eventid, 1, false, "", groupid, id, msgseq, apiv2)
if err != nil {
mylog.Printf("Error messageToCreate: %v", err)
return &dto.MessageToCreate{
Content: "错误: 上传语音失败",
MsgID: id,
EventID: eventid,
MsgSeq: msgseq,
MsgType: 0, // 默认文本类型
}
}
return messageToCreate
}
// 将解码的语音数据转换回base64格式并上传
imageURL, err := images.UploadBase64RecordToServer(base64.StdEncoding.EncodeToString(fileRecordData))
imageURL, err := images.UploadBase64RecordToServer(base64Encoded)
if err != nil {
mylog.Printf("failed to upload base64 record: %v", err)
return nil
@@ -1578,8 +1594,24 @@ func generatePrivateMessage(id string, eventid string, foundItems map[string][]s
fileRecordData = silk.EncoderSilk(fileRecordData)
mylog.Printf("音频转码ing")
}
base64Encoded := base64.StdEncoding.EncodeToString(fileRecordData)
if config.GetUploadPicV2Base64() {
// 直接上传语音返回 MessageToCreate type=7
messageToCreate, err := images.CreateAndUploadMediaMessagePrivate(context.TODO(), base64Encoded, eventid, 1, false, "", userid, id, msgseq, apiv2)
if err != nil {
mylog.Printf("Error messageToCreate: %v", err)
return &dto.MessageToCreate{
Content: "错误: 上传语音失败",
MsgID: id,
EventID: eventid,
MsgSeq: msgseq,
MsgType: 0, // 默认文本类型
}
}
return messageToCreate
}
// 将解码的语音数据转换回base64格式并上传
imageURL, err := images.UploadBase64RecordToServer(base64.StdEncoding.EncodeToString(fileRecordData))
imageURL, err := images.UploadBase64RecordToServer(base64Encoded)
if err != nil {
mylog.Printf("failed to upload base64 record: %v", err)
return nil
21 changes: 11 additions & 10 deletions structs/structs.go
Original file line number Diff line number Diff line change
@@ -109,16 +109,17 @@ type Settings struct {
//增长营销类
SelfIntroduce []string `yaml:"self_introduce"`
//api修改
GetGroupListAllGuilds bool `yaml:"get_g_list_all_guilds"`
GetGroupListGuilds string `yaml:"get_g_list_guilds"`
GetGroupListReturnGuilds bool `yaml:"get_g_list_return_guilds"`
GetGroupListGuidsType int `yaml:"get_g_list_guilds_type"`
GetGroupListDelay int `yaml:"get_g_list_delay"`
ForwardMsgLimit int `yaml:"forward_msg_limit"`
CustomBotName string `yaml:"custom_bot_name"`
TransFormApiIds bool `yaml:"transform_api_ids"`
AutoPutInteraction bool `yaml:"auto_put_interaction"`
PutInteractionDelay int `yaml:"put_interaction_delay"`
GetGroupListAllGuilds bool `yaml:"get_g_list_all_guilds"`
GetGroupListGuilds string `yaml:"get_g_list_guilds"`
GetGroupListReturnGuilds bool `yaml:"get_g_list_return_guilds"`
GetGroupListGuidsType int `yaml:"get_g_list_guilds_type"`
GetGroupListDelay int `yaml:"get_g_list_delay"`
ForwardMsgLimit int `yaml:"forward_msg_limit"`
CustomBotName string `yaml:"custom_bot_name"`
TransFormApiIds bool `yaml:"transform_api_ids"`
AutoPutInteraction bool `yaml:"auto_put_interaction"`
PutInteractionDelay int `yaml:"put_interaction_delay"`
PutInteractionExcept []string `yaml:"put_interaction_except"`
//onebot修改
TwoWayEcho bool `yaml:"twoway_echo"`
Array bool `yaml:"array"`
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ settings:
transform_api_ids : true #对get_group_menmber_list\get_group_member_info\get_group_list生效,是否在其中返回转换后的值(默认转换,不转换请自行处理插件逻辑,比如调用gsk的http api转换)
auto_put_interaction : false #自动回应按钮回调的/interactions/{interaction_id} 注本api需要邮件申请,详细方法参考群公告:196173384
put_interaction_delay : 0 #单位毫秒 表示回应已收到回调类型的按钮的毫秒数 会按用户进行区分 非全局delay
put_interaction_except : [] #自动回复按钮的例外,当你想要自己用api回复,回复特殊状态时,将指令前缀填入进去(根据按钮的data字段判断的)

#Onebot修改
twoway_echo : false #是否采用双向echo,根据机器人选择,獭獭\早苗 true 红色问答\椛椛 或者其他 请使用 false