diff --git a/config/config.go b/config/config.go index 8b6f6128..c57764b0 100644 --- a/config/config.go +++ b/config/config.go @@ -141,6 +141,7 @@ type Settings struct { LinkText string `yaml:"link_text"` LinkPic string `yaml:"link_pic"` MusicPrefix string `yaml:"music_prefix"` + DisableWebui bool `yaml:"disable_webui"` } // LoadConfig 从文件中加载配置并初始化单例配置 @@ -1776,3 +1777,15 @@ func GetMusicPrefix() string { } return instance.Settings.MusicPrefix } + +// 获取 GetDisableWebui 的值 +func GetDisableWebui() bool { + mu.Lock() + defer mu.Unlock() + + if instance == nil { + mylog.Println("Warning: instance is nil when trying to GetDisableWebui value.") + return false + } + return instance.Settings.DisableWebui +} diff --git a/handlers/send_group_msg.go b/handlers/send_group_msg.go index b48077bc..0d4d3e0d 100644 --- a/handlers/send_group_msg.go +++ b/handlers/send_group_msg.go @@ -1057,21 +1057,20 @@ func SendStackMessages(apiv2 openapi.OpenAPI, messageid string, GroupID string) mylog.Printf("取出数量: %v", count) pairs := echo.PopGlobalStackMulti(count) for i, pair := range pairs { - mylog.Printf("%v: %v", pair.Group, GroupID) + mylog.Printf("发送栈中的消息匹配 %v: %v", pair.Group, GroupID) if pair.Group == GroupID { // 发送消息 msgseq := echo.GetMappingSeq(messageid) echo.AddMappingSeq(messageid, msgseq+1) pair.GroupMessage.MsgSeq = msgseq + 1 pair.GroupMessage.MsgID = messageid + mylog.Printf("发送栈中的消息 使用MsgSeq[%v]使用MsgID[%v]", pair.GroupMessage.MsgSeq, pair.GroupMessage.MsgID) _, err := apiv2.PostGroupMessage(context.TODO(), pair.Group, pair.GroupMessage) if err != nil { mylog.Printf("发送组合消息失败: %v", err) - continue } else { echo.RemoveFromGlobalStack(i) } - // 检查错误码 if err != nil && strings.Contains(err.Error(), `"code":22009`) { mylog.Printf("信息再次发送失败,加入到队列中,下次被动信息进行发送") diff --git a/httpapi/httpapi.go b/httpapi/httpapi.go index 12960a39..8f2656f0 100644 --- a/httpapi/httpapi.go +++ b/httpapi/httpapi.go @@ -26,6 +26,10 @@ func CombinedMiddleware(api openapi.OpenAPI, apiV2 openapi.OpenAPI) gin.HandlerF handleSendGuildChannelMessage(c, api, apiV2) return } + if c.Request.URL.Path == "/get_group_list" { + handleGetGroupList(c, api, apiV2) + return + } // 调用c.Next()以继续处理请求链 c.Next() @@ -197,3 +201,26 @@ func (c *HttpAPIClient) SendMessage(message map[string]interface{}) error { // 返回nil占位符 return nil } + +// handleGetGroupList 处理获取群列表 +func handleGetGroupList(c *gin.Context, api openapi.OpenAPI, apiV2 openapi.OpenAPI) { + var retmsg string + + // 使用解析后的参数处理请求 + client := &HttpAPIClient{} + // 创建 ActionMessage 实例 + message := callapi.ActionMessage{ + Action: "get_group_list", + } + + // 调用处理函数 + retmsg, err := handlers.GetGroupList(client, api, apiV2, message) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + + // 返回处理结果 + c.Header("Content-Type", "application/json") + c.String(http.StatusOK, retmsg) +} diff --git a/main.go b/main.go index b2ca9fdd..26776507 100644 --- a/main.go +++ b/main.go @@ -298,7 +298,7 @@ func main() { r.POST("/uploadpic", server.UploadBase64ImageHandler(rateLimiter)) r.POST("/uploadrecord", server.UploadBase64RecordHandler(rateLimiter)) r.Static("/channel_temp", "./channel_temp") - if config.GetFrpPort() == "0" { + if config.GetFrpPort() == "0" && !config.GetDisableWebui() { //webui和它的api webuiGroup := r.Group("/webui") { @@ -308,6 +308,8 @@ func main() { webuiGroup.DELETE("/*filepath", webui.CombinedMiddleware(api, apiV2)) webuiGroup.PATCH("/*filepath", webui.CombinedMiddleware(api, apiV2)) } + } else { + mylog.Println("Either FRP port is set to '0' or WebUI is disabled.") } //正向http api http_api_address := config.GetHttpAddress() diff --git a/template/config_template.go b/template/config_template.go index 9c07b5c5..fb921d46 100644 --- a/template/config_template.go +++ b/template/config_template.go @@ -126,6 +126,7 @@ settings: url_pic_transfer : false #把图片url(任意来源图链)变成你备案的白名单url 需要较高上下行+ssl+自备案域名+设置白名单域名(暂时不需要) idmap_pro : false #需开启hash_id配合,高级id转换增强,可以多个真实值bind到同一个虚拟值,对于每个用户,每个群\私聊\判断私聊\频道,都会产生新的虚拟值,但可以多次bind,bind到同一个数字.数据库负担会变大. send_delay : 300 #单位 毫秒 默认300ms 可以视情况减少到100或者50 + disable_webui: false #禁用webui title : "Gensokyo © 2023 - Hoshinonyaruko" #程序的标题 如果多个机器人 可根据标题区分 custom_bot_name : "Gensokyo全域机器人" #自定义机器人名字,会在api调用中返回,默认Gensokyo全域机器人