def send_status(self, event, message, name): if (len(message) == 0): line_bot_api.reply_message(event.reply_token, [ TextSendMessage( text=MessageFactory.no_reservation_message(name)) ]) else: title_message = MessageFactory.reservation_found_title_message( name) line_bot_api.reply_message(event.reply_token, [ TextSendMessage(text=title_message), TextSendMessage(text=message.strip()) ])
def handle(self, event): try: self.parse_command(event) except Exception as error: self.reply(event, MessageFactory.error_message()) print(str(error)) traceback.print_exc()
def handle(self, event): user_id = event.source.user_id profile = line_bot_api.get_profile(user_id) first_name = profile.display_name.split(' ')[0] message_body = MessageFactory.follow_message(first_name) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=message_body))
def run(self, event): commands = event.message.text.strip().split(' ') if (len(commands) < 2): self.simple_reply(event, MessageFactory.status_command_invalid_message()) return else: message = self.construct_status_message_body(commands[1]) self.send_status(event, message, commands[1])
def parse_command(self, event): if (event.message.type != "text"): return text = event.message.text.strip().lower() if (text.startswith("!today")): self.feature_today.run(event) elif (text.startswith("!help")): self.feature_help.run(event) elif (text.startswith("!status")): self.feature_status.run(event) elif (text.startswith("!")): self.reply(event, MessageFactory.command_not_found_message())
def run(self, event): commands = event.message.text.strip().split(' ') if (len(commands) == 1): self.send_room_list(event) return else: if not(self.is_room_exists(commands[1])): self.simple_reply(event, MessageFactory.room_not_found_message(commands[1])) return room_schedules = self.get_room_schedule(event, commands[1]) message = self.construct_message_body(room_schedules) self.send_room_schedules(event, message, commands[1])
def parse_status_response(self, response): dom = pq(response) statuses = dom(".responsive-table tbody tr") message = "" for status in statuses: tr = pq(status) activity_issuer = tr.children("td")[1].text activity_name = tr.children("td")[2].text activity_status = tr.children("td")[4].text message += MessageFactory.status_message_body( activity_issuer, activity_name, activity_status) return message
def construct_reply_message(self): message = MessageFactory.help_message() return TextSendMessage(text=message)
def handle(self, event): message = MessageFactory.join_message() line_bot_api.reply_message(event.reply_token, TextSendMessage(text=message))