Example #1
0
def subEvent(msg):
    try:
        User.objects.get(openid=msg.source)
    except:
        User.objects.create(openid=msg.source, likenum=0, coins=0, sign="真懒,啥也没留下")
        tools.updateInfo(msg.source)
        menu = (
            '{"button":[{"type":"click","name":"好友排行","key":"V1000_FRIEND"},'
            + '{"type":"click","name":"产品简介","key":"V1000_HELP"},'
            + '{"name":"健康数据","sub_button":[{"type":"click","name":"运动步数","key":"V1000_STEP"},{"type":"click","name":"睡眠状况","key":"V1000_SLEEP"}]}]}'
        )
        tools.menuCreate(menu)
    tools.customSendArticle(
        msg.source,
        u"或许这些能对您有帮助",
        u"",
        "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/help.png",
        "http://" + tools.IP + "/handbook/",
    )
    return HttpResponse(create_reply(u"感谢您的关注", message=msg))
Example #2
0
def textHandle(msg):
    if msg.type == "text":
        textstr = msg.content.encode("utf-8")
        if (
            (textstr == "我是谁")
            or (textstr == "我是谁?")
            or (textstr == "我是谁?")
            or (textstr == "你猜我是谁?")
            or (textstr == "你猜我是谁?")
        ):
            return HttpResponse(
                create_reply("你是:".decode("utf-8") + "%s" % User.objects.get(openid=msg.source).name, message=msg)
            )
        if textstr == "运动步数":
            tools.customSendArticle(
                msg.source,
                u"运动步数",
                u"",
                "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/sports.png",
                "http://" + tools.IP + "/" + msg.source + "/steps/",
            )
            return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
        if textstr == "睡眠状况":
            tools.customSendArticle(
                msg.source,
                u"睡眠状况",
                u"",
                "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/sleep.jpg",
                "http://" + tools.IP + "/" + msg.source + "/sleep/",
            )
            return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
        if textstr.find("帮我将签名改为:") == 0:
            if len(textstr) > 54:
                return HttpResponse(create_reply("您的签名太长啦> <".decode("utf-8"), message=msg))
            else:
                User.objects.filter(openid=msg.source).update(sign=textstr[24:])
                return HttpResponse(create_reply("修改成功".decode("utf-8"), message=msg))
        if textstr.find("帮我将签名改为:") == 0:
            if len(textstr) > 52:
                return HttpResponse(create_reply("您的签名太长啦> <".decode("utf-8"), message=msg))
            else:
                User.objects.filter(openid=msg.source).update(sign=textstr[22:])
                return HttpResponse(create_reply("修改成功".decode("utf-8"), message=msg))
        tools.customSendArticle(
            msg.source,
            u"或许你要寻求的服务能在这里找到?",
            u"",
            "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/help.png",
            "http://" + tools.IP + "/handbook/",
        )
        return HttpResponse(create_reply("抱歉,我们找不到您要的服务".decode("utf-8"), message=msg))
Example #3
0
def clickEvent(msg):
    if msg.key == "V1000_FRIEND":
        tools.customSendArticle(
            msg.source,
            u"好友排行",
            u"",
            "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/rank.jpg",
            "http://" + tools.IP + "/" + msg.source + "/friend/",
        )
        return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
    if msg.key == "V1000_HELP":
        tools.customSendArticle(
            msg.source,
            u"产品简介",
            u"",
            "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/help.png",
            "http://" + tools.IP + "/handbook/",
        )
        return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
    if msg.key == "V1000_STEP":
        tools.customSendArticle(
            msg.source,
            u"运动步数",
            u"",
            "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/sports.png",
            "http://" + tools.IP + "/" + msg.source + "/steps/",
        )
        return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
    if msg.key == "V1000_SLEEP":
        tools.customSendArticle(
            msg.source,
            u"睡眠状况",
            u"",
            "https://raw.githubusercontent.com/wmc54321/wrist/hj/%E4%BA%8C%E5%90%88%E4%B8%80/wrist/static/images/sleep.jpg",
            "http://" + tools.IP + "/" + msg.source + "/sleep/",
        )
        return HttpResponse(create_reply("谢谢查询".decode("utf-8"), message=msg))
    return HttpResponse(create_reply(u"Hello World!I am 点击菜单跳转链接事件", message=msg))