• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Weixin implementation in Flask.

Flask-Weixin

Flask-Weixin is the implementation for http://mp.weixin.qq.com/ with the flavor of Flask. It can be used without Flask too.

Wheel Status Latest Version Travis CI Coverage Status

Installation

You can install Flask-Weixin with pip:

$ pip install Flask-Weixin

Or, with setuptools easy_install in case you didn't have pip:

$ easy_install Flask-Weixin

Getting Started

Eager to get started? It is always the Flask way to create a new instance:

from flask_weixin import Weixin

weixin = Weixin(app)

Or pass the app later:

weixin = Weixin()
weixin.init_app(app)

However, you need to configure before using it, here is the configuration list:

  • WEIXIN_TOKEN: this is required
  • WEIXIN_SENDER: a default sender, optional
  • WEIXIN_EXPIRES_IN: not expires by default

For Flask user, it is suggested that you use the default view function:

app.add_url_rule('/', view_func=weixin.view_func)

@weixin.register('*')
def reply(**kwargs):
    username = kwargs.get('sender')
    sender = kwargs.get('receiver')
    content = kwargs.get('content')
    return weixin.reply(
        username, sender=sender, content=content
    )

The example above will reply anything the user sent.

Or you can register a function to handle a specific keyword:

@weixin.register('help')
def reply_help(**kwargs):
    ...

this function will be used to handle text message help.

There are more ways to match messages to handlers:

@weixin.register(type='event', event='subscribe')
def send_welcome(**kwargs):
    username = kwargs.get('sender')
    sender = kwargs.get('receiver')
    return weixin.reply(username, sender=sender, content='Thanks for follow!')

this function will send a message to new followers.

Message Types

Every message from weixin has these information:

  • id: message ID
  • receiver: which is ToUserName in the official documentation
  • sender: which is FromUserName in the official documentation
  • type: message type
  • timestamp: message timestamp

Text Type

Text type has an extra data: content.

Image Type

Image type has an extra data: picurl.

Link Type

Link type has extra data:

  • title: article title
  • description: article description
  • url: original url of the article

Location Type

Location type has extra data:

  • location_x
  • location_y
  • scale
  • label

Event Type

Event type has extra data:

  • event
  • event_key
  • latitude
  • longitude
  • precision

Voice Type

Event type has extra data:

  • media_id
  • format
  • recognition

More Repositories

1

authlib

The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Python
3,619
star
2

editor

A markdown editor. http://lab.lepture.com/editor/
JavaScript
2,791
star
3

mistune

A fast yet powerful Python Markdown parser with renderers and plugins.
Python
2,323
star
4

github-cards

The unofficial GitHub Cards. Card for your GitHub profile, card for your GitHub repositories.
HTML
2,085
star
5

flask-oauthlib

YOU SHOULD USE https://github.com/lepture/authlib
Python
1,443
star
6

python-livereload

livereload server in python
Python
993
star
7

captcha

A captcha library that generates audio and image CAPTCHAs.
Python
920
star
8

nico

MAINTAINER WANTED!
JavaScript
277
star
9

vui

A UI framework for mobile, built with Vue.
Vue
246
star
10

zerqu

ZERQU is a content-focused API-based platform.
Python
173
star
11

vim-jinja

jinja plugins for vim (syntax and indent)
Vim Script
141
star
12

getbook

Generate ebooks from a collection of web links.
Python
108
star
13

flask-turbolinks

Turbolinks for Flask.
Python
80
star
14

tornado.ext

!!!DEACTIVATE!!!
Python
75
star
15

markit

A markdown parser and compiler with custom rendering. Forked from marked.
JavaScript
73
star
16

colorful

colorful environment for command line tools in node
JavaScript
62
star
17

safe

Is your password safe?
Python
62
star
18

shibuya

A responsive, good looking with modern design documentation theme for Sphinx
CSS
59
star
19

opencc-python

OpenCC binding for Python.
Python
52
star
20

selection.js

selection.js provides a clean API to access selection on browser.
JavaScript
52
star
21

terminal

A terminal environment tools for python.
Python
49
star
22

ganam

Yes, it's Ganam Style - a ganam style guide parser. Inspired by kneath's kss.
JavaScript
49
star
23

lepture.com

My website. (It is not powered by Jekyll)
HTML
48
star
24

safe.js

Is your password safe?
JavaScript
47
star
25

july

DEACTIVATE.
Python
47
star
26

tower-slack

将 Tower.im 的消息发送到 Slack 上
Python
46
star
27

chinalaw

请关注 https://github.com/cn
44
star
28

mistune-contrib

Contribution for mistune.
Python
40
star
29

getbook-chinese

Python
35
star
30

tornado.third

third party for tornado, see howto at https://github.com/lepture/tornado.ext
Python
35
star
31

social

Share your notes with a beautiful social button.
JavaScript
34
star
32

flask-storage

Uploader extension for Flask. [WIP]
Python
34
star
33

flask-shorturl

Short URL generator for Flask.
Python
33
star
34

rewatch

Watch and execute command.
JavaScript
30
star
35

dotfiles

my dot files
Python
27
star
36

tforms

Python
24
star
37

dingo

My personal mini Heroku (WIP)
Shell
23
star
38

vino

Vino Is Not ORM [DONT USE IT]
Python
22
star
39

mocha-browser

A mocha test suite for browser.
JavaScript
19
star
40

vim-css

css3 syntax support for vim
Vim Script
18
star
41

StatusBarApp

Demo for Status Bar App
Objective-C
16
star
42

example-oauth1-server

This is an example of OAuth 1 Server.
Python
16
star
43

onepage

Onepage scroll webpage in component.
JavaScript
15
star
44

vim-velocity

velocity syntax for vim
Vim Script
14
star
45

ed

A wysiwyg editor without configuration.
JavaScript
14
star
46

mailship

A solution for shipping emails as cheaper as possible. (WIP)
Go
13
star
47

liquidluck-theme-moment

liquidluck default theme
CSS
12
star
48

Vealous

This project is DEACTIVE
Python
12
star
49

burglar

Let's rob the fat guys, and publish everything into feeds.
Python
12
star
50

pedantmark

Python binding of GitHub CommonMark with extensions and renderers.
Python
12
star
51

pigeon

Sending mails over HTTP.
JavaScript
11
star
52

jekyll-vision

A jekyll theme that once looked like my blog.
CSS
11
star
53

nico-one

the one theme for nico
CSS
11
star
54

feedme

Feeds by Doocer
Python
10
star
55

color-patterns

Colors that I love.
CSS
10
star
56

aiowhoosh

Whoosh over HTTP by aiohttp
Python
8
star
57

ansible-scrapyd

Ansible role for scrapyd.
8
star
58

flask-alchemy

Flask-Alchemy is designed to work with SQLAlchemy default declarative_base, with powerful master-slave and seprated databases support.
Python
8
star
59

caret

Manipulate caret, selection and range.
JavaScript
7
star
60

jsdc-2014

Slide for JSDC TW 2014
JavaScript
7
star
61

sanitize

sanitize html for safety.
JavaScript
7
star
62

pydouban

deactived. see tornado.third instead.
Python
7
star
63

learn-ios-development

Keep the tune of learning.
7
star
64

liquidluck-theme-octopress

octopress theme for Felix Felicis
JavaScript
6
star
65

writeup

Don't use it. This is designed for my own.
Python
6
star
66

ganam-cli

The command line tools for ganam style guide.
JavaScript
6
star
67

github.js

GitHub API in seajs
JavaScript
6
star
68

ebook

ebook library for mobi and epub
Python
5
star
69

markdown-textarea

A <textarea> with markdown toolbar.
JavaScript
5
star
70

format

An easy way for formatting in content editable.
JavaScript
5
star
71

nico-boilerplate

An example for nico blog on GitHub.
Python
5
star
72

og.py

Parse open graph and twitter card from HTML content.
Python
5
star
73

heroku-stripe

My Simple Stripe system on Heroku.
HTML
5
star
74

color-picker

Color picker component.
JavaScript
5
star
75

gaussian-blur

Gaussian blur effect for images.
JavaScript
5
star
76

hentry

Parse hentry from microformats
Python
4
star
77

ipinfo

Query an IP Information.
Python
4
star
78

placeholder

placeholder for contenteditable
JavaScript
4
star
79

semantic-ui

Semantic-UI as a component.
JavaScript
4
star
80

python-wheels

Build my wheels
4
star
81

email-howto

How to write email templates in practice.
CSS
3
star
82

whitepac

Generate whitelist pac for proxy.
JavaScript
3
star
83

removie

Play m3u8
Go
3
star
84

liquidluck-editor

editor server for Felix Felicis
JavaScript
2
star
85

substitute

A proxy image server
JavaScript
2
star
86

node-vc

change version of a package.json
JavaScript
2
star
87

ansible-elasticsearch

Ansible role which manage Elasticsearch 2.x.
2
star
88

init

init: for a simple life [not ready]
Python
2
star
89

book-chenmaoxiu

九一話人生 陳茂修自傳
2
star
90

k-format

Fix keyboard behavior for format.
JavaScript
2
star
91

vue-hammer

Hammer directive for Vue
JavaScript
2
star
92

cordova-plugin-socialkit

Cordova plugin for requesting social services. (WIP)
Objective-C
2
star
93

typlog-coffee

A typlog theme designed by uxcoffee.
CSS
2
star
94

mistune-renderers

Changed to https://github.com/lepture/mistune-contrib
Python
2
star
95

feedpod

Podcasts by Doocer
Python
1
star
96

longjing

longjing is a full stack logging system for node.
JavaScript
1
star
97

docker-bedrock

Bedrock server via Docker
Dockerfile
1
star
98

mardict

just a dict bot
Python
1
star
99

liquidluck

Moved to https://github.com/avelino/liquidluck
HTML
1
star