{"id":18953014,"url":"https://github.com/walkure/aggrechans","last_synced_at":"2025-04-16T02:31:38.723Z","repository":{"id":65194605,"uuid":"427429867","full_name":"walkure/aggrechans","owner":"walkure","description":"Slackの全Public channelにおける人間の発言を一つのチャンネルに集約して流したりするbot","archived":false,"fork":false,"pushed_at":"2023-02-15T14:00:21.000Z","size":47,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T01:11:56.603Z","etag":null,"topics":["golang","slack","slack-bot"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/walkure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-12T16:42:00.000Z","updated_at":"2023-10-06T14:07:30.000Z","dependencies_parsed_at":"2024-06-20T13:00:46.993Z","dependency_job_id":"bb591ef2-5ab1-4177-ad0c-9bd393ffafa9","html_url":"https://github.com/walkure/aggrechans","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkure%2Faggrechans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkure%2Faggrechans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkure%2Faggrechans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkure%2Faggrechans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkure","download_url":"https://codeload.github.com/walkure/aggrechans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249184535,"owners_count":21226395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","slack","slack-bot"],"created_at":"2024-11-08T13:35:41.547Z","updated_at":"2025-04-16T02:31:38.432Z","avatar_url":"https://github.com/walkure.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aggrechans\n\nSlackの全Public channelにおける人間の発言を一つのチャンネルに集約して流したりします。\n\n## Appの権限設定\n\n- アプリを生成して、適当に設定します。\n- (必要に応じてsocket modeを有効にして)eventを有効化します。\n- スコープは以下の設定をしてください。\n- private channelに発言させるには、private channelでintegration設定で当該アプリを入れる必要があります。\n\n### scopes\n\n#### Bot scope\n\n- `users:read` ユーザIDとユーザ名の変換\n- `channels:read` チャンネルIDとチャンネル名の変換\n- `chat:write.customize` 名前を変更してpostする権限\n  - `chat:write` 親権限\n- `team:read` チームURIのドメイン取得\n\n#### User scope\n\n- `channels:history` イベントを受信\n- eventsをuser eventsにした場合\n  - `channels:read` - チャンネル状態の変化イベント\n  - `users:read` - ユーザ情報の変更イベント\n\n### Subscribe events\n\n#### bot(or user) events\n\n- `channel_rename` - チャンネルのリネーム\n- `channel_created` - チャンネルの作成\n- `channel_unarchive` - チャンネルのアーカイブ解除\n- `user_change` - ユーザ情報の変更\n\n#### user events\n\n- `message.channels` public channelに流れるメッセージ\n\n## Message dispatch rules\n\n### 全メッセージを一箇所に集約\n\n環境変数 `AGGREGATE_CHANNEL_ID` にチャンネルIDを指定して起動すると、受信した人間による全発言を投入します。\n\n巨大Workspaceなどでは[chat.postMessage](https://api.slack.com/methods/chat.postMessage)の[API rate limit](https://api.slack.com/docs/rate-limits#tier_t5)を突き抜けるかもしれません。\n\n### チャンネル名で集約先を分ける\n\n環境変数`DISPATCH_CHANNEL`にJSON形式で集約ルールを書くことが出来ます。`prefix`と`suffix`の2つがあり、`prefix`を先に評価します。\n\n```json\n[{\n  \"prefix\": \"times_\",\n  \"cid\": \"CIDTIMES\"\n},{\n  \"suffix\": \"_zatsu\",\n  \"cid\": \"CIDZATSU\"\n},{\n  \"suffix\": \"_foobar\",\n  \"cid\": \"CIDFOOBAR\"\n}]\n```\n\n## Redis cache\n\nSlackが送ってくるイベントではチャンネルとユーザ名が内部UIDで表記されているため、適当にlookupする必要があります。\nオンメモリでキャッシュしていますが、なんかの弾みでプロセスが再起動される毎にAPI叩くのを避けるためにRedisに保存することができます。\n\n`REDIS_TLS_URL`(TLSでの接続URL)、`REDIS_URL`(生TCPでの接続URL)、`REDIS_HOST`(host:port形式)のどれか環境変数で設定すると、Redisをオンメモリキャッシュの裏として使うようになります。\n\n現状Redisに書き込むkeyは特にTTLを設定していないので、適当に`allkeys-lru`などのeviction policyを設定してください。\n\n## Heroku\n\nWebhookでEvent API受け取る場合はHerokuでも動きます。\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)\n\n## Docker\n\ndockerコンテナを作るようにしたので、`ghcr.io/walkure/aggrechans:latest`などで取ってくることが出来ます。[Package](https://github.com/walkure/aggrechans/pkgs/container/aggrechans)を参照してください。\n\n### Dockerでの起動\n\nコンテナは`SLACK_APP_TOKEN`が定義されているとsocket modeで起動し、なければwebhook modeで起動します。`SLACK_BOT_TOKEN`はどちらの場合も必要です。\n\n`docker run -e SLACK_BOT_TOKEN=(BOT TOKEN) -e REDIS_HOST=localhost:6379 -e AGGREGATE_CHANNEL_ID=(CHANNEL_ID) -e SLACK_APP_TOKEN=(APP TOKEN) ghcr.io/walkure/aggrechans:latest`\n\nwebhook modeの場合は`REDIS_HOST`や`SLACK_SIGNING_SECRET`(App CredentialsのSigning Secretにある値)も必要です。\nsocket modeの場合は`REDIS_HOST`の存在は任意で、`SLACK_SIGNING_SECRET`は不要です。\n\n## Author\n\nwalkure at 3pf.jp\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkure%2Faggrechans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkure%2Faggrechans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkure%2Faggrechans/lists"}