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

Beta22 #74

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ _✨ 基于 [OneBot](https://github.com/howmanybots/onebot/blob/master/README.md
## 兼容性
gensokyo兼容 [OneBot-v11](https://github.com/botuniverse/onebot-11) ,并在其基础上做了一些扩展,详情请看 OneBot 的文档。

可将官方的websocket和api转换至onebotv11标准,和koishi,nonebot2,trss等项目的onebot适配器相连接使用.
可将官方的websocket和api转换至onebotv11标准,

支持连接koishi,nonebot2,trss,zerobot,MiraiCQ,hoshino..

可以与支持onebotV11适配器的项目相连接使用.

实现插件开发和用户开发者无需重新开发,复用过往生态的插件和使用体验.

目前还处于早期阶段.....交流群:196173384
持续完善中.....交流群:196173384

欢迎测试,询问任何有关使用的问题,有问必答,有难必帮~

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 仅沙盒有效,正式环境请关闭
Loading