Code Monkey home page Code Monkey logo

werobot's Introduction

WeRoBot

image

image

image

image

image

image

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

文档在这里: https://werobot.readthedocs.org/zh_CN/latest/

安装

推荐使用 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()

werobot's People

Contributors

whtsky avatar helloqiu avatar tg123 avatar cocobear avatar ayang avatar weberwang avatar doraemonext avatar cloverstd avatar deronw avatar sbilly avatar wwj718 avatar jiahut avatar zhu327 avatar

Watchers

James Cloos avatar ayuliao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.