bots: Add empty message support in Wikipedia bot.

This commit is contained in:
Krzysztof Krzysztof 2017-05-24 12:23:50 -07:00 committed by Tim Abbott
parent c6d294385f
commit 12e81fd024

View file

@ -31,7 +31,10 @@ class WikipediaHandler(object):
client.send_reply(message, bot_response) client.send_reply(message, bot_response)
def get_bot_wiki_response(self, message, client): def get_bot_wiki_response(self, message, client):
help_text = 'Please enter your message after @mention-bot'
query = message['content'] query = message['content']
if query == '':
return help_text
query_wiki_link = ('https://en.wikipedia.org/w/api.php?action=query&' query_wiki_link = ('https://en.wikipedia.org/w/api.php?action=query&'
'list=search&srsearch=%s&format=json' % (query,)) 'list=search&srsearch=%s&format=json' % (query,))
try: try: