示例#1
0
    print message.key
    return  "This is a click %s" % message.key

client = Client('wx1c61843daa556523', '0798b663ac452fdc9ec8c76d99751a17')
token = client.grant_token()
print token
client.create_menu({"button": [
                    {
                        "type":"click",
                        "name":"今日歌曲",
                        "key":"V1001_TODAY_MUSIC"
                    },
                    {
                        "type":"click",
                        "name":"歌手简介",
                        "key":"V1001_TODAY_SINGER"
                    },
                    {
                        "name":"菜单",
                        "sub_button":[
                            {
                                "type":"view",
                                "name":"搜索",
                                "url":"http://testrobot.nat123.net/hello"
                            },
                        ]
                    }
                ]})

robot.run(host='0.0.0.0',port=80)
示例#2
0
#     payload = md5sign.get_params(plus_item)
#     # r = requests.get(url,params=payload)
#     r = requests.post(url,data=payload)
#     return r.json()["data"]["answer"]

robot = WeRoBot(enable_session=False,
        token = 'wechat',
        APP_ID = 'wxd2037f04aeb582fb',
        APP_SECRET = 'ti8e627JwSwqSVYoPDH2E6qR1GqP65cGRNqpKimdGEf')
 
@robot.text
def hello(message):   
    if is_pessimistic(message.content):
        rep = "十分抱歉给您带来的不便,我们这边马上安排工作人员和您沟通。"
        # account_sid = "ACc290a6cb0258540264b0ebb1f6a37d60"
        # auth_token = "fa5c345aedc44bc5888f843a3bbe53ed"
        # client = Client(account_sid, auth_token)
        # message = client.messages.create(to="+8617359870570",  # 区号+你的手机号码
        #                                 from_="+12023359371",  # 你的 twilio 电话号码
        #                                 body="你的客户xxx,需要你马上处理。")
        return rep
    else:    
        rep= get_content(message.content)
        return rep


# 让服务器监听在 0.0.0.0:80
robot.config['HOST'] = '0.0.0.0'
robot.config['PORT'] = 80
robot.run()
示例#3
0
    max_page = result['max_page']
    result = requests.get('%s/page/1' % url).json()
    for r in result['results']:
        return_value += '=' * 5
        return_value += '\n'

        r['last_seen'] = time.strftime("%Y-%m-%d %H:%M:%S",
                                       time.localtime(r['last_seen']))
        r['length'] = '%dMB' % int(r['length'] / 1024 / 1024)

        return_value += '名称: %s\n' % r['title']
        return_value += '大小: %s\n' % r['length']
        return_value += '记录时间: %s\n' % r['last_seen']
        return_value += '详情页: http://www.shapaozi.me/detail/%s\n' % r[
            'infohash']
        return_value += '=' * 5
        return_value += '\n'

    if max_page > 1:
        return_value += '更多结果请点击: http://www.shapaozi.me/search/%s' % message.content

    return return_value


@robot.subscribe
def hello():
    return '欢迎关注超级可爱的 ShaPaoZi ( ˙˘˙ )\n请直接回复查询内容。'


robot.run(host='localhost', port=5000, server='gunicorn')