client.create_menu({ "button": [ { "type": "view", "name": "Valentine", "url": "http://create.maka.im/k/1FG29JLU" }, { "type": "view", "name": "Beautiful", "url": "http://create.maka.im/k/EQ52YHUW" }, { "name": "More", "sub_button": [ { "type": "click", "name": "Life", "key": "SNS" }, { "type": "click", "name": "Moment", "key": "MOMENT" }, { "type": "click", "name": "Music", "key": "MUSIC" }, { "type": "click", "name": "Kiss Me", "key": "NICE" } ] } ]})
# -*- coding: utf-8 -*- import werobot from werobot.client import Client robot = werobot.WeRoBot(token='hehe') app_id = 'wx35028b78608d38f9' app_secret = '107da9b468d3cf7427dc439de6405d01' client = Client(app_id, app_secret) client.create_menu({ "button": [ { "type": "view", "name": "Test", "url": "www.baidu.com" } ]}) @robot.handler def echo(message): print robot return 'http://www.baidu.com' robot.run(host='0.0.0.0', port=80)
def switch(): sensor_data = get_sensor_data() if (sensor_data): return "液化气浓度:{0} ppm".format(float(sensor_data['MQ-2'])) else: return err_msg @robot.key_click("SMOKE") def switch(): sensor_data = get_sensor_data() if (sensor_data): return "烟雾浓度:{0} ppm".format(float(sensor_data['MQ-5'])) else: return err_msg @robot.click def click_event(): return "我还没有准备好!" # Reading menu data back with open('./data/menu.json', 'r') as f: menu_data = json.load(f) client = Client("wx6eff06f20136ac85", "f2cafa0e5900a415e812ac2ef557d0f6") client.create_menu(menu_data) robot.run(host='0.0.0.0', port=8889)
client.create_menu({ "button": [{ "type": "view", "name": "Valentine", "url": "http://create.maka.im/k/1FG29JLU" }, { "type": "view", "name": "Beautiful", "url": "http://create.maka.im/k/EQ52YHUW" }, { "name": "More", "sub_button": [{ "type": "click", "name": "Life", "key": "SNS" }, { "type": "click", "name": "Moment", "key": "MOMENT" }, { "type": "click", "name": "Music", "key": "MUSIC" }, { "type": "click", "name": "Kiss Me", "key": "NICE" }] }] })
config = Config() basedir = os.path.dirname(os.path.abspath(__file__)) config.from_pyfile(os.path.join(basedir, "client_config.py")) client = Client(config=config) from werkzeug.local import LocalProxy def get_client(): return client tulingbot = Tuling() ###client.get_menu ''' client.create_menu({ "button": [ { "name": "办事指南", "sub_button": [ { "type": "click", "name": "最新政策", "key": "zxzc" }, { "type": "click", "name": "最新通知", "key": "zxtz" }, { "type": "click",