-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(channels): add Mattermost channel support #1288
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Mattermost | ||
|
|
||
| Mattermost 是一个开源的团队协作平台。PicoClaw 通过 WebSocket API v4 和 REST API v4 连接到 Mattermost 服务器,支持接收和发送消息、文件上传、线程回复和输入指示器。 | ||
|
|
||
| ## 配置 | ||
|
|
||
| ```json | ||
| { | ||
| "channels": { | ||
| "mattermost": { | ||
| "enabled": true, | ||
| "url": "https://your-mattermost-server.com", | ||
| "token": "YOUR_BOT_TOKEN", | ||
| "username": "picoclaw", | ||
| "reply_in_thread": true, | ||
| "allow_from": ["YOUR_USER_ID"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| | 字段 | 类型 | 必填 | 描述 | | ||
| | ---------------- | ------ | ---- | ---------------------------------------- | | ||
| | enabled | bool | 是 | 是否启用 Mattermost 频道 | | ||
| | url | string | 是 | Mattermost 服务器地址 | | ||
| | token | string | 是 | 机器人访问令牌 | | ||
| | username | string | 否 | 机器人用户名(用于去除 @提及) | | ||
| | reply_in_thread | bool | 否 | 在频道中自动使用线程回复(默认:true) | | ||
| | allow_from | array | 否 | 用户ID白名单,空表示允许所有用户 | | ||
| | group_trigger | object | 否 | 群组触发设置 | | ||
| | typing | object | 否 | 输入指示器设置 | | ||
| | placeholder | object | 否 | 占位消息设置(默认启用,文本:"Thinking... 💭")| | ||
|
|
||
lmorchard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## 设置流程 | ||
|
|
||
| 1. 前往 Mattermost 管理后台 → 集成 → 机器人帐户 → 添加机器人帐户 | ||
| 2. 复制机器人令牌 | ||
| 3. 将令牌填入配置文件中 | ||
| 4. 将机器人添加到需要的频道 | ||
| 5. 通过私信或 @提及 与机器人交互 | ||
|
|
||
| ## 功能 | ||
|
|
||
| - **线程回复**:频道消息自动使用线程,私信保持平面结构 | ||
| - **自动重连**:WebSocket 断开后自动重连(指数退避 5s-60s) | ||
| - **消息分割**:超长消息自动分割(上限 4000 字符) | ||
| - **文件上传**:支持通过 MediaSender 接口上传文件 | ||
| - **输入指示器**:支持显示"正在输入"状态 | ||
| - **消息编辑**:支持编辑已发送的消息 | ||
| - **占位消息**:发送"思考中..."占位消息,完成后替换为实际回复 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package mattermost | ||
|
|
||
| import ( | ||
| "github.com/sipeed/picoclaw/pkg/bus" | ||
| "github.com/sipeed/picoclaw/pkg/channels" | ||
| "github.com/sipeed/picoclaw/pkg/config" | ||
| ) | ||
|
|
||
| func init() { | ||
| channels.RegisterFactory("mattermost", func(cfg *config.Config, b *bus.MessageBus) (channels.Channel, error) { | ||
| return NewMattermostChannel(cfg.Channels.Mattermost, b) | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.