forked from zwczou/weixin-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg.py
More file actions
56 lines (36 loc) · 923 Bytes
/
msg.py
File metadata and controls
56 lines (36 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
from flask import Flask
from weixin.msg import WeixinMsg
app = Flask(__name__)
msg = WeixinMsg("e10adc3949ba59abbe56e057f20f883e", None, 0)
app.add_url_rule("/", view_func=msg.view_func)
@msg.all
def all_test(**kwargs):
print kwargs
# 或者直接返回
# return "all"
return msg.reply(
kwargs['sender'], sender=kwargs['receiver'], content='all'
)
@msg.text()
def hello(**kwargs):
return dict(content="hello too!", type="text")
@msg.text("world")
def world(**kwargs):
return msg.reply(
kwargs['sender'], sender=kwargs['receiver'], content='hello world!'
)
@msg.image
def image(**kwargs):
print kwargs
return ""
@msg.subscribe
def subscribe(**kwargs):
print kwargs
return ""
@msg.unsubscribe
def unsubscribe(**kwargs):
print kwargs
return ""
if __name__ == '__main__':
app.run(host="0.0.0.0", port=9900)