mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat: add Matrix channel support
This commit is contained in:
@@ -423,7 +423,7 @@ func (s *appState) hasEnabledChannel() bool {
|
||||
c := s.config.Channels
|
||||
return c.Telegram.Enabled || c.Discord.Enabled || c.QQ.Enabled || c.MaixCam.Enabled ||
|
||||
c.WhatsApp.Enabled || c.Feishu.Enabled || c.DingTalk.Enabled || c.Slack.Enabled ||
|
||||
c.LINE.Enabled || c.OneBot.Enabled || c.WeCom.Enabled || c.WeComApp.Enabled
|
||||
c.Matrix.Enabled || c.LINE.Enabled || c.OneBot.Enabled || c.WeCom.Enabled || c.WeComApp.Enabled
|
||||
}
|
||||
|
||||
func (s *appState) confirmApplyOrDiscard(onApply func(), onDiscard func()) {
|
||||
|
||||
@@ -61,6 +61,12 @@ func (s *appState) buildChannelMenuItems() []MenuItem {
|
||||
s.config.Channels.Slack.Enabled,
|
||||
func() { s.push("channel-slack", s.slackForm()) },
|
||||
),
|
||||
channelItem(
|
||||
"Matrix",
|
||||
"Matrix bot settings",
|
||||
s.config.Channels.Matrix.Enabled,
|
||||
func() { s.push("channel-matrix", s.matrixForm()) },
|
||||
),
|
||||
channelItem(
|
||||
"LINE",
|
||||
"LINE bot settings",
|
||||
@@ -233,6 +239,28 @@ func (s *appState) lineForm() tview.Primitive {
|
||||
return wrapWithBack(form, s)
|
||||
}
|
||||
|
||||
func (s *appState) matrixForm() tview.Primitive {
|
||||
cfg := &s.config.Channels.Matrix
|
||||
form := baseChannelForm("Matrix", cfg.Enabled, s.makeChannelOnEnabled(&cfg.Enabled))
|
||||
form.AddInputField("Homeserver", cfg.Homeserver, 128, nil, func(text string) {
|
||||
cfg.Homeserver = strings.TrimSpace(text)
|
||||
})
|
||||
form.AddInputField("User ID", cfg.UserID, 128, nil, func(text string) {
|
||||
cfg.UserID = strings.TrimSpace(text)
|
||||
})
|
||||
form.AddInputField("Access Token", cfg.AccessToken, 128, nil, func(text string) {
|
||||
cfg.AccessToken = strings.TrimSpace(text)
|
||||
})
|
||||
form.AddInputField("Device ID", cfg.DeviceID, 128, nil, func(text string) {
|
||||
cfg.DeviceID = strings.TrimSpace(text)
|
||||
})
|
||||
form.AddCheckbox("Join On Invite", cfg.JoinOnInvite, func(checked bool) {
|
||||
cfg.JoinOnInvite = checked
|
||||
})
|
||||
addAllowFromField(form, &cfg.AllowFrom)
|
||||
return wrapWithBack(form, s)
|
||||
}
|
||||
|
||||
func (s *appState) onebotForm() tview.Primitive {
|
||||
cfg := &s.config.Channels.OneBot
|
||||
form := baseChannelForm("OneBot", cfg.Enabled, s.makeChannelOnEnabled(&cfg.Enabled))
|
||||
|
||||
@@ -9,7 +9,7 @@ A standalone launcher for PicoClaw, providing visual JSON editing and OAuth prov
|
||||
|
||||
- 📝 **Config Editor** — Sidebar-based settings UI with model management, channel configuration forms, and a raw JSON editor
|
||||
- 🤖 **Model Management** — Model card grid with availability status (grayed out without API key), primary model selection, add/edit/delete with required/optional field separation
|
||||
- 📡 **Channel Configuration** — Form-based settings for 12 channel types (Telegram, Discord, Slack, WeCom, DingTalk, Feishu, LINE, WhatsApp, QQ, OneBot, MaixCAM, etc.) with documentation links
|
||||
- 📡 **Channel Configuration** — Form-based settings for 13 channel types (Telegram, Discord, Slack, Matrix, WeCom, DingTalk, Feishu, LINE, WhatsApp, QQ, OneBot, MaixCAM, etc.) with documentation links
|
||||
- 🔐 **Provider Auth** — Login to OpenAI (Device Code), Anthropic (API Token), Google Antigravity (Browser OAuth)
|
||||
- 🌐 **Embedded Frontend** — Compiles to a single binary with no external dependencies
|
||||
- 🌍 **i18n** — Chinese/English language switching with browser auto-detection
|
||||
|
||||
@@ -538,6 +538,7 @@
|
||||
<div class="sidebar-item" data-panel="panelCh_telegram">Telegram</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_discord">Discord</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_slack">Slack</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_matrix">Matrix</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_wecom">WeCom</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_wecom_app">WeCom App</div>
|
||||
<div class="sidebar-item" data-panel="panelCh_dingtalk">DingTalk</div>
|
||||
@@ -606,6 +607,7 @@
|
||||
<div class="content-panel" id="panelCh_telegram"></div>
|
||||
<div class="content-panel" id="panelCh_discord"></div>
|
||||
<div class="content-panel" id="panelCh_slack"></div>
|
||||
<div class="content-panel" id="panelCh_matrix"></div>
|
||||
<div class="content-panel" id="panelCh_wecom"></div>
|
||||
<div class="content-panel" id="panelCh_wecom_app"></div>
|
||||
<div class="content-panel" id="panelCh_dingtalk"></div>
|
||||
@@ -1011,6 +1013,16 @@ const channelSchemas = {
|
||||
{ key: 'app_token', label: 'App Token', type: 'password', placeholder: 'xapp-...' },
|
||||
]
|
||||
},
|
||||
matrix: {
|
||||
title: 'Matrix', configKey: 'matrix', docSlug: null,
|
||||
fields: [
|
||||
{ key: 'homeserver', label: 'Homeserver', type: 'text', placeholder: 'https://matrix.org' },
|
||||
{ key: 'user_id', label: 'User ID', type: 'text', placeholder: '@bot:matrix.org' },
|
||||
{ key: 'access_token', label: 'Access Token', type: 'password', placeholder: 'syt_...' },
|
||||
{ key: 'device_id', label: 'Device ID', type: 'text', placeholder: 'Optional device ID' },
|
||||
{ key: 'join_on_invite', label: 'Join On Invite', type: 'toggle' },
|
||||
]
|
||||
},
|
||||
wecom: {
|
||||
title: 'WeCom (Bot)', configKey: 'wecom', docSlug: 'wecom-bot',
|
||||
fields: [
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/irc"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/line"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/maixcam"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/matrix"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/onebot"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/pico"
|
||||
_ "github.com/sipeed/picoclaw/pkg/channels/qq"
|
||||
|
||||
Reference in New Issue
Block a user