Skip to content

Instantly share code, notes, and snippets.

@toracle
Created August 7, 2017 08:00
Show Gist options
  • Save toracle/1bee9d5fa9087836c6ee384b5813ef55 to your computer and use it in GitHub Desktop.
Save toracle/1bee9d5fa9087836c6ee384b5813ef55 to your computer and use it in GitHub Desktop.
bothub-tutorial-wordbook-4
from bothub_client.bot import BaseBot
from bothub_client.messages import Message
class Bot(BaseBot):
def handle_message(self, event, context):
content = event['content']
if content.startswith('/'):
if content == '/start':
self.send_start_message(event)
elif content.startswith('/list'):
self.send_word_list(event)
return
self.count_word(content)
self.search_word(event)
def send_start_message(self, event):
message = Message(event).set_text("Hi! I'm a wordbook bot.\n"\
'Enter a word, you gets dictionary URL.\n'\
'You can check search history afterword.')\
.add_postback_button('Word list', '/list')
self.send_message(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment