Created
July 27, 2017 14:42
-
-
Save toracle/96742a931af8f86ca73ff10ae9cf9fd7 to your computer and use it in GitHub Desktop.
moviefriend-code-3
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.messages import Message | |
| from .movies import BoxOffice | |
| class Bot(BaseBot): | |
| def handle_message(self, event, context): | |
| message = event.get('content') | |
| if message == '영화순위': | |
| self.send_box_office(event) | |
| def send_box_office(self, event): | |
| data = self.get_project_data() | |
| api_key = data.get('box_office_api_key') | |
| box_office = BoxOffice(api_key) | |
| movies = box_office.simplify(box_office.get_movies()) | |
| rank_message = ', '.join(['{}. {}'.format(m['rank'], m['name']) for m in movies]) | |
| response = '요즘 볼만한 영화들의 순위입니다\n{}'.format(rank_message) | |
| message = Message(event).set_text(response)\ | |
| .add_quick_reply('영화순위')\ | |
| .add_quick_reply('근처 상영관 찾기') | |
| self.send_message(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment