Created
August 7, 2017 08:00
-
-
Save toracle/1bee9d5fa9087836c6ee384b5813ef55 to your computer and use it in GitHub Desktop.
bothub-tutorial-wordbook-4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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