mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-05 16:28:58 +08:00
hide unavailable channels in webui
This commit is contained in:
@@ -1188,9 +1188,10 @@ func (s *Server) handleWebUIVersion(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"ok": true,
|
||||
"gateway_version": firstNonEmptyString(s.gatewayVersion, gatewayBuildVersion()),
|
||||
"webui_version": firstNonEmptyString(s.webuiVersion, detectWebUIVersion(strings.TrimSpace(s.webUIDir))),
|
||||
"ok": true,
|
||||
"gateway_version": firstNonEmptyString(s.gatewayVersion, gatewayBuildVersion()),
|
||||
"webui_version": firstNonEmptyString(s.webuiVersion, detectWebUIVersion(strings.TrimSpace(s.webUIDir))),
|
||||
"compiled_channels": channels.CompiledChannelKeys(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1523,8 +1524,9 @@ func (s *Server) webUISubagentsRuntimePayload(ctx context.Context) map[string]in
|
||||
|
||||
func (s *Server) webUIVersionPayload() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"gateway_version": firstNonEmptyString(s.gatewayVersion, gatewayBuildVersion()),
|
||||
"webui_version": firstNonEmptyString(s.webuiVersion, detectWebUIVersion(strings.TrimSpace(s.webUIDir))),
|
||||
"gateway_version": firstNonEmptyString(s.gatewayVersion, gatewayBuildVersion()),
|
||||
"webui_version": firstNonEmptyString(s.webuiVersion, detectWebUIVersion(strings.TrimSpace(s.webUIDir))),
|
||||
"compiled_channels": channels.CompiledChannelKeys(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
30
pkg/channels/compiled_channels.go
Normal file
30
pkg/channels/compiled_channels.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package channels
|
||||
|
||||
import "sort"
|
||||
|
||||
func CompiledChannelKeys() []string {
|
||||
out := make([]string, 0, 7)
|
||||
if telegramCompiled {
|
||||
out = append(out, "telegram")
|
||||
}
|
||||
if whatsappCompiled {
|
||||
out = append(out, "whatsapp")
|
||||
}
|
||||
if discordCompiled {
|
||||
out = append(out, "discord")
|
||||
}
|
||||
if feishuCompiled {
|
||||
out = append(out, "feishu")
|
||||
}
|
||||
if qqCompiled {
|
||||
out = append(out, "qq")
|
||||
}
|
||||
if dingtalkCompiled {
|
||||
out = append(out, "dingtalk")
|
||||
}
|
||||
if maixcamCompiled {
|
||||
out = append(out, "maixcam")
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
}
|
||||
@@ -30,6 +30,8 @@ type DingTalkChannel struct {
|
||||
sessionWebhooks sync.Map // chatID -> sessionWebhook
|
||||
}
|
||||
|
||||
const dingtalkCompiled = true
|
||||
|
||||
// NewDingTalkChannel creates a new DingTalk channel instance
|
||||
func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus) (*DingTalkChannel, error) {
|
||||
if cfg.ClientID == "" || cfg.ClientSecret == "" {
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type DingTalkChannel struct{ disabledChannel }
|
||||
|
||||
const dingtalkCompiled = false
|
||||
|
||||
func NewDingTalkChannel(cfg config.DingTalkConfig, bus *bus.MessageBus) (*DingTalkChannel, error) {
|
||||
return nil, errChannelDisabled("dingtalk")
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ type DiscordChannel struct {
|
||||
config config.DiscordConfig
|
||||
}
|
||||
|
||||
const discordCompiled = true
|
||||
|
||||
func NewDiscordChannel(cfg config.DiscordConfig, bus *bus.MessageBus) (*DiscordChannel, error) {
|
||||
session, err := discordgo.New("Bot " + cfg.Token)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type DiscordChannel struct{ disabledChannel }
|
||||
|
||||
const discordCompiled = false
|
||||
|
||||
func NewDiscordChannel(cfg config.DiscordConfig, bus *bus.MessageBus) (*DiscordChannel, error) {
|
||||
return nil, errChannelDisabled("discord")
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ type FeishuChannel struct {
|
||||
tenantTokenErr error
|
||||
}
|
||||
|
||||
const feishuCompiled = true
|
||||
|
||||
func (c *FeishuChannel) SupportsAction(action string) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(action)) {
|
||||
case "", "send":
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type FeishuChannel struct{ disabledChannel }
|
||||
|
||||
const feishuCompiled = false
|
||||
|
||||
func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChannel, error) {
|
||||
return nil, errChannelDisabled("feishu")
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ type MaixCamChannel struct {
|
||||
clientsMux sync.RWMutex
|
||||
}
|
||||
|
||||
const maixcamCompiled = true
|
||||
|
||||
type MaixCamMessage struct {
|
||||
Type string `json:"type"`
|
||||
Tips string `json:"tips"`
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type MaixCamChannel struct{ disabledChannel }
|
||||
|
||||
const maixcamCompiled = false
|
||||
|
||||
func NewMaixCamChannel(cfg config.MaixCamConfig, bus *bus.MessageBus) (*MaixCamChannel, error) {
|
||||
return nil, errChannelDisabled("maixcam")
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ type QQChannel struct {
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
const qqCompiled = true
|
||||
|
||||
func NewQQChannel(cfg config.QQConfig, messageBus *bus.MessageBus) (*QQChannel, error) {
|
||||
base := NewBaseChannel("qq", cfg, messageBus, cfg.AllowFrom)
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type QQChannel struct{ disabledChannel }
|
||||
|
||||
const qqCompiled = false
|
||||
|
||||
func NewQQChannel(cfg config.QQConfig, bus *bus.MessageBus) (*QQChannel, error) {
|
||||
return nil, errChannelDisabled("qq")
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ const (
|
||||
telegramStreamMaxRetries = 4
|
||||
)
|
||||
|
||||
const telegramCompiled = true
|
||||
|
||||
type TelegramChannel struct {
|
||||
*BaseChannel
|
||||
bot *telego.Bot
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type TelegramChannel struct{ disabledChannel }
|
||||
|
||||
const telegramCompiled = false
|
||||
|
||||
func NewTelegramChannel(cfg config.TelegramConfig, bus *bus.MessageBus) (*TelegramChannel, error) {
|
||||
return nil, errChannelDisabled("telegram")
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ type WhatsAppChannel struct {
|
||||
connected bool
|
||||
}
|
||||
|
||||
const whatsappCompiled = true
|
||||
|
||||
func NewWhatsAppChannel(cfg config.WhatsAppConfig, bus *bus.MessageBus) (*WhatsAppChannel, error) {
|
||||
base := NewBaseChannel("whatsapp", cfg, bus, cfg.AllowFrom)
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
type WhatsAppChannel struct{ disabledChannel }
|
||||
|
||||
const whatsappCompiled = false
|
||||
|
||||
func NewWhatsAppChannel(cfg config.WhatsAppConfig, bus *bus.MessageBus) (*WhatsAppChannel, error) {
|
||||
return nil, errChannelDisabled("whatsapp")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user