Remove triage_message() function from all the contrib-bots.

To make all bots consistent add shared function in bot_lib.py
to check if this bot is called. All bots respond to at-mention of
the bot instead of their specific names.
This commit is contained in:
Abhijeet Kaur 2017-02-17 03:26:32 +05:30 committed by showell
parent a87ae4b1c4
commit 9a8dc7c622
18 changed files with 134 additions and 281 deletions

View file

@ -18,28 +18,19 @@ def encrypt(text):
class EncryptHandler(object):
'''
This bot allows users to quickly encrypt messages using ROT13 encryption.
It encrypts/decrypts messages starting with @encrypt.
It encrypts/decrypts messages starting with @mention-bot.
'''
def usage(self):
return '''
This bot uses ROT13 encryption for its purposes.
It responds to me starting with @encrypt.
It responds to me starting with @mention-bot.
Feeding encrypted messages into the bot decrypts them.
'''
def triage_message(self, message, client):
original_content = message['content']
# This makes sure that the bot only replies to messages it supposed to reply to.
should_be_encrypted = original_content.startswith('@encrypt')
return should_be_encrypted
def handle_message(self, message, client, state_handler):
original_content = message['content']
temp_content = encrypt(original_content.replace('@encrypt', ''))
temp_content = encrypt(original_content)
send_content = "Encrypted/Decrypted text: " + temp_content
client.send_message(dict(