offu / werobot Goto Github PK
View Code? Open in Web Editor NEWWeRoBot 是一个微信公众号开发框架
Home Page: https://werobot.readthedocs.io/zh_CN/latest/
License: MIT License
WeRoBot 是一个微信公众号开发框架
Home Page: https://werobot.readthedocs.io/zh_CN/latest/
License: MIT License
Thanks to @sbilly
如果构造UnKnownMessage的话,成员里面是没有source属性,但是在robot.py的get_reply()方法里面如下代码会报错,抛出异常 说UnKnownMessage是没有source
session_storage = self.session_storage
if session_storage:
id = message.source
session = session_storage[id]
handlers = self.get_handlers(message.type)
这里的建议:
虽然感觉有点扯淡,还是说一下吧。
https://werobot.readthedocs.org/en/latest/session.html#id1
倒数第三行
你需要安装 redis 才能使用 MongoDBStorage 。
use requests>=2.3.0 for example
install_requires=map(lambda x: x.replace('==', '>='), open("requirements.txt").readlines()),
已经将那三个文件(robot.py,index.wsgi,config.yaml)上传到SAE服务器上了,并且上传了一份werobot文件夹(用pip install 下载到site-packages中,复制整个werobot文件夹到与那三个文件同级的目录下),改了config.yaml里的name,robot.py里的token='tokenhere' 也换成了自已在微信平台上的设置的token了,可是微信还是接不到回复,直接访问应用的sinaapp二级域名(http://yangyanxing.sinaapp.com)会提示
Error 500: Internal Server Error
请问我哪里出错了吗?SAE新手
求解,谢谢
特别是 issue #48 已经在develop分支被fix了,有近期合并到master分支并且release新版本的计划吗?
我的提问有点儿菜,因为我Python编程也比较菜
我想问的是,如何在本地利用poster进行测试?我post一个简单的微信数据过去,总是显示ValueError: String status line without a reason phrase.
另外,我看文档,貌似没有提到如何实现状态保持。比如我开发了功能,主菜单是:
输入1,使用x功能
输入2,使用y功能
然后现在用户输入了2,我应该回复y功能给它,要怎么实现状态保持呢?
小弟菜鸟,最近自己学习微信公众平台,现在0.6版本的微信支付接口还能不能用?
我部署在新浪SAE 收到消息回应时回应Hello world没问题 但是回应中文 你好久回无法收到!
I run the code robot.run(port=8888) ,how to get the reply?
If I open localhost:8888 in browser,I can't get the response.
收到用户主动上报的地理位置消息会报错。
<xml><ToUserName><![CDATA[id_here]]></ToUserName>
<FromUserName><![CDATA[id_here]]></FromUserName>
<CreateTime>1391486031</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[LOCATION]]></Event>
<Latitude>127.841963</Latitude>
<Longitude>123.112488</Longitude>
<Precision>30.000000</Precision>
</xml>
IOError: [Errno 13] Permission denied: '/data1/www/htdocs/305/wetest/1/werobot_session.dat'
这样的话不知道应该如何解决呢?
如果作者同意我贡献代码,我自己加也行。
requests会将dict类型的数据转化成k1=v1&k2=v2的形式,而微信需要接收json数据才会正确响应。
解决办法是将data以字符串的形式发送,或者用json.dumps再次转化。
session.delete("type", None)
AttributeError: 'dict' object has no attribute 'delete'
我想在一个vps上部署WeRoBot。
vps是ubuntu 12.04+nginx。已经申请好了公共账号。
要使WeRoBot能work,还要安装什么?
比如 , 用户如果发 "查询天气" , 机器人提示输入地点 , 然后 用户输入地名 , 机器人回复天气情况 。
如题
现在get_reply()方法里面处理外部的调用函数,结果返回reply, 但有可能会影响到session, 为了完整性建议 [reply,session] = handler(message, session)
这样的话,外部函数也是可以调取session里面的内容
现在的是通过微信帐号给公众帐号发送消息后,再进行消息回复。
有没有办法主动从公众帐号给某个特定的微信帐号发送消息,该微信帐号已经关注公众帐号。请教下思路。
大神我们期待针对企业号的封装!
develop 分支返回消息 ToUserName 和 FromUserName 一样
模板消息用于公众号向用户发送重要的服务通知,参见:
http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html
根据现在的微信api接口文档,在消息xml中,fromusername和tousername都是一串openid, 不知道代表什么人,如果在进行回答的时候能够识别谈话者的微信号,就可以打招呼用姓名了?
请问现在的代码解决了这个问题吗?
upload_media 是对media进行操作,显然此处的api是对menu进行操作。
应该怎么办
在 robot.py 里面添加相应路由吗?
RuntimeError: Bottle requires gevent.monkey.patch_all() (before import)
从0.4版开始按照介绍是启用了session管理,
查看代码以FileStorage为例子,存放在文件 "werobot_session"中使用的是dbm格式和库包
如果用户下一次,比如第二次等等,在robot.py文件中 BaseRobot类的get_reply()方法里面,因为已经存在session_storage了,那么从取出sesion, 见如下代码
id = message.source
session = session_storage[id]
我发现有个问题就是当第一次的时候,那么怎么办呢,session应该是要构建出来?session的构建代码没有找到?请教一下了。
谢谢
我写了一个微信公众号 Python SDK wechatpy,纯粹做了解析消息、生成回复和主动调用 API 这些功能,参考(或者说 copy 了)不少 WeRoBot 的代码。
我觉得 WeRoBot 可以用 wechatpy 来做解析消息等 SDK 层面的工作,专注做 robot 层面的东西。你觉得呢?
如题,谢谢 :)
to_text()
输入是 unicode 时报错。
In [1]: import six
In [2]: def to_text(value, encoding="utf-8"):
...: if isinstance(value, (six.string_types, six.binary_type)):
...: return value.decode(encoding)
...: if isinstance(value, int):
...: return six.text_type(value)
...: assert isinstance(value, six.text_type)
...: return value
...:
In [3]: print to_text(u'\u4e2d\u5348')
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-3-9478a71004a0> in <module>()
----> 1 print to_text(u'\u4e2d\u5348')
<ipython-input-2-3b3748f845b1> in to_text(value, encoding)
1 def to_text(value, encoding="utf-8"):
2 if isinstance(value, (six.string_types, six.binary_type)):
----> 3 return value.decode(encoding)
4 if isinstance(value, int):
5 return six.text_type(value)
/root/.virtualenvs/wxPortal/lib/python2.7/encodings/utf_8.pyc in decode(input, errors)
14
15 def decode(input, errors='strict'):
---> 16 return codecs.utf_8_decode(input, errors, True)
17
18 class IncrementalEncoder(codecs.IncrementalEncoder):
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
针对创建菜单api的问题:
源码./client.py 里创建菜单api有些问题,我的解决方式是:
132 return self.post(
133 url="https://api.weixin.qq.com/cgi-bin/menu/create",
134 data=json.dumps(menu_data,ensure_ascii=False)
135 )
按照WeRoBot-SAE-demo上的方法部署到SAE,saecloud install werobot
命令并没有把0.11.6版的bottle.py安装到site-packages/目录。由于SAE默认为bottle0.96。不支持 @app.post('<t:path>')
这种写法,导致发生404错误。必须手动copy 0.11.6版本的bottle.py到工程目录。
thanks
我依据你的写了一个api,没有完成,不过实现的基本都测试通过了
https://github.com/ForTheDream/weixin_api.git
[root@linux]# python3 wx-0.5.py
Traceback (most recent call last):
File "wx-0.5.py", line 116, in
robot.run(server='tornado', port=8888)
File "/opt/python3/lib/python3.3/site-packages/werobot/robot.py", line 250, in run
enable_pretty_logging(self.logger)
File "/opt/python3/lib/python3.3/site-packages/werobot/logger.py", line 32, in enable_pretty_logging
channel.setFormatter(_LogFormatter(color=color))
File "/opt/python3/lib/python3.3/site-packages/werobot/logger.py", line 53, in init
logging.DEBUG: unicode(curses.tparm(fg_color, 4),
NameError: global name 'unicode' is not defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.