def db_router(recv_msg, *args): if recv_msg.msg_type == 'text': for pattern in PatternT2T.objects.all(): match = re.search( pattern.content.encode('utf-8'), recv_msg.content) if match: return text_response(recv_msg, pattern.handler.content) for pattern in PatternT2PT.objects.all(): match = re.search( pattern.content.encode('utf-8'), recv_msg.content) if match: return pic_text_response(recv_msg, new_msg_from_db(pattern)) if recv_msg.msg_type == 'event': for pattern in PatternE2T.objects.all(): if pattern.event == recv_msg.event: if recv_msg.event_key: match = re.search( pattern.event_key.encode('utf-8'), recv_msg.event_key) if match: return text_response(recv_msg, pattern.handler.content) else: return text_response(recv_msg, pattern.handler.content) for pattern in PatternE2PT.objects.all(): if pattern.event == recv_msg.event: if recv_msg.event_key: match = re.search( pattern.event_key.encode('utf-8'), recv_msg.event_key) if match: return pic_text_response(recv_msg, new_msg_from_db(pattern)) else: return pic_text_response(recv_msg, new_msg_from_db(pattern))
def robot_handler(recv_msg, *args, **kwargs): recv_content = recv_msg.content reply = robot.get_reply(recv_content,recv_msg.from_user_name) if len(reply) > 0: return text_response(recv_msg, reply.encode('utf-8')) else: return text_response(recv_msg, """ 您的留言我们已经收到:) """)
def robot_handler(recv_msg, *args, **kwargs): recv_content = recv_msg.content reply = robot.get_reply(recv_content, recv_msg.from_user_name) if len(reply) > 0: return text_response(recv_msg, reply.encode('utf-8')) else: return text_response(recv_msg, """ 您的留言我们已经收到:) """)
def subscrib_handler(recv_msg, *args, **kwargs): content = """ --键入小写命令-- view 查看活动 input 发起活动 help 帮助信息 about 关于我们 使用相应功能^_^ """ return text_response(recv_msg, content)
def db_router(recv_msg, *args): if recv_msg.msg_type == 'text': for pattern in PatternT2T.objects.all(): match = re.search(pattern.content.encode('utf-8'), recv_msg.content) if match: return text_response(recv_msg, pattern.handler.content) for pattern in PatternT2PT.objects.all(): match = re.search(pattern.content.encode('utf-8'), recv_msg.content) if match: return pic_text_response(recv_msg, new_msg_from_db(pattern)) if recv_msg.msg_type == 'event': for pattern in PatternE2T.objects.all(): if pattern.event == recv_msg.event: if recv_msg.event_key: match = re.search(pattern.event_key.encode('utf-8'), recv_msg.event_key) if match: return text_response(recv_msg, pattern.handler.content) else: return text_response(recv_msg, pattern.handler.content) for pattern in PatternE2PT.objects.all(): if pattern.event == recv_msg.event: if recv_msg.event_key: match = re.search(pattern.event_key.encode('utf-8'), recv_msg.event_key) if match: return pic_text_response(recv_msg, new_msg_from_db(pattern)) else: return pic_text_response(recv_msg, new_msg_from_db(pattern))
def about_handler(recv_msg, *args, **kwargs): content = """ 关于我们 """ return text_response(recv_msg, content)