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://pypip.in/v/WeRoBot/badge.png https://pypip.in/d/WeRoBot/badge.png

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

文档在这里: https://werobot.readthedocs.org/en/0.5.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.5.1.zip (34.3 kB view details)

Uploaded Source

WeRoBot-0.5.1.tar.gz (24.8 kB view details)

Uploaded Source

File details

Details for the file WeRoBot-0.5.1.zip.

File metadata

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

File hashes

Hashes for WeRoBot-0.5.1.zip
Algorithm Hash digest
SHA256 fa6a30901c898afc809b71a196f305ccfb22a8b0bcb0236b3db55714fcc95257
MD5 9a2abaf4e8c96a681ee85baf081d2238
BLAKE2b-256 6b7f26a500105e863012799006fbf8268ffe6a57751d353bd76de00eab79c61a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for WeRoBot-0.5.1.tar.gz
Algorithm Hash digest
SHA256 53520984b927f7b6c84e13a54c61cfa6c373f68626ede1ab98041908119052a6
MD5 6693869e3e1d7f469fe28bdfb926bfe6
BLAKE2b-256 20748552f4d2e84f1bc64a3256fce5fb85f568d3f9ae3b3e6151fbfca9f6aec7

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