Skip to main content

WeRoBot: writing WeChat Offical Account Robots with fun

Project description

https://api.travis-ci.org/whtsky/WeRoBot.png?branch=master https://coveralls.io/repos/whtsky/WeRoBot/badge.png?branch=master https://scrutinizer-ci.com/g/whtsky/WeRoBot/badges/quality-score.png?b=master

WeRoBot 是一个微信机器人框架,采用MIT协议发布。

文档在这里: https://werobot.readthedocs.org/en/0.6.1/

安装

推荐使用 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.pyhttps://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


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.6.1.zip (39.2 kB view details)

Uploaded Source

WeRoBot-0.6.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

WeRoBot-0.6.1-py2.py3-none-any.whl (21.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file WeRoBot-0.6.1.zip.

File metadata

  • Download URL: WeRoBot-0.6.1.zip
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for WeRoBot-0.6.1.zip
Algorithm Hash digest
SHA256 212afae3e95cd70f501caf9c88d7ac21e128ba8130a020f24c7077cde7b4294b
MD5 193f9eb690df783990c1ad3ab4a1bec6
BLAKE2b-256 864a023e893673ec79b5e8436fbb9035bdca16c4b92ed939b4e7eb53d939b467

See more details on using hashes here.

File details

Details for the file WeRoBot-0.6.1.tar.gz.

File metadata

  • Download URL: WeRoBot-0.6.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for WeRoBot-0.6.1.tar.gz
Algorithm Hash digest
SHA256 9f642f5536788f564c0bb2555ea26fc150abd42babd562db9ea9ad22682dc398
MD5 deb23c2c04c962dd9307f87438861a25
BLAKE2b-256 44c129711a33ca8bb22d9df475039b89ab191cf74296aec2f8737044b4611772

See more details on using hashes here.

File details

Details for the file WeRoBot-0.6.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for WeRoBot-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f2c55e7be56d5217436c912967f7ab48f3f9f698b2840ff7f1235628fe04d937
MD5 5a1a1c8eb737234459fb70ccba0307c1
BLAKE2b-256 7de51145c82ad6f1dfa7589d04ed0ba55cf3488fd9d655fc9f6cf36b095195da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page