Skip to content

Replicate Reacji Channeler functionality #47

@itsthejoker

Description

@itsthejoker

As an exercise, this issue is to take the functionality of Reacji Channeler and port that to Bubbles.

Overview

This will require the following components:

  • one command to add, delete, or list emoji / channel associations
  • the actual listener to perform the copying when a known emoji is applied

Example commands:

I'm calling it channeler here but that's up for debate.

  • @bubbles channeler :thonking: #general
  • @bubbles channeler delete :thonking:
  • @bubbles channeler list

Notes

The list of associations will have to survive reboots and deploys without being lost, so the best way to do that is some form of local file. A database (even sqlite) is overkill, so a JSON file will do.

Warning: paths change their behavior after Bubbles is compiled into an archive. Import ARCHIVE_PATH from bubbles.config and check its value; if it's None, you're running in development mode and paths will work as expected. If it's anything else, use that path as the base for where to put and read your file.

Example schema:

{
  "thonking": "general",
  "send_to_devs": "dev_general",
}

The actual receipt of the reaction emoji is already handled for you and provided in Payload form. Put your logic in its own function in https://github.com/GrafeasGroup/Bubbles/blob/master/bubbles/reaction_added.py; call it from reaction_added_callback and just pass the payload along.

Of course, this project wouldn't be a Slack-based project unless there was some Slack-related BS to deal with. When the payload comes in, it doesn't actually give you any useful information about the message that was reacted to, which is pretty important for this functionality. To combat this, I've added a new function -- payload.get_reaction_message(), which reaches out to Slack and asks nicely for this data. You can see the format of the returned payload here:

Example response here:
{
'type': 'message',
'channel': 'HIJKLM',
'message': {
'client_msg_id': '3456c594-3024-404d-9e08-3eb4fe0924c0',
'type': 'message',
'text': 'Sounds great, thanksss',
'user': 'XYZABC',
'ts': '1661965345.288219',
'team': 'GFEDCBA',
'blocks': [...],
'reactions': [
{
'name': 'upvote',
'users': ['ABCDEFG'], 'count': 1
}
],
'permalink': 'https://...'
}
}

I think all you need to do is grab the permalink attribute out of the returned data and send that with unfurl_links=True to the given channel, but we'll see how far we can go before deploying to test.

If you run into any issues, reach out to Joe or Tim on #dev_general. Don't struggle with any single problem for more than 30 minutes to an hour before asking for help! (Reminder that interactive mode exists for local testing -- trigger it with python blossom/main.py --interactive.)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions