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.4.0/

安装

推荐使用 pip 进行安装

pip install werobot

如果你没有安装 pip 而且正在使用一台 OS X / Linux 电脑,那么你应该运行

curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

如果你是 Windows 用户, 那么下载 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(message):
    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.4.0.zip (28.1 kB view details)

Uploaded Source

WeRoBot-0.4.0.tar.gz (19.8 kB view details)

Uploaded Source

File details

Details for the file WeRoBot-0.4.0.zip.

File metadata

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

File hashes

Hashes for WeRoBot-0.4.0.zip
Algorithm Hash digest
SHA256 493af54bc0db3eb9f3633845133530d73823085d9bf4b4bfb9f1ec27be8ce5c9
MD5 2c512da2fc68d3141ffb8a0ac52bffc8
BLAKE2b-256 cd35bce07b3ff3b5c15fdee7fb243d5c578c7bf982e93060d9e454df1de6d948

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for WeRoBot-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dedd6d536c1126431b5dbfc512fdd9d00193794bfee2e6ca5d8061a44f17587e
MD5 e463de1c7736dbd1ffd5973739c2297e
BLAKE2b-256 f7498c1203eb1152324702d75b1e8c4f94ee1184ecb2978f80c2f1025b0ef086

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