Exemple #1
0
def weixin_daily_analyse():
    for wx in WXAccount.objects.filter(state=WXAccount.STATE_BOUND):
        try:
            data = WeixinDailyData.objects.get(weixin=wx, date=datetime.date.today())
            logger.debug("already have one")
        except:
            data = WeixinDailyData()
            data.weixin = wx
            data.date = datetime.date.today()
            data.save()
Exemple #2
0
def micro_site(rule, info):
    try:
        wx_account = WXAccount.objects.get(id=info.wx)
        WeixinDailyData.today_subscribe_one(info.wx)
        homepage = HomePage.objects.get(wx=wx_account)
        data = {}
        data['title'] = homepage.name
        if homepage.message_description:
            data['description'] = homepage.message_description
        else:
            data['description'] = consts.DEFAULT_HOMEPAGE_MSG % wx_account.name
        if homepage.message_cover:
            data['pic_url'] = homepage.message_cover.url
        else:
            data['pic_url'] = settings.SITE_URL + settings.STATIC_URL + consts.DEFAULT_HOMEPAGE_COVER
        data['url'] = get_page_url(homepage) + "?user=%s&wx=%s" % (info.user, info.wx)
        return BuildConfig(MessageBuilder.TYPE_WEB_APP, None, data)
    except:
        logger.error(traceback.format_exc())
        return BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, u'非常抱歉')
Exemple #3
0
def unsubscribe(rule, info):
    WeixinDailyData.today_unsubscribe_one(info.wx)

    return BuildConfig(MessageBuilder.TYPE_NO_RESPONSE, None, u"%s unsubscribe" % info.user)