Created
March 17, 2021 10:49
-
-
Save Ashex/cb66194c429fb8d4d2f19a15fcc75b64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from will.plugin import WillPlugin | |
from will.decorators import respond_to, require_settings | |
class WillTestPlugin(WillPlugin): | |
def get_user_id(self, user_id): | |
people_cache = self.load('slack_people_cache', {}) | |
for k, c in people_cache.items(): | |
if user_id == c.handle: | |
return c.id | |
@respond_to(r"give me a file") | |
def test_send_file(self, message): | |
"""give me a file: Just send a file for testing.""" | |
r = requests.get('https://gist.githubusercontent.com/Ashex/703ef3311bcb4fa50d1268303f5b08ab/raw/87159c75045d723908488c0e9ce99774858f7fb2/guide.md') | |
self.send_file(message, content=r.text, filename='readme.md', text='Here is your file!', channel=self.get_user_id(message.sender.handle)) | |
@require_settings("AM_I_REAL") | |
@respond_to("are you (?P<existence>.*)") | |
def require_setting(self, message, existence): | |
"""are you: Give me an existential crisis.""" | |
if existence == 'real': | |
self.reply(message, content="I'm not sure this is a good idea", color='red') | |
elif existence == 'a bot': | |
self.reply(message, content="Why yes I am!", color='green') | |
else: | |
self.reply(message, content=f"I'm not sure, are you {existence}", color='yellow') | |
@respond_to("link pls") | |
def provide_link(self, message): | |
"""link pls: Return a link.""" | |
self.reply(message, content=r'<a href="http://www.drivecomic.com">here is a link</a>', html=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment