Skip to content

Commit 85f2a9e

Browse files
committed
bots: Add basic metadata with failover, used on running only.
1 parent 5681b6e commit 85f2a9e

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

zulip_bots/zulip_bots/bots/wikipedia/wikipedia.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class WikipediaHandler(object):
1818
kind of external issue tracker as well.
1919
'''
2020

21+
META = {
22+
'name': 'Wikipedia',
23+
'description': 'Searches Wikipedia for a term and returns the top article.',
24+
}
25+
2126
def usage(self):
2227
return '''
2328
This plugin will allow users to directly search

zulip_bots/zulip_bots/bots/xkcd/xkcd.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class XkcdHandler(object):
1414
commands.
1515
'''
1616

17+
META = {
18+
'name': 'XKCD',
19+
'description': 'Fetches comic strips from https://xkcd.com.',
20+
}
21+
1722
def usage(self):
1823
return '''
1924
This plugin allows users to fetch a comic strip provided by

zulip_bots/zulip_bots/lib.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,17 @@ def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name):
187187

188188
state_handler = StateHandler()
189189

190+
# Set default bot_details, then override from class, if provided
191+
bot_details = {
192+
'name': bot_name.capitalize(),
193+
'description': "",
194+
}
195+
bot_details.update(getattr(lib_module.handler_class, 'META', {}))
196+
190197
if not quiet:
198+
print("Running {} Bot:".format(bot_details['name']))
199+
if bot_details['description'] != "":
200+
print("\n\t{}".format(bot_details['description']))
191201
print(message_handler.usage())
192202

193203
def handle_message(message):

0 commit comments

Comments
 (0)