This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Proposal - add threading & reactions to Slack #123
Closed
+81
−4
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.
This isn't finished; think of it more as a proposal, which we'll be happy to clean up if you like the idea.
Our goal is to let our bot use some advanced Slack features, namely:
We wanted to do all three of these things without modifying the Lita core. To accomplish that, we added a
SlackSource
which subclassesLita::Source
and adds Slack extensions; when the Slack adapter processes messages, it instantiatesSlackSource
so that when its own methods are called back, it can rely on the extra state tucked away inside the source. (Naturally, it gracefully degrades if you pass a vanillaSource
into the adapter.)The adapter itself has gotten some new, Slack-specific methods to
react_with_emoji
,reply_in_thread
, and so forth. However, all of these are obscured from the bot's handlers. Instead, we have introduced two new conventions inside the adapter'ssend_messages
, since this is the "nexus" of message sending which allows our conventions to apply to all of the ways that Lita has to send messages.The two conventions are:
Symbol
instead ofString
message, causes an emoji reaction to the source.…
is sent in a thread of the original message (i.e. it begins a new thread even if the original message was top-level)In addition, because SlackSource tracks threadiness, any reply to a threaded SlackSource will be made in the same thread.
We're interested in your feedback on the way we have implemented these things, and happy to clean up our implementation and add tests once we've heard your thoughts. My own observations:
It seems a bit weird to incorporate notions of "thread" and "reaction" into Lita's core, so the use of message-formatting conventions is probably a good idea, to keep the core adapter-agnostic. Both of these conventions work sensibly when used with adapters that don't support them.
It seems dirty that we need to use a special
SlackSource
to track extensions. If theSource
class kept track of extensions, or pointed to the originalMessage
, we could get rid of the subclass.