Completed
Push — master ( a9d037...ae9180 )
by Wu
14s
created

ScanCodePushEvent   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 0
dl 0
loc 4
rs 10
c 2
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3
import six
4
from werobot.messages.entries import StringEntry, IntEntry, FloatEntry
5
from werobot.messages.base import WeRoBotMetaClass
6
7
8
class EventMetaClass(WeRoBotMetaClass):
9
    pass
10
11
12
@six.add_metaclass(EventMetaClass)
13
class WeChatEvent(object):
14
    target = StringEntry('ToUserName')
15
    source = StringEntry('FromUserName')
16
    time = IntEntry('CreateTime')
17
    message_id = IntEntry('MsgID', 0)
18
19
    def __init__(self, message):
20
        self.__dict__.update(message)
21
22
23
class SimpleEvent(WeChatEvent):
24
    key = StringEntry('EventKey')
25
26
27
class TicketEvent(WeChatEvent):
28
    key = StringEntry('EventKey')
29
    ticket = StringEntry('Ticket')
30
31
32
class SubscribeEvent(TicketEvent):
33
    __type__ = 'subscribe_event'
34
35
36
class UnSubscribeEvent(WeChatEvent):
37
    __type__ = 'unsubscribe_event'
38
39
40
class ScanEvent(TicketEvent):
41
    __type__ = 'scan_event'
42
43
44
class ScanCodePushEvent(SimpleEvent):
45
    __type__ = 'scancode_push_event'
46
    scan_type = StringEntry('ScanCodeInfo.ScanType')
47
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
48
49
50
class ScanCodeWaitMsgEvent(ScanCodePushEvent):
51
    __type__ = 'scancode_waitmsg_event'
52
    scan_type = StringEntry('ScanCodeInfo.ScanType')
53
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
54
55
56
class ClickEvent(SimpleEvent):
57
    __type__ = 'click_event'
58
59
60
class ViewEvent(SimpleEvent):
61
    __type__ = 'view_event'
62
63
64
class LocationEvent(WeChatEvent):
65
    __type__ = 'location_event'
66
    latitude = FloatEntry('Latitude')
67
    longitude = FloatEntry('Longitude')
68
    precision = FloatEntry('Precision')
69
70
71
class TemplateSendJobFinishEvent(WeChatEvent):
72
    __type__ = 'templatesendjobfinish_event'
73
    status = StringEntry('Status')
74
75
76
class UnknownEvent(WeChatEvent):
77
    __type__ = 'unknown_event'
78