Skip to content
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

Replicate Reacji Channeler functionality #47

Open
itsthejoker opened this issue Sep 5, 2022 · 1 comment
Open

Replicate Reacji Channeler functionality #47

itsthejoker opened this issue Sep 5, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@itsthejoker
Copy link
Member

itsthejoker commented Sep 5, 2022

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.)

@itsthejoker itsthejoker added the enhancement New feature or request label Sep 5, 2022
@itsthejoker
Copy link
Member Author

The important stuff in message_utils and plugins has been moved here: https://github.com/GrafeasGroup/utonium/blob/main/utonium/__init__.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants