def on_message(self, msg): if hasattr(msg, 'text'): m = sendMessage() m.chat_id = msg.chat.id if msg.text == 'Hello': m.text = 'Hello my name is %s' % os.environ['BOT_NAME'] else: m.text = 'You said: "%s"' % msg.text elif hasattr(msg, 'photo'): m = sendPhoto() m.chat_id = msg.chat.id m.caption = "What a pong!" m.photo = msg.photo[0].file_id else: return False rsp = yield from self.send_method(m) return True
def on_message(self, msg): if hasattr(msg, 'text'): m = sendMessage() m.chat_id = msg.chat.id if msg.text == 'Hello': m.text = 'Hello my name is %s' % os.environ['BOT_NAME'] else: m.text = 'You said: "%s"' % msg.text elif hasattr(msg, 'photo'): m = sendPhoto() m.chat_id = msg.chat.id m.caption = "What a pong!" m.photo = msg.photo[0].file_id else: defer.returnValue(True) log.msg("REPLY: %s" % m) rsp = yield self.send_method(m) log.msg("RSP: %s" % rsp) defer.returnValue(True)
def on_message(self, msg): if msg.text: m = sendMessage() m.chat_id = msg.chat.id if msg.text == 'Hello': m.text = 'Hello my name is %s' % os.environ['BOT_NAME'] else: m.text = '"%s"?' % msg.text elif msg.photo: m = sendPhoto() m.chat_id = msg.chat.id m.caption = "What a pong?" m.photo = msg.photo[0].file_id else: return log.msg("REPLY: %s" % m) rsp = yield self.send_message(m) log.msg("RSP: %s" % rsp) defer.returnValue(True)