Skip to content

Commit

Permalink
Merge 68b1d13 into e8e8ff7
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Nov 11, 2023
2 parents e8e8ff7 + 68b1d13 commit 3226201
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Settings struct {
VisualPrefixs []string `yaml:"visual_prefixs"`
VisibleIp bool `yaml:"visible_ip"`
ForwardMsgLimit int `yaml:"forward_msg_limit"`
DevMessgeID bool `yaml:"dev_message_id"`
}

// LoadConfig 从文件中加载配置并初始化单例配置
Expand Down Expand Up @@ -766,3 +767,15 @@ func GetBackupPort() string {

return instance.Settings.BackupPort
}

// 获取GetDevMsgID的值
func GetDevMsgID() bool {
mu.Lock()
defer mu.Unlock()

if instance == nil {
mylog.Println("Warning: instance is nil when trying to GetDevMsgID value.")
return false
}
return instance.Settings.DevMessgeID
}
5 changes: 4 additions & 1 deletion handlers/send_group_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ func handleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), message.Params.GroupID)
mylog.Println("通过GetMessageIDByUseridOrGroupid函数获取的message_id:", message.Params.GroupID, messageID)
}

//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}
// 优先发送文本信息
if messageText != "" {
groupReply := generateGroupMessage(messageID, nil, messageText)
Expand Down
4 changes: 4 additions & 0 deletions handlers/send_guild_channel_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func handleSendGuildChannelMsg(client callapi.Client, api openapi.OpenAPI, apiv2
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), channelID)
mylog.Println("通过GetMessageIDByUseridOrGroupid函数获取的message_id:", messageID)
}
//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}
mylog.Println("频道发信息messageText:", messageText)
//mylog.Println("foundItems:", foundItems)
// 优先发送文本信息
Expand Down
8 changes: 8 additions & 0 deletions handlers/send_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func handleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), message.Params.GroupID)
mylog.Println("通过GetMessageIDByUserid函数获取的message_id:", messageID)
}
//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}
// 优先发送文本信息
if messageText != "" {
groupReply := generateGroupMessage(messageID, nil, messageText)
Expand Down Expand Up @@ -162,6 +166,10 @@ func handleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), UserID)
mylog.Println("通过GetMessageIDByUserid函数获取的message_id:", messageID)
}
//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}
mylog.Println("私聊发信息messageText:", messageText)
//mylog.Println("foundItems:", foundItems)

Expand Down
8 changes: 8 additions & 0 deletions handlers/send_private_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func handleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 open
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), UserID)
mylog.Println("通过GetMessageIDByUserid函数获取的message_id:", messageID)
}
//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}
mylog.Println("私聊发信息messageText:", messageText)
//mylog.Println("foundItems:", foundItems)

Expand Down Expand Up @@ -205,6 +209,10 @@ func handleSendGuildChannelPrivateMsg(client callapi.Client, api openapi.OpenAPI
messageID = GetMessageIDByUseridOrGroupid(config.GetAppIDStr(), UserID)
mylog.Println("通过GetMessageIDByUserid函数获取的message_id:", messageID)
}
//开发环境用
if config.GetDevMsgID() {
messageID = "1000"
}

timestamp := time.Now().Unix()
timestampStr := fmt.Sprintf("%d", timestamp)
Expand Down
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ settings:
develop_access_token_dir : "" #开发者测试环境access_token自定义获取地址 默认留空 请留空忽略
develop_bot_id : "1234" #开发者环境需自行获取botid 填入 用户请不要设置这两行...开发者调试用
sandbox_mode : false #默认false 如果你只希望沙箱频道使用,请改为true
dev_message_id : false #在沙盒和测试环境使用无限制msg_id 仅沙盒有效,正式环境请关闭,内测结束后,tx侧未来会移除
title : "Gensokyo © 2023 - Hoshinonyaruko" #程序的标题 如果多个机器人 可根据标题区分
Expand Down
3 changes: 2 additions & 1 deletion template/config_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ settings:
black_prefixs : [""] #可设置多个 比如设置 查询 则查询开头的信息均被拦截 防止审核失败
visual_prefixs : [""] #虚拟前缀 与white_prefixs配合使用 处理流程自动忽略该前缀 remove_prefix remove_at 需为true时生效
visible_ip : false #转换url时,如果server_dir是ip true将以ip形式发出url 默认隐藏url 将server_dir配置为自己域名可以转换url
forward_msg_limit : 3 #发送折叠转发信息时的最大限制条数 若要发转发信息 请设置lazy_message_id为true
forward_msg_limit : 3 #发送折叠转发信息时的最大限制条数 若要发转发信息 请设置lazy_message_id为true
dev_message_id : false #在沙盒和测试环境使用无限制msg_id 仅沙盒有效,正式环境请关闭

0 comments on commit 3226201

Please sign in to comment.