chatbot.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:six_hack 作者: petr-tik 项目源码 文件源码
def on_chat_message(self, msg):
        # if chat_id not in self._seen:
        #     return
        print(msg)
        parser = Parser(msg['text'])
        parsed = parser.parse_text()

        # have another id to transfer and send a message.
        if self.current_thread:
            print("current thread, {}".format(self.current_thread))
        elif parsed['action'] != 'transfer':
            print('action isnt transfer')
            return
        elif parsed['action'] == 'transfer':
            print('action is transfer')
            self.current_thread = True
        if not self.recipient:
            print('no recipient')
            self.recipient = parsed['recepient']['user_alias']
            self.amount = int(parsed['amount'])
        try:
            self.alias_id = self._db.fetch_alias(self.recipient)
        except KeyError:
            self.sender.sendMessage('Oh oh, looks like your friend hasn\'t registered yet. Send him a message and let him know that he should register right away.')
            return

        print(self.current_thread)
        print(self.asked_password)

        if self.asked_confirmation:
            print('going to send money')
            self.trigger_confirmation(msg)
        elif self.asked_password:
            print('going to ask confirmation')
            self.trigger_confirmation(msg)
        elif self.recipient and self.alias_id:
            print('going to ask password')
            self.trigger_password_question(msg, parsed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号