forked from ipfyx/signal-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signal_structure.py
140 lines (112 loc) · 4.05 KB
/
signal_structure.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
from functools import total_ordering
SMS_SENT = 10485783
SMS_RECV = 10485780
SMS_NULL = [10747924,10747927,2,1,3]
DATE_FORMAT = '%A %d-%m-%Y %H:%M:%S'
class colors:
FAIL = '\033[91m'
OK = '\033[92m'
WARNING = '\033[93m'
INFO = '\033[94m'
@total_ordering
class MMS(object):
def __init__(self, date, address, msg_type, body, quote_id, quote_author, quote_body, reactions, mms_id, part_ct, part_unique_id, part_quote):
self.date = int(date)
self.address = int(address)
self.msg_type = int(msg_type)
if body:
self.body = body
else:
self.body = ''
self.quote_id = int(quote_id)
self.quote_author = int(quote_author) if quote_author is not None else None
self.quote_body = quote_body
if reactions:
self.reactions = reactions[:11].decode('utf-8')[4]
if self.reactions == '❤':
self.reactions = '❤️'
else:
self.reactions = reactions
if part_unique_id:
self.parts = [PART(mms_id, part_ct, part_unique_id, part_quote)]
else:
self.parts = []
def __str__(self):
return self.__repr__()
def __eq__(self, other):
return ((self.date,self.body) == (other.date,other.body))
def __ne__(self, other):
return not (self == other)
def __lt__(self, other):
return (self.date < other.date)
def __repr__(self):
return "date : {}, address : {}, type : {}, body : {}, quote_id : {}, quote_author : {} quote_body : {}, reactions : {}, parts : {}\n".format(self.date, self.address, self.msg_type, self.body, self.quote_id, self.quote_author, self.quote_body, self.reactions, self.parts)
@total_ordering
class SMS(object):
def __init__(self, thread_id, address, date, msg_type, body, reactions):
self.date = int(date)
self.body = body
self.msg_type = int(msg_type)
self.thread_id = int(thread_id)
self.address = int(address)
if reactions:
self.reactions = reactions[:11].decode('utf-8')[4]
if self.reactions == '❤':
self.reactions = '❤️'
else:
self.reactions = reactions
def __str__(self):
return self.__repr__()
def __eq__(self, other):
return ((self.date,self.body) == (other.date,other.body))
def __ne__(self, other):
return not (self == other)
def __lt__(self, other):
return (self.date < other.date)
def __repr__(self):
return "date : {}, type : {}, body : {}, thread_id : {}, address : {}, reactions : {}\n".format(self.date, self.msg_type, self.body, self.thread_id, self.address, self.reactions)
class PART(object):
def __init__(self, id_part, ct, unique_id, part_quote):
self.id_part = int(id_part)
self.ct = ct
self.unique_id = unique_id
# 1 if the part is already included in the quote
# else 0
self.part_quote = part_quote
if unique_id is not None:
assert(id_part is not None)
self.filename = str(unique_id) + "_" + str(id_part)
else:
self.filename = None
def __repr__(self):
return "id : {}, filename : {}, ct : {}, unique_id : {}".format(self.id_part, self.filename, self.ct, self.unique_id)
def __str__(self):
return self.__repr__()
class CONTACT(object):
def __init__(self, _id, phone, color, name, thread_id):
self.id = int(_id)
self.name = name
self.phone = phone
self.color = color
try:
self.thread_id = int(thread_id)
except TypeError:
self.thread_id = None
def __str__(self):
return self.__repr__()
def __repr__(self):
return "id : {}, name : {}, color : {}, phone : {}, thread_id : {}".format(self.id, self.name, self.color, self.phone, self.thread_id)
class GROUP(object):
def __init__(self, _id, name, members, contact_id, thread_id):
self.id = int(_id)
self.name = name
self.members = [int(m) for m in members.split(',')]
self.thread_id = int(contact_id)
try:
self.thread_id = int(thread_id)
except TypeError:
self.thread_id = None
def __str__(self):
return self.__repr__()
def __repr__(self):
return "id : {}, name : {}, contact_id : {}, thread_id : {}".format(self.id, self.name, self.contact_id, self.thread_id)