Skip to main content

WeRoBot: writing WeChat Offical Account Robots with fun

Project description

https://img.shields.io/travis/whtsky/WeRoBot/master.svg?maxAge=3600&label=macOS https://img.shields.io/appveyor/ci/whtsky/WeRoBot/master.svg?maxAge=3600&label=Windows https://semaphoreci.com/api/v1/whtsky/werobot/branches/master/shields_badge.svg https://codecov.io/gh/whtsky/WeRoBot/branch/master/graph/badge.svg https://img.shields.io/badge/QQ%20Group-283206829-brightgreen.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0yNzAgODA2cS04LTE5LTgtNTIgMC0yMCAxMS00OXQyNC00NXEtMS0yMiA3LjUtNTN0MjIuNS00M3EwLTEzOSA5Mi41LTI4OC41dDIxNy41LTIwOS41cTEzOS02NiAzMjQtNjYgMTMzIDAgMjY2IDU1IDQ5IDIxIDkwIDQ4dDcxIDU2IDU1IDY4IDQyIDc0IDMyLjUgODQuNSAyNS41IDg5LjUgMjIgOThsMSA1cTU1IDgzIDU1IDE1MCAwIDE0LTkgNDB0LTkgMzhxMCAxIDEuNSAzLjV0My41IDUgMiAzLjVxNzcgMTE0IDEyMC41IDIxNC41dDQzLjUgMjA4LjVxMCA0My0xOS41IDEwMHQtNTUuNSA1N3EtOSAwLTE5LjUtNy41dC0xOS0xNy41LTE5LTI2LTE2LTI2LjUtMTMuNS0yNi05LTE3LjVxLTEtMS0zLTFsLTUgNHEtNTkgMTU0LTEzMiAyMjMgMjAgMjAgNjEuNSAzOC41dDY5IDQxLjUgMzUuNSA2NXEtMiA0LTQgMTZ0LTcgMThxLTY0IDk3LTMwMiA5Ny01MyAwLTExMC41LTl0LTk4LTIwLTEwNC41LTMwcS0xNS01LTIzLTctMTQtNC00Ni00LjV0LTQwLTEuNXEtNDEgNDUtMTI3LjUgNjV0LTE2OC41IDIwcS0zNSAwLTY5LTEuNXQtOTMtOS0xMDEtMjAuNS03NC41LTQwLTMyLjUtNjRxMC00MCAxMC01OS41dDQxLTQ4LjVxMTEtMiA0MC41LTEzdDQ5LjUtMTJxNCAwIDE0LTIgMi0yIDItNGwtMi0zcS00OC0xMS0xMDgtMTA1LjV0LTczLTE1Ni41bC01LTNxLTQgMC0xMiAyMC0xOCA0MS01NC41IDc0LjV0LTc3LjUgMzcuNWgtMXEtNCAwLTYtNC41dC01LTUuNXEtMjMtNTQtMjMtMTAwIDAtMjc1IDI1Mi00NjZ6IiBmaWxsPSIjZmZmIi8%2BPC9zdmc%2B https://werobot-slackin.herokuapp.com/badge.svg

WeRoBot 是一个微信公众号开发框架,采用MIT协议发布。

文档在这里: https://werobot.readthedocs.org/zh_CN/v1.4.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.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')

@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 Distribution

WeRoBot-1.4.0.tar.gz (61.5 kB view details)

Uploaded Source

Built Distribution

WeRoBot-1.4.0-py3-none-any.whl (42.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for WeRoBot-1.4.0.tar.gz
Algorithm Hash digest
SHA256 c779e1253ea3afbf6399f0e978b9d5abe5db043a53ce1cc150486e48c1081bc8
MD5 753691ee87f590b295b40d05530c55d4
BLAKE2b-256 c2d3229091ad2bc7bdda59a0765a4640db5d735b897767ee6135d8983e6c09f4

See more details on using hashes here.

File details

Details for the file WeRoBot-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for WeRoBot-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad0b5fd7e1c552569a42f3d84830585a9ad839742990f15b9708e46765b10901
MD5 6edf39194966d2f662ef8b00d2016c3c
BLAKE2b-256 14bcd009cc2e0feeb26de2ede2202061036fffdd9255b29335d0743c884f9284

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