当前位置: 首页>>代码示例>>Python>>正文


Python Engine.process_message_dev方法代码示例

本文整理汇总了Python中engine.Engine.process_message_dev方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.process_message_dev方法的具体用法?Python Engine.process_message_dev怎么用?Python Engine.process_message_dev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在engine.Engine的用法示例。


在下文中一共展示了Engine.process_message_dev方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_message

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import process_message_dev [as 别名]
    def on_message(self, sender=None, message=None):
        logging.info("Recieved message from %s: %s", sender, message)
        if sender is None or message is None or message == "":
            raise Error("Invalid sender or message.")
        # Admin start command requires 10 digit phone NOT prefixed with "+1"
        if message.split(' ')[0].lower() == "start":
            sender = "+1" + message.split(' ')[1]
            logging.info("AdminStart for #: %s", sender)
            message = "AdminStart"
        student = Student.ensure_student(phone=sender)
        try:
            student.totalMsgReceived
        except:
            student.totalMsgReceived = 1
        else:
            student.totalMsgReceived += 1
        student.put()
        session = Session.ensure_session(student.get_id())
        lesson = self.lessons.get(session.lesson_id)
        if lesson is None:
            raise Error("No such lesson: %s" % session.lesson_id)

        json_data = open('hiragana.json')
        data = json.load(json_data)
        json_data.close()
        eng = Engine(data)
        messages = eng.process_message_dev(message, student)
        #logging.info("Student's foo: %s" % student.questionHistory['foo'])

        if session.state == -1:
            session.key.delete()
        else:
            session.put()
        self.send_SMS_replies(sender, messages)
开发者ID:cwkoss,项目名称:TextTeach,代码行数:36,代码来源:controller.py


注:本文中的engine.Engine.process_message_dev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。