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

@ -31,8 +31,8 @@ class ConverterHandler(object):
This plugin allows users to make conversions between various units,
e.g. Celsius to Fahrenheit, or kilobytes to gigabytes.
It looks for messages of the format
'@convert <number> <unit_from> <unit_to>'
The message '@convert help' posts a short description of how to use
'@mention-bot <number> <unit_from> <unit_to>'
The message '@mention-bot help' posts a short description of how to use
the plugin, along with a list of all supported units.
'''
@ -41,20 +41,18 @@ class ConverterHandler(object):
This plugin allows users to make conversions between
various units, e.g. Celsius to Fahrenheit,
or kilobytes to gigabytes. It looks for messages of
the format '@convert <number> <unit_from> <unit_to>'
The message '@convert help' posts a short description of
the format '@mention-bot <number> <unit_from> <unit_to>'
The message '@mention-bot help' posts a short description of
how to use the plugin, along with a list of
all supported units.
'''
def triage_message(self, message, client):
return '@convert' in message['content']
def handle_message(self, message, client, state_handler):
content = message['content']
words = content.lower().split()
convert_indexes = [i for i, word in enumerate(words) if word == "@convert"]
convert_indexes = [-1] + convert_indexes
results = []
for convert_index in convert_indexes: