-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmessage.py
106 lines (77 loc) · 2.67 KB
/
message.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# coding: utf8
class Message(object):
"""Wei chart super class"""
def __init__(self, touser, fromuser, create_time, msg_id):
self.touser = touser
self.fromuser = fromuser
self.create_time = int(create_time)
if msg_id:
self.msg_id = int(msg_id)
class TextMessage(Message):
"""
Text message
touser - 开发者微信号
fromuser - 发送方微信号(OpenId)
create_time - 消息创建时间
msg_id - 消息Id,64位整数
content - 文本消息内容
"""
def __init__(self, touser, fromuser, create_time, msg_id, content):
super(TextMessage, self).__init__(touser, fromuser, create_time, msg_id)
self.content = content
if self.content == 'Hello2BizUser':
self.msg_type = 'hello'
self.msg_type = "text"
class ImageMessage(Message):
"""
Image message
pic_url - 图片连接
"""
def __init__(self, touser, fromuser, create_time, msg_id, pic_url):
super(ImageMessage, self).__init__(touser, fromuser, create_time, msg_id)
self.msg_type = "image"
self.pic_url = pic_url
class LinkMessage(Message):
"""
Link message
title - 消息标题
description - 消息描述
url - 消息链接
"""
def __init__(self, touser, fromuser, create_time, msg_id, title, description, url):
super(LinkMessage, self).__init__(touser, fromuser, create_time, msg_id)
self.msg_type = "link"
self.title = title
self.description = description
self.url = url
class LocationMessage(Message):
"""
Location Message
x - 地理位置纬度
y - 地理位置经度
scale - 地图缩放大小
label - 地理位置信息
"""
def __init__(self, touser, fromuser, create_time, msg_id, x, y, scale, label):
super(LocationMessage, self).__init__(touser, fromuser, create_time, msg_id)
self.msg_type = "location"
self.x = x
self.y = y
self.scale = scale
self.label = label
class EventMessage(Message):
"""
Event push message
event - 事件类型,有subscribe(订阅), unsubscribe(取消订阅), CLICK(自定义菜单点击事件)
event_key - 时间Key值,对应自定义菜单中的Key
"""
def __init__(self, touser, fromuser, create_time, msg_id, event, event_key):
super(EventMessage, self).__init__(touser, fromuser, create_time, msg_id)
self.msg_type = "event"
self.event = event
self.event_key = event_key
class ErrorMessage(object):
"""错误消息"""
def __init__(self, errcode, errmsg):
self.errcode = errcode
self.errmsg = errmsg