1
|
|
|
# -*- coding: utf-8 -*- |
2
|
10 |
|
from __future__ import absolute_import, unicode_literals |
3
|
|
|
|
4
|
10 |
|
from wechatpy.fields import IntegerField, StringField |
5
|
10 |
|
from wechatpy import messages |
6
|
|
|
|
7
|
|
|
|
8
|
10 |
|
MESSAGE_TYPES = {} |
9
|
|
|
|
10
|
|
|
|
11
|
10 |
|
def register_message(msg_type): |
12
|
10 |
|
def register(cls): |
13
|
10 |
|
MESSAGE_TYPES[msg_type] = cls |
14
|
10 |
|
return cls |
15
|
10 |
|
return register |
16
|
|
|
|
17
|
|
|
|
18
|
10 |
|
@register_message('text') |
19
|
10 |
|
class TextMessage(messages.TextMessage): |
20
|
10 |
|
agent = IntegerField('AgentID', 0) |
21
|
|
|
|
22
|
|
|
|
23
|
10 |
|
@register_message('image') |
24
|
10 |
|
class ImageMessage(messages.ImageMessage): |
25
|
10 |
|
agent = IntegerField('AgentID', 0) |
26
|
|
|
|
27
|
|
|
|
28
|
10 |
|
@register_message('voice') |
29
|
10 |
|
class VoiceMessage(messages.VoiceMessage): |
30
|
10 |
|
agent = IntegerField('AgentID', 0) |
31
|
|
|
|
32
|
|
|
|
33
|
10 |
|
@register_message('shortvideo') |
34
|
10 |
|
class ShortVideoMessage(messages.ShortVideoMessage): |
35
|
10 |
|
agent = IntegerField('AgentID', 0) |
36
|
|
|
|
37
|
|
|
|
38
|
10 |
|
@register_message('video') |
39
|
10 |
|
class VideoMessage(messages.VideoMessage): |
40
|
10 |
|
agent = IntegerField('AgentID', 0) |
41
|
|
|
|
42
|
|
|
|
43
|
10 |
|
@register_message('location') |
44
|
10 |
|
class LocationMessage(messages.LocationMessage): |
45
|
10 |
|
agent = IntegerField('AgentID', 0) |
46
|
|
|
|
47
|
10 |
|
@register_message('link') |
48
|
10 |
|
class LinkMessage(messages.LinkMessage): |
49
|
10 |
|
agent = IntegerField('AgentID', 0) |
50
|
|
|
pic_url = StringField('PicUrl') |
51
|
|
|
|