WeRoBot: writing WeChat Offical Account Robots with fun
Project description
WeRoBot 是一个微信机器人框架,采用MIT协议发布。
文档在这里: https://werobot.readthedocs.org/en/0.5.0/
安装
推荐使用 pip 进行安装
pip install werobot
如果你没有安装 pip 而且正在使用一台 OS X / Linux 电脑,那么你应该运行
curl http://peak.telecommunity.com/dist/ez_setup.py | python curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
如果你是 Windows 用户, 那么下载 http://peak.telecommunity.com/dist/ez_setup.py 和 https://raw.github.com/pypa/pip/master/contrib/get-pip.py 这两个文件,双击运行。
Hello World
一个非常简单的 Hello World 微信机器人,会对收到的所有文本消息回复 Hello World
import werobot robot = werobot.WeRoBot(token='tokenhere') @robot.text def hello_world(): return 'Hello World!' robot.run()
Session
WeRoBot 在 0.4.0 版本中开始支持 Session , Session 可以用来方便的记录用户数据
import werobot robot = werobot.WeRoBot(token='tokenhere', enable_session=True) @robot.text def session(message, session): last = session.get("last", None) if last: return last session["last"] = message.content return '这是你第一次和我说话' robot.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
WeRoBot-0.5.0.zip
(34.3 kB
view details)
WeRoBot-0.5.0.tar.gz
(24.8 kB
view details)
File details
Details for the file WeRoBot-0.5.0.zip
.
File metadata
- Download URL: WeRoBot-0.5.0.zip
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a26cc9fdbfa01cb4181e1d8f898c43eaa0cac5b05988f51ae0a6a3212855bab5 |
|
MD5 | edecd21823617a54d6e37ec1f95a434d |
|
BLAKE2b-256 | d950af5982c3c8ffd6af57a501b58477ca720a678bda834b41bb82bf8e47deea |
File details
Details for the file WeRoBot-0.5.0.tar.gz
.
File metadata
- Download URL: WeRoBot-0.5.0.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b713e52ace46f7541f74715f422e9f790b4ab6aec2c2bb9267928e667e377dd4 |
|
MD5 | 0e02e9772a410cc41d6b155e5a70b0f3 |
|
BLAKE2b-256 | 99ced0d0a9d5a1f8090ea03bbb03a23a3a45dee28f07094b90bbd94bc1a9bdfb |