-
Notifications
You must be signed in to change notification settings - Fork 11
/
Test.py
67 lines (40 loc) · 1.11 KB
/
Test.py
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
57
58
59
60
61
62
63
64
65
66
#coding:utf-8
from WeiXinCore.WeiXinMsg import *
weixin = WeiXinMsg(u'''
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[voice]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<Recognition><![CDATA[腾讯微信团队]]></Recognition>
<MsgId>1234567890123456</MsgId>
</xml>
''')
def onEvent(wxmsg):
print 'event'
def onText(wxmsg):
print 'text'
def onImage(wxmsg):
pass
def onVoice(wxmsg):
print 'voice'
def onLocation(wxmsg):
pass
def onLink(wxmsg):
pass
Response = {
"event":onEvent,
"text":onText,
"voice":onVoice,
}
print '\n'.join([k+':'+str(v) for k,v in weixin.j.items()])
print weixin['MsgType']
print weixin.j['MsgType']
Response[weixin.MsgType]()
# news1 = NewsItem("title1","wwwwwwwwwwwwwww","picurl1","url")
# news2 = NewsItem("title2","wwwwwwwwwwwwwww","picurl2","url")
# news3 = NewsItem("title3","wwwwwwwwwwwwwww","picurl3","url")
# news_items = [news1,news2,news3]
# print ''.join([str(i) for i in news_items])