-
Notifications
You must be signed in to change notification settings - Fork 710
Add Events API in socket mode for Slack adapter#2161
Add Events API in socket mode for Slack adapter#2161kolsys wants to merge 1 commit into42wim:masterfrom
Conversation
This is beta version for modern Slack applications.
Changes implement Slack Events API in socket mode, see #964.
Fixes #2159
It also fixes files upload to Slack for modern Apps.
To activate Ecvents API in SocketMode you must:
- Create new modern App with following OAuth Bot scope (or upgrade Legacy)
channels:history
channels:read
chat:write
files:read
files:write
groups:history
groups:read
im:history
im:read
mpim:history
mpim:read
users.profile:read
users:read
- Acivate Socket mode
- Subscribe to the following events:
channel_history_changed
group_history_changed
im_history_changed
message.channels
message.groups
message.im
message.mpim
- Add AppToken to the toml:
[slack]
[slack.mybot]
Token="xoxb-*******"
AppToken="xapp-**********"
| } | ||
| } | ||
|
|
||
| func (b *Bslack) handleSlackClientSocketMode(messages chan *config.Message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method Bslack.handleSlackClientSocketMode has 107 lines of code (exceeds 50 allowed). Consider refactoring.
| } | ||
| } | ||
|
|
||
| func (b *Bslack) handleSlackClientSocketMode(messages chan *config.Message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method Bslack.handleSlackClientSocketMode has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR diff size of 236869 lines exceeds the maximum allowed for the inline comments feature.
- Fix files upload for new applications
|
Code Climate has analyzed commit 5b86262 and detected 4 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
FROM golang:1.22.0-alpine3.19 AS builder@kolsys Could you please update the Dockerfile? The current version in the master branch doesn't work correctly. |
Whats wrong with the master version? I've build and run it. |
|
Hi. We experiencing errors downloading images. Look like the file URL is empty. config [api.api]Also tried without MediaDownloadPath/MediaServerDownload options - result is the same. logs time="2024-07-12T11:23:12Z" level=debug msg="Message event: {"client_msg_id":"3c60172b-85be-20cb-bed3-1b041bdd51af","typ e":"message","user":"U05******","text":"test40","thread_ts": "1720779786.805609","ts":"1720783391.651979","channel":"C061 W7QFYPM","channel_type":"channel","event_ts":"1720783391.651 979","subtype":"file_share","upload":false,"files":[{"id":"F 07BZLYLJ6A","created":0,"timestamp":0,"name":"","title":""," mimetype":"","filetype":"png","pretty_type":"","user":"","ed itable":false,"size":0,"mode":"","is_external":false,"extern al_type":"","is_public":false,"public_url_shared":false,"dis play_as_bot":false,"username":"","url_private":"","url_priva te_download":"","thumb_64":"","thumb_80":"","thumb_360":""," thumb_360_w":0,"thumb_360_h":0,"thumb_480":"","thumb_480_w": 0,"thumb_480_h":0,"thumb_160":"","thumb_720":"","thumb_720_w ":0,"thumb_720_h":0,"thumb_800":"","thumb_800_w":0,"thumb_80 0_h":0,"thumb_960":"","thumb_960_w":0,"thumb_960_h":0,"thumb _1024":"","thumb_1024_w":0,"thumb_1024_h":0,"image_exif_rota tion":0,"original_w":0,"original_h":0,"permalink":"","permal ink_public":""}],"blocks":[{"type":"rich_text","block_id":"o 6CuE","elements":[{"type":"rich_text_section","elements":[{" type":"text","text":"test40"}]}]}],"root":null}" func=handleSlackClientSocketMode file="bridge/slack/handlers.go:99" prefix=slackwe are running bridge in k8s (without nat) but webockets seems to be work, pings look fine slack-go/slack/socketmode2024/07/12 12:56:36 socket_mode_managed_conn.go:627: WebSocket ping message received: Ping from applink-13 |
|
@xeonic-ant |
|
Just confirming, is there any ability within this using the new slack app to post in a channel within slack using a nickname that isn't the same name as the bot (so as to preserve / bridge the nickname and avatar?) |
|
Any further progress on this one? |
I will no support this patch because we've stopped to using Slack. But this version is work. You are welcome to modify this patch to extend support support of socket mode. |
|
Worked for me |
|
but can we get it merged? |
|
how do i build upon your fork? i want to use it for slack <-> irc bridging. ~ go install github.com/tippl/matterbridge@master |
|
hi! edit: build instructions were as easy as: git clone https://github.com/kolsys/matterbridge(thanks to a friend who pointed that out) |
|
Hi! Any updates on merging this PR? Seems to have stalled. |
you just need to add the |