Example #1
0
def weixin_msg():
    logging.error("1.weixin: in weixin_msg ")
    if weixin.verification(request):
        logging.error("2.weixin verify done")
        data = request.data
        msg = weixin.parse_msg(data)
        if weixin.user_subscribe_event(msg):
            return weixin.help_info(msg)
        elif weixin.is_text_msg(msg):
            content = msg['Content']
            if content == u'?' or content == u'?':
                return weixin.help_info(msg)
            elif (content == u'm' or content == u'M' 
                 or content == u'money' or content == u'MONEY'
                 or content == u'Money'):
                return weixin.currency_info_AUDCNY_Pic(msg)
            elif (content == u'p' or content == u'P' 
                 or content == u'petrol' or content == u'PETROL'
                 or content == u'Petrol'):
                return weixin.petrol(msg)
            else:
                return weixin.help_info(msg)
        elif weixin.is_location_msg(msg):
            Label = msg['Label'] 
            return weixin.help_info(msg)
    return 'message processing fail'
Example #2
0
def weixin_msg():
    logging.error("1.weixin: in weixin_msg ")
    if weixin.verification(request):
        logging.error("2.weixin verify done")
        data = request.data
        msg = weixin.parse_msg(data)
        if weixin.user_subscribe_event(msg):
            return weixin.help_info(msg)
        elif weixin.is_text_msg(msg):
            content = msg['Content']
            if content == u'?' or content == u'?':
                return weixin.help_info(msg)
            elif (content == u'n' or content == u'N' 
                 or content == u'new' or content == u'NEW'
                 or content == u'New'):
                posts = operatorDB.get_weixin_articles()
                rmsg = weixin.response_news_msg(msg, posts)
                logging.error("3.weixin get rmsg: %s"%rmsg)
                return rmsg
            else:
                return weixin.help_info(msg)
        elif weixin.is_location_msg(msg):
            Label = msg['Label'] 
            return weixin.help_info(msg)
    return 'message processing fail'