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

Switch to slack_sdk and add support to ignore users and send files #428

Merged
merged 8 commits into from
Mar 19, 2021

Conversation

BrianGallew
Copy link
Contributor

@BrianGallew BrianGallew commented Mar 11, 2021

This is huge, I know. Sorry.

Summary:

  • pep8 compliance of changed files
  • housekeeping (adding doc-strings and remove unused imports)
  • Rewrite slack backend to use slack_sdk
  • Drop support from python 2.7, moving support up to 3.6+
  • Ability to ignore users

@BrianGallew
Copy link
Contributor Author

Addresses #426

@BrianGallew
Copy link
Contributor Author

Forgot I was supposed to tag @Ashex with this.

@BrianGallew
Copy link
Contributor Author

I suppose I should point out: this code is what we've been running in production for some time now (most of it for more than 3 months). The ability to ignore users is newer, though: only 3 weeks or so. We had a couple of bots get into a loop, and this was an easy fix.

Copy link
Collaborator

@Ashex Ashex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MANY welcome changes here. We just need to get a little clarity on some changes and remove a couple to keep this PR scope "narrow".

will/__init__.py Outdated Show resolved Hide resolved
will/backends/encryption/aes.py Show resolved Hide resolved
will/backends/io_adapters/base.py Outdated Show resolved Hide resolved
will/plugin.py Show resolved Hide resolved
will/plugin.py Show resolved Hide resolved
will/plugins/help/programmer_help.py Show resolved Hide resolved
will/requirements/slack.txt Show resolved Hide resolved
@BrianGallew
Copy link
Contributor Author

I've pushed an update that should address all of the raised concerns.

will/plugin.py Show resolved Hide resolved
@Ashex
Copy link
Collaborator

Ashex commented Mar 12, 2021

Another note for reference, the introduction of f-strings will force us to only support python 3.6+ therefore satisfying #417

@Ashex Ashex changed the title Switch to slack_sdk, various extensions Switch to slack_sdk and add support to ignore users Mar 12, 2021
Copy link
Collaborator

@Ashex Ashex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the slack backend specifically (that I missed on my first run through as github didn't render the diff). This is a monumental rewrite and it looks great. I don't want to rush getting this merged in so I'll leave the rest of the contributors to review and provide feedback through the weekend.

I'll spin up a test instance with this branch on monday and run will through some basic tests to validate.

will/backends/io_adapters/slack.py Show resolved Hide resolved
will/backends/io_adapters/slack.py Outdated Show resolved Hide resolved
will/backends/io_adapters/slack.py Show resolved Hide resolved
@BrianGallew
Copy link
Contributor Author

BrianGallew commented Mar 13, 2021 via email

@skoczen
Copy link
Owner

skoczen commented Mar 13, 2021

My two cents:

There's precedent to backends having exclusive features, if they're not something that can be abstracted generally, or they're not common, etc.

Merging with files and then building up an abstraction from there would seem sane to me.

That said, keeping things moving does seem to be the highest priority.

@BrianGallew Thanks for sending this. As you know, it's a community effort: folks here (including me) are fitting this in between their jobs, their families, relationships, doctor's appointments, etc. It takes time to build consensus, and asynchronous, community-based PRs take extra time. Your patience is appreciated, and it makes things much easier. Also, it's hard to tell tone on the internet. Please give a little extra kindness and patience to the process, like I'm sure you'd appreciate if you were on the other side!

@Ashex @pastorhudson @rsalmond - do we need any changes to contributor/owner status for the repo or pypi to get this out? I've got for sure solid internet for the next couple of days, and really happy to get it done.

@pastorhudson
Copy link
Contributor

I'm happy to do whatever you guys need

@BrianGallew
Copy link
Contributor Author

I'm not angry. Like the rest of you, I'm busy with my own life. I'm quite happy to contribute to will. I'm simply uninterested in breaking things out into multiple commits/PRs. If the send_file code I submitted was unacceptable for any reason, then there's no reason for me to re-submit it. As Ashex has pointed out, there's an existing PR covering that, and potentially other implementations out there to choose from.

@BrianGallew BrianGallew requested a review from Ashex March 13, 2021 23:47
@Ashex
Copy link
Collaborator

Ashex commented Mar 14, 2021

@BrianGallew Based off everyones feedback can you add the send_file implementation back? I truly appreciate the work you've done and am grateful for this pull request, my aim was to not disrupt the work others have done but at the end of the day those are custom changes and the PR I referenced has been sitting for some time (and doesn't support DM). I already looked at the code for it when it was present so I'll approve it after I've tested everything and we'll get it merged.

@skoczen I'll need pypi access so I can cut a 2.2.0 release with this PR and everything missing since 2.1.3 was released.

@BrianGallew
Copy link
Contributor Author

send_file is back in and I think I kept all of the other requested changes.

@Ashex
Copy link
Collaborator

Ashex commented Mar 15, 2021

@BrianGallew
Copy link
Contributor Author

Sorry, my weak git-fu is now revealed. I had actually reverted all my changes, including the ones I had wanted to retain. They're in there now, and according to grep send_file is now declared in both slack.py and plugin.py.

@pastorhudson
Copy link
Contributor

Sorry, my weak git-fu is now revealed. I had actually reverted all my changes, including the ones I had wanted to retain. They're in there now, and according to grep send_file is now declared in both slack.py and plugin.py.

No worries. It happens to us all!

@Ashex
Copy link
Collaborator

Ashex commented Mar 15, 2021

No worries at all! I'll commence testing tomorrow :) I'll write a plugin for executing a variety of actions and share the gist with the approval.

@skoczen
Copy link
Owner

skoczen commented Mar 16, 2021

@Ashex Yep, you got it on Pypi - what's your pypi username?

@Ashex
Copy link
Collaborator

Ashex commented Mar 16, 2021

@skoczen My pypi username is Ashex

@skoczen
Copy link
Owner

skoczen commented Mar 16, 2021

@Ashex you've been added to Pypi, and should be able to release as soon as you accept the invite!

Copy link
Collaborator

@Ashex Ashex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this through some tests, the only thing that needs to be fixed is adding this back to will/plugin.py as otherwise send_file fails.

FILENAME_CLEANER = re.compile(r'[^-_0-9a-zA-Z]+')

And putting aiohttp back into requirements as it turns out it is needed since we're using the async api. The line should be aiohttp>=3.7.3,<4 in order to pin the version.

Here's the plugin I wrote to do some quick tests, I wanted to ask if send_file supports DM as I was not able to get that to function.

https://gist.github.com/Ashex/cb66194c429fb8d4d2f19a15fcc75b64

There's a couple minor things I spotted but I'll correct that myself through another PR.

@Ashex Ashex added this to the 2.x milestone Mar 17, 2021
@Ashex Ashex linked an issue Mar 17, 2021 that may be closed by this pull request
@Ashex Ashex self-assigned this Mar 17, 2021
@BrianGallew BrianGallew requested a review from Ashex March 17, 2021 15:56
@BrianGallew
Copy link
Contributor Author

FILENAME_CLEANER re-added. And, no, I don't believe it supports DMs correctly: there is a nuance which I've not investigated sufficiently to make it work correctly in that case.

@Ashex
Copy link
Collaborator

Ashex commented Mar 17, 2021

Great, can you also add aiohttp back to the requirements file? I'll get this merged in once that's done.

@Ashex
Copy link
Collaborator

Ashex commented Mar 17, 2021

Regarding DM support, it does work when interacting with the bot directly. There's just some extra magic required when you want to send a user an unsolicited DM with a file, I did sort it out elsewhere so expect a PR in the near future with the enhancement.

@Ashex Ashex modified the milestones: 2.x, 2.2 Mar 17, 2021
@Ashex Ashex linked an issue Mar 18, 2021 that may be closed by this pull request
This reverts commit 299d348.
@BrianGallew
Copy link
Contributor Author

BrianGallew commented Mar 19, 2021

aiohttp change reverted

Copy link
Collaborator

@Ashex Ashex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again for your patience and all the work you put in to rewrite this, I can definitely say you've brought life back to the project.

I'll now approve and get this merged. We have some work left to do before we cut a new release with this but it will be coming soon.

@Ashex Ashex changed the title Switch to slack_sdk and add support to ignore users Switch to slack_sdk and add support to ignore users and send files Mar 19, 2021
@Ashex Ashex merged commit eb57878 into skoczen:master Mar 19, 2021
@pastorhudson
Copy link
Contributor

I totally agree with @Ashex thank you for the work you put into this @BrianGallew! I really appreciate it. I’m excited to see this project moving again! 🥳

@BrianGallew
Copy link
Contributor Author

:victory:

Ashex pushed a commit that referenced this pull request Feb 5, 2022
)

* Switch to slack_sdk, various extensions
* Use Slack Events API
* Added file upload support
* Ignore users via config setting
* Bump version for upcoming release
* pep8 compliance
* Drop support for python 2.7
* Whole lot of housekeeping

Co-authored-by: Brian Gallew <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slack APIs consumed by will are slated to be shut off in Feburary 2021 Slack Events API
5 participants