reywechat 1.0.63__py3-none-any.whl → 1.0.65__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reywechat/rdb.py +83 -23
- reywechat/rlog.py +8 -8
- reywechat/rreceive.py +29 -29
- reywechat/rsend.py +49 -49
- {reywechat-1.0.63.dist-info → reywechat-1.0.65.dist-info}/METADATA +1 -1
- {reywechat-1.0.63.dist-info → reywechat-1.0.65.dist-info}/RECORD +8 -8
- {reywechat-1.0.63.dist-info → reywechat-1.0.65.dist-info}/WHEEL +0 -0
- {reywechat-1.0.63.dist-info → reywechat-1.0.65.dist-info}/licenses/LICENSE +0 -0
reywechat/rdb.py
CHANGED
@@ -19,7 +19,7 @@ from reykit.rwrap import wrap_thread
|
|
19
19
|
|
20
20
|
from .rbase import WeChatBase
|
21
21
|
from .rreceive import WeChatMessage
|
22
|
-
from .rsend import WeChatSendTypeEnum, WeChatSendStatusEnum,
|
22
|
+
from .rsend import WeChatSendTypeEnum, WeChatSendStatusEnum, WeChatSendParameters
|
23
23
|
from .rwechat import WeChat
|
24
24
|
|
25
25
|
|
@@ -31,7 +31,7 @@ __all__ = (
|
|
31
31
|
class WeChatDatabase(WeChatBase):
|
32
32
|
"""
|
33
33
|
WeChat database type.
|
34
|
-
Can create database used `self.
|
34
|
+
Can create database used `self.build_db` method.
|
35
35
|
"""
|
36
36
|
|
37
37
|
|
@@ -82,7 +82,7 @@ class WeChatDatabase(WeChatBase):
|
|
82
82
|
|
83
83
|
# Check.
|
84
84
|
if 'sqlite' in (self.database_wechat.backend, self.database_file.backend):
|
85
|
-
text='not suitable for SQLite databases'
|
85
|
+
text = 'not suitable for SQLite databases'
|
86
86
|
throw(AssertionError, text=text)
|
87
87
|
|
88
88
|
# Add handler.
|
@@ -159,6 +159,20 @@ class WeChatDatabase(WeChatBase):
|
|
159
159
|
}
|
160
160
|
],
|
161
161
|
'primary': 'user_id',
|
162
|
+
'indexes': [
|
163
|
+
{
|
164
|
+
'name': 'n_create_time',
|
165
|
+
'fields': 'create_time',
|
166
|
+
'type': 'noraml',
|
167
|
+
'comment': 'Record create time normal index.'
|
168
|
+
},
|
169
|
+
{
|
170
|
+
'name': 'n_update_time',
|
171
|
+
'fields': 'update_time',
|
172
|
+
'type': 'noraml',
|
173
|
+
'comment': 'Record update time normal index.'
|
174
|
+
}
|
175
|
+
],
|
162
176
|
'comment': 'User contact table.'
|
163
177
|
},
|
164
178
|
|
@@ -204,6 +218,20 @@ class WeChatDatabase(WeChatBase):
|
|
204
218
|
}
|
205
219
|
],
|
206
220
|
'primary': 'room_id',
|
221
|
+
'indexes': [
|
222
|
+
{
|
223
|
+
'name': 'n_create_time',
|
224
|
+
'fields': 'create_time',
|
225
|
+
'type': 'noraml',
|
226
|
+
'comment': 'Record create time normal index.'
|
227
|
+
},
|
228
|
+
{
|
229
|
+
'name': 'n_update_time',
|
230
|
+
'fields': 'update_time',
|
231
|
+
'type': 'noraml',
|
232
|
+
'comment': 'Record update time normal index.'
|
233
|
+
}
|
234
|
+
],
|
207
235
|
'comment': 'Chat room contact table.'
|
208
236
|
},
|
209
237
|
|
@@ -255,6 +283,20 @@ class WeChatDatabase(WeChatBase):
|
|
255
283
|
}
|
256
284
|
],
|
257
285
|
'primary': ['room_id', 'user_id'],
|
286
|
+
'indexes': [
|
287
|
+
{
|
288
|
+
'name': 'n_create_time',
|
289
|
+
'fields': 'create_time',
|
290
|
+
'type': 'noraml',
|
291
|
+
'comment': 'Record create time normal index.'
|
292
|
+
},
|
293
|
+
{
|
294
|
+
'name': 'n_update_time',
|
295
|
+
'fields': 'update_time',
|
296
|
+
'type': 'noraml',
|
297
|
+
'comment': 'Record update time normal index.'
|
298
|
+
}
|
299
|
+
],
|
258
300
|
'comment': 'Chat room user contact table.'
|
259
301
|
},
|
260
302
|
|
@@ -347,6 +389,12 @@ class WeChatDatabase(WeChatBase):
|
|
347
389
|
],
|
348
390
|
'primary': 'message_id',
|
349
391
|
'indexes': [
|
392
|
+
{
|
393
|
+
'name': 'n_create_time',
|
394
|
+
'fields': 'create_time',
|
395
|
+
'type': 'noraml',
|
396
|
+
'comment': 'Record create time normal index.'
|
397
|
+
},
|
350
398
|
{
|
351
399
|
'name': 'n_message_time',
|
352
400
|
'fields': 'message_time',
|
@@ -380,10 +428,10 @@ class WeChatDatabase(WeChatBase):
|
|
380
428
|
'comment': 'Record create time.'
|
381
429
|
},
|
382
430
|
{
|
383
|
-
'name': '
|
431
|
+
'name': 'update_time',
|
384
432
|
'type': 'datetime',
|
385
|
-
'constraint': '
|
386
|
-
'comment': '
|
433
|
+
'constraint': 'DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP',
|
434
|
+
'comment': 'Record update time.'
|
387
435
|
},
|
388
436
|
{
|
389
437
|
'name': 'plan_time',
|
@@ -446,16 +494,28 @@ class WeChatDatabase(WeChatBase):
|
|
446
494
|
'primary': 'send_id',
|
447
495
|
'indexes': [
|
448
496
|
{
|
449
|
-
'name': '
|
450
|
-
'fields': '
|
497
|
+
'name': 'n_create_time',
|
498
|
+
'fields': 'create_time',
|
451
499
|
'type': 'noraml',
|
452
|
-
'comment': '
|
500
|
+
'comment': 'Record create time normal index.'
|
501
|
+
},
|
502
|
+
{
|
503
|
+
'name': 'n_update_time',
|
504
|
+
'fields': 'update_time',
|
505
|
+
'type': 'noraml',
|
506
|
+
'comment': 'Record update time normal index.'
|
453
507
|
},
|
454
508
|
{
|
455
509
|
'name': 'n_receive_id',
|
456
510
|
'fields': 'receive_id',
|
457
511
|
'type': 'noraml',
|
458
512
|
'comment': 'Receive to user ID or chat room ID normal index.'
|
513
|
+
},
|
514
|
+
{
|
515
|
+
'name': 'n_file_id',
|
516
|
+
'fields': 'file_id',
|
517
|
+
'type': 'noraml',
|
518
|
+
'comment': 'Send file ID normal index.'
|
459
519
|
}
|
460
520
|
],
|
461
521
|
'comment': 'Message send table.'
|
@@ -657,7 +717,7 @@ class WeChatDatabase(WeChatBase):
|
|
657
717
|
{
|
658
718
|
'name': 'send_last_time',
|
659
719
|
'select': (
|
660
|
-
'SELECT MAX(`
|
720
|
+
'SELECT MAX(`update_time`)\n'
|
661
721
|
f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
|
662
722
|
'WHERE `status` = 2'
|
663
723
|
),
|
@@ -1094,26 +1154,26 @@ class WeChatDatabase(WeChatBase):
|
|
1094
1154
|
|
1095
1155
|
|
1096
1156
|
# Define.
|
1097
|
-
def sender_handler_update_send_status(
|
1157
|
+
def sender_handler_update_send_status(send_params: WeChatSendParameters) -> None:
|
1098
1158
|
"""
|
1099
1159
|
Update field `status` of table `message_send`.
|
1100
1160
|
|
1101
1161
|
Parameters
|
1102
1162
|
----------
|
1103
|
-
|
1163
|
+
send_params : `WeChatSendParameters` instance.
|
1104
1164
|
"""
|
1105
1165
|
|
1106
1166
|
# Check.
|
1107
|
-
if
|
1167
|
+
if send_params.status != WeChatSendStatusEnum.SENT:
|
1108
1168
|
return
|
1109
1169
|
|
1110
1170
|
# Handle parameter.
|
1111
|
-
if
|
1171
|
+
if send_params.exc_reports == []:
|
1112
1172
|
status = 2
|
1113
1173
|
else:
|
1114
1174
|
status = 3
|
1115
1175
|
data = {
|
1116
|
-
'send_id':
|
1176
|
+
'send_id': send_params.send_id,
|
1117
1177
|
'status': status,
|
1118
1178
|
'limit': 1
|
1119
1179
|
}
|
@@ -1226,15 +1286,15 @@ class WeChatDatabase(WeChatBase):
|
|
1226
1286
|
parameter['file_path'] = file_path
|
1227
1287
|
parameter['file_name'] = file_name
|
1228
1288
|
|
1229
|
-
|
1289
|
+
send_params = WeChatSendParameters(
|
1230
1290
|
self.wechat.sender,
|
1231
1291
|
send_type,
|
1232
1292
|
receive_id,
|
1233
1293
|
send_id,
|
1234
1294
|
**parameter
|
1235
1295
|
)
|
1236
|
-
|
1237
|
-
self.wechat.sender.queue.put(
|
1296
|
+
send_params.status = WeChatSendStatusEnum.WAIT
|
1297
|
+
self.wechat.sender.queue.put(send_params)
|
1238
1298
|
|
1239
1299
|
# Commit.
|
1240
1300
|
conn.commit()
|
@@ -1319,21 +1379,21 @@ class WeChatDatabase(WeChatBase):
|
|
1319
1379
|
return judge
|
1320
1380
|
|
1321
1381
|
|
1322
|
-
def _insert_send(self,
|
1382
|
+
def _insert_send(self, send_params: WeChatSendParameters) -> None:
|
1323
1383
|
"""
|
1324
1384
|
Insert into `wechat.message_send` table of database, wait send.
|
1325
1385
|
|
1326
1386
|
Parameters
|
1327
1387
|
----------
|
1328
|
-
|
1388
|
+
send_params : `WeChatSendParameters` instance.
|
1329
1389
|
"""
|
1330
1390
|
|
1331
1391
|
# Handle parameter.
|
1332
|
-
params =
|
1392
|
+
params = send_params.params.copy()
|
1333
1393
|
data = {
|
1334
1394
|
'status': 0,
|
1335
|
-
'type':
|
1336
|
-
'receive_id':
|
1395
|
+
'type': send_params.send_type,
|
1396
|
+
'receive_id': send_params.receive_id,
|
1337
1397
|
'parameter': params
|
1338
1398
|
}
|
1339
1399
|
|
reywechat/rlog.py
CHANGED
@@ -14,7 +14,7 @@ from reykit.ros import Folder, join_path
|
|
14
14
|
|
15
15
|
from .rbase import WeChatBase
|
16
16
|
from .rreceive import WeChatMessage
|
17
|
-
from .rsend import
|
17
|
+
from .rsend import WeChatSendParameters
|
18
18
|
from .rwechat import WeChat
|
19
19
|
|
20
20
|
|
@@ -185,27 +185,27 @@ class WeChatLog(WeChatBase):
|
|
185
185
|
|
186
186
|
def log_send(
|
187
187
|
self,
|
188
|
-
|
188
|
+
send_params: WeChatSendParameters
|
189
189
|
) -> None:
|
190
190
|
"""
|
191
191
|
Log send message.
|
192
192
|
|
193
193
|
Parameters
|
194
194
|
----------
|
195
|
-
|
195
|
+
send_params : `WeChatSendParameters` instance.
|
196
196
|
"""
|
197
197
|
|
198
198
|
# Generate record.
|
199
|
-
content_print = 'SEND | %-20s' %
|
199
|
+
content_print = 'SEND | %-20s' % send_params.receive_id
|
200
200
|
content_file = 'SEND | %s' % {
|
201
|
-
'receive_id':
|
202
|
-
**
|
201
|
+
'receive_id': send_params.receive_id,
|
202
|
+
**send_params.params
|
203
203
|
}
|
204
|
-
if
|
204
|
+
if send_params.exc_reports == []:
|
205
205
|
level = self.rrlog.INFO
|
206
206
|
else:
|
207
207
|
level = self.rrlog.ERROR
|
208
|
-
exc_text = '\n'.join(
|
208
|
+
exc_text = '\n'.join(send_params.exc_reports)
|
209
209
|
content_print = '%s\n%s' % (content_print, exc_text)
|
210
210
|
content_file = '%s\n%s' % (content_file, exc_text)
|
211
211
|
|
reywechat/rreceive.py
CHANGED
@@ -35,8 +35,8 @@ __all__ = (
|
|
35
35
|
)
|
36
36
|
|
37
37
|
|
38
|
-
|
39
|
-
'
|
38
|
+
MessageParametersFile = TypedDict(
|
39
|
+
'MessageParametersFile',
|
40
40
|
{
|
41
41
|
'path': str,
|
42
42
|
'name': str,
|
@@ -44,8 +44,8 @@ MessageParameterFile = TypedDict(
|
|
44
44
|
'size': int
|
45
45
|
}
|
46
46
|
)
|
47
|
-
|
48
|
-
'
|
47
|
+
MessageParameters = TypedDict(
|
48
|
+
'MessageParameters',
|
49
49
|
{
|
50
50
|
'time': int,
|
51
51
|
'id': int,
|
@@ -55,20 +55,20 @@ MessageParameter = TypedDict(
|
|
55
55
|
'type': int,
|
56
56
|
'display': str,
|
57
57
|
'data': str,
|
58
|
-
'file':
|
58
|
+
'file': MessageParametersFile
|
59
59
|
}
|
60
60
|
)
|
61
|
-
|
62
|
-
'
|
61
|
+
MessageShareParameters = TypedDict(
|
62
|
+
'MessageShareParameters',
|
63
63
|
{
|
64
64
|
'name': str | None,
|
65
65
|
'title': str | None,
|
66
|
-
'
|
66
|
+
'desc': str | None,
|
67
67
|
'url': str | None
|
68
68
|
}
|
69
69
|
)
|
70
|
-
|
71
|
-
'
|
70
|
+
MessageQuoteParameters = TypedDict(
|
71
|
+
'MessageQuoteParameters',
|
72
72
|
{
|
73
73
|
'text': str,
|
74
74
|
'quote_id': int,
|
@@ -132,7 +132,7 @@ class WeChatMessage(WeChatBase):
|
|
132
132
|
self.display = display
|
133
133
|
self.data = data
|
134
134
|
self.window = window
|
135
|
-
self.file:
|
135
|
+
self.file: MessageParametersFile | None = None
|
136
136
|
self.trigger_rule: TriggerRule | None = None
|
137
137
|
self.trigger_continue = self.receiver.trigger.continue_
|
138
138
|
self.trigger_break = self.receiver.trigger.break_
|
@@ -164,7 +164,7 @@ class WeChatMessage(WeChatBase):
|
|
164
164
|
|
165
165
|
### Share.
|
166
166
|
self._share_type: int | None = None
|
167
|
-
self._share_params:
|
167
|
+
self._share_params: MessageShareParameters | None = None
|
168
168
|
self._is_file_uploading: bool | None = None
|
169
169
|
self._file_name_uploading: str | None = None
|
170
170
|
self._is_file_uploaded: bool | None = None
|
@@ -206,7 +206,7 @@ class WeChatMessage(WeChatBase):
|
|
206
206
|
|
207
207
|
|
208
208
|
@property
|
209
|
-
def params(self) ->
|
209
|
+
def params(self) -> MessageParameters:
|
210
210
|
"""
|
211
211
|
Return parameters dictionary.
|
212
212
|
|
@@ -216,7 +216,7 @@ class WeChatMessage(WeChatBase):
|
|
216
216
|
"""
|
217
217
|
|
218
218
|
# Handle parameter.
|
219
|
-
params:
|
219
|
+
params: MessageParameters = {
|
220
220
|
'time': self.time,
|
221
221
|
'id': self.id,
|
222
222
|
'number': self.number,
|
@@ -390,8 +390,8 @@ class WeChatMessage(WeChatBase):
|
|
390
390
|
self._text = '[转发聊天记录]'
|
391
391
|
else:
|
392
392
|
self._text = f'[转发"{self.share_params['title']}"]'
|
393
|
-
if self.share_params['
|
394
|
-
self._text += f' {self.share_params['
|
393
|
+
if self.share_params['desc'] is not None:
|
394
|
+
self._text += f' {self.share_params['desc']}'
|
395
395
|
|
396
396
|
### Mini program.
|
397
397
|
elif self.is_mini_program:
|
@@ -435,8 +435,8 @@ class WeChatMessage(WeChatBase):
|
|
435
435
|
self._text = f'[APP"{self.share_params['name']}"分享]'
|
436
436
|
if self.share_params["title"] is not None:
|
437
437
|
self._text += f' {self.share_params["title"]}'
|
438
|
-
if self.share_params["
|
439
|
-
self._text += f' {self.share_params["
|
438
|
+
if self.share_params["desc"] is not None:
|
439
|
+
self._text += f' {self.share_params["desc"]}'
|
440
440
|
|
441
441
|
### Other.
|
442
442
|
else:
|
@@ -446,8 +446,8 @@ class WeChatMessage(WeChatBase):
|
|
446
446
|
self._text = f'["{self.share_params['name']}"分享]'
|
447
447
|
if self.share_params["title"] is not None:
|
448
448
|
self._text += f' {self.share_params["title"]}'
|
449
|
-
if self.share_params["
|
450
|
-
self._text += f' {self.share_params["
|
449
|
+
if self.share_params["desc"] is not None:
|
450
|
+
self._text += f' {self.share_params["desc"]}'
|
451
451
|
|
452
452
|
## Voice call or video call.
|
453
453
|
case 50:
|
@@ -583,7 +583,7 @@ class WeChatMessage(WeChatBase):
|
|
583
583
|
|
584
584
|
|
585
585
|
@property
|
586
|
-
def share_params(self) ->
|
586
|
+
def share_params(self) -> MessageShareParameters:
|
587
587
|
"""
|
588
588
|
Share message parameters.
|
589
589
|
|
@@ -607,14 +607,14 @@ class WeChatMessage(WeChatBase):
|
|
607
607
|
if name is None:
|
608
608
|
name: str | None = search('.*<nickname>([^<>]+)</nickname>', self.data)
|
609
609
|
title: str | None = search('<title>([^<>]+)</title>', self.data)
|
610
|
-
|
611
|
-
if
|
612
|
-
|
610
|
+
desc: str | None = search('.*<des>([^<>]+)</des>', self.data)
|
611
|
+
if desc is None:
|
612
|
+
desc: str | None = search('.*<desc>([^<>]+)</desc>', self.data)
|
613
613
|
url: str | None = search('.*<url>([^<>]+)</url>', self.data)
|
614
|
-
self._share_params:
|
614
|
+
self._share_params: MessageShareParameters = {
|
615
615
|
'name': name,
|
616
616
|
'title': title,
|
617
|
-
'
|
617
|
+
'desc': desc,
|
618
618
|
'url': url
|
619
619
|
}
|
620
620
|
|
@@ -784,7 +784,7 @@ class WeChatMessage(WeChatBase):
|
|
784
784
|
|
785
785
|
|
786
786
|
@property
|
787
|
-
def quote_params(self) ->
|
787
|
+
def quote_params(self) -> MessageQuoteParameters:
|
788
788
|
"""
|
789
789
|
Quote message parameters.
|
790
790
|
|
@@ -826,7 +826,7 @@ class WeChatMessage(WeChatBase):
|
|
826
826
|
quote_user_name: str = search(pattern, self.data)
|
827
827
|
pattern = '<content>([^<>]+)</content>'
|
828
828
|
quote_data: str = search(pattern, self.data)
|
829
|
-
self._quote_params:
|
829
|
+
self._quote_params: MessageQuoteParameters = {
|
830
830
|
'text': text,
|
831
831
|
'quote_id': quote_id,
|
832
832
|
'quote_time': quote_time,
|
@@ -1938,7 +1938,7 @@ class WechatReceiver(WeChatBase):
|
|
1938
1938
|
|
1939
1939
|
# Set parameter.
|
1940
1940
|
cache_file = File(cache_path)
|
1941
|
-
message_file:
|
1941
|
+
message_file: MessageParametersFile = {
|
1942
1942
|
'path': cache_path,
|
1943
1943
|
'name': cache_file.name_suffix,
|
1944
1944
|
'md5': cache_file.md5,
|
reywechat/rsend.py
CHANGED
@@ -27,7 +27,7 @@ from .rwechat import WeChat
|
|
27
27
|
|
28
28
|
__all__ = (
|
29
29
|
'WeChatSendTypeEnum',
|
30
|
-
'
|
30
|
+
'WeChatSendParameters',
|
31
31
|
'WeChatSender'
|
32
32
|
)
|
33
33
|
|
@@ -74,7 +74,7 @@ class WeChatSendStatusEnum(WeChatBase, IntEnum):
|
|
74
74
|
SENT = 2
|
75
75
|
|
76
76
|
|
77
|
-
class
|
77
|
+
class WeChatSendParameters(WeChatBase):
|
78
78
|
"""
|
79
79
|
WeChat send parameters type.
|
80
80
|
"""
|
@@ -285,8 +285,8 @@ class WeChatSender(WeChatBase):
|
|
285
285
|
|
286
286
|
# Set attribute.
|
287
287
|
self.wechat = wechat
|
288
|
-
self.queue: Queue[
|
289
|
-
self.handlers: list[Callable[[
|
288
|
+
self.queue: Queue[WeChatSendParameters] = Queue()
|
289
|
+
self.handlers: list[Callable[[WeChatSendParameters], Any]] = []
|
290
290
|
self.started: bool | None = False
|
291
291
|
|
292
292
|
# Start.
|
@@ -313,17 +313,17 @@ class WeChatSender(WeChatBase):
|
|
313
313
|
case None:
|
314
314
|
break
|
315
315
|
|
316
|
-
|
317
|
-
handle_handler_exception = lambda exc_text, *_:
|
316
|
+
send_params = self.queue.get()
|
317
|
+
handle_handler_exception = lambda exc_text, *_: send_params.exc_reports.append(exc_text)
|
318
318
|
|
319
319
|
## Handler.
|
320
320
|
for handler in self.handlers:
|
321
321
|
handler = wrap_exc(handler, handler=handle_handler_exception)
|
322
|
-
handler(
|
322
|
+
handler(send_params)
|
323
323
|
|
324
324
|
## Send.
|
325
325
|
try:
|
326
|
-
self.__send(
|
326
|
+
self.__send(send_params)
|
327
327
|
|
328
328
|
## Exception.
|
329
329
|
except BaseException:
|
@@ -332,104 +332,104 @@ class WeChatSender(WeChatBase):
|
|
332
332
|
exc_text, *_ = catch_exc()
|
333
333
|
|
334
334
|
# Save.
|
335
|
-
|
335
|
+
send_params.exc_reports.append(exc_text)
|
336
336
|
|
337
|
-
|
337
|
+
send_params.status = WeChatSendStatusEnum.SENT
|
338
338
|
|
339
339
|
## Handler.
|
340
340
|
for handler in self.handlers:
|
341
341
|
handler = wrap_exc(handler, handler=handle_handler_exception)
|
342
|
-
handler(
|
342
|
+
handler(send_params)
|
343
343
|
|
344
344
|
## Log.
|
345
|
-
self.wechat.error.log_send(
|
345
|
+
self.wechat.error.log_send(send_params)
|
346
346
|
|
347
347
|
|
348
348
|
def __send(
|
349
349
|
self,
|
350
|
-
|
350
|
+
send_params: WeChatSendParameters
|
351
351
|
) -> None:
|
352
352
|
"""
|
353
353
|
Send message.
|
354
354
|
|
355
355
|
Parameters
|
356
356
|
----------
|
357
|
-
|
357
|
+
send_params : `WeChatSendParameters` instance.
|
358
358
|
"""
|
359
359
|
|
360
360
|
# Test.
|
361
361
|
if (
|
362
|
-
|
363
|
-
and
|
362
|
+
send_params.params.get('is_test')
|
363
|
+
and send_params.send_type in (WeChatSendTypeEnum.TEXT, WeChatSendTypeEnum.TEXT_AT)
|
364
364
|
):
|
365
|
-
text: str =
|
365
|
+
text: str = send_params.params['text']
|
366
366
|
now_time = now('time_str')
|
367
367
|
modify_text = text.replace(':time:', now_time, 1)
|
368
|
-
|
368
|
+
send_params.params['text'] = modify_text
|
369
369
|
|
370
370
|
# Send.
|
371
|
-
match
|
371
|
+
match send_params.send_type:
|
372
372
|
|
373
373
|
## Text.
|
374
374
|
case WeChatSendTypeEnum.TEXT:
|
375
375
|
self.wechat.client.send_text(
|
376
|
-
|
377
|
-
|
376
|
+
send_params.receive_id,
|
377
|
+
send_params.params['text']
|
378
378
|
)
|
379
379
|
|
380
380
|
## Text with '@'.
|
381
381
|
case WeChatSendTypeEnum.TEXT_AT:
|
382
382
|
self.wechat.client.send_text_at(
|
383
|
-
|
384
|
-
|
385
|
-
|
383
|
+
send_params.receive_id,
|
384
|
+
send_params.params['user_id'],
|
385
|
+
send_params.params['text']
|
386
386
|
)
|
387
387
|
|
388
388
|
## File.
|
389
389
|
case WeChatSendTypeEnum.FILE:
|
390
390
|
self.wechat.client.send_file(
|
391
|
-
|
392
|
-
|
391
|
+
send_params.receive_id,
|
392
|
+
send_params.params['file_path']
|
393
393
|
)
|
394
394
|
|
395
395
|
## Image.
|
396
396
|
case WeChatSendTypeEnum.IMAGE:
|
397
397
|
self.wechat.client.send_image(
|
398
|
-
|
399
|
-
|
398
|
+
send_params.receive_id,
|
399
|
+
send_params.params['file_path']
|
400
400
|
)
|
401
401
|
|
402
402
|
## Emotion.
|
403
403
|
case WeChatSendTypeEnum.EMOTION:
|
404
404
|
self.wechat.client.send_emotion(
|
405
|
-
|
406
|
-
|
405
|
+
send_params.receive_id,
|
406
|
+
send_params.params['file_path']
|
407
407
|
)
|
408
408
|
|
409
409
|
## Pat.
|
410
410
|
case WeChatSendTypeEnum.PAT:
|
411
411
|
self.wechat.client.send_pat(
|
412
|
-
|
413
|
-
|
412
|
+
send_params.receive_id,
|
413
|
+
send_params.params['user_id']
|
414
414
|
)
|
415
415
|
|
416
416
|
## Public account.
|
417
417
|
case WeChatSendTypeEnum.PUBLIC:
|
418
418
|
self.wechat.client.send_public(
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
419
|
+
send_params.receive_id,
|
420
|
+
send_params.params['page_url'],
|
421
|
+
send_params.params['title'],
|
422
|
+
send_params.params['text'],
|
423
|
+
send_params.params['image_url'],
|
424
|
+
send_params.params['public_name'],
|
425
|
+
send_params.params['public_id']
|
426
426
|
)
|
427
427
|
|
428
428
|
## Forward.
|
429
429
|
case WeChatSendTypeEnum.FORWARD:
|
430
430
|
self.wechat.client.send_forward(
|
431
|
-
|
432
|
-
|
431
|
+
send_params.receive_id,
|
432
|
+
send_params.params['message_id']
|
433
433
|
)
|
434
434
|
|
435
435
|
## Throw exception.
|
@@ -523,38 +523,38 @@ class WeChatSender(WeChatBase):
|
|
523
523
|
"""
|
524
524
|
|
525
525
|
# Handle parameter.
|
526
|
-
|
526
|
+
send_params = WeChatSendParameters(
|
527
527
|
self,
|
528
528
|
send_type,
|
529
529
|
receive_id,
|
530
530
|
**params
|
531
531
|
)
|
532
|
-
|
533
|
-
handle_handler_exception = lambda exc_text, *_:
|
532
|
+
send_params.status = WeChatSendStatusEnum.INIT
|
533
|
+
handle_handler_exception = lambda exc_text, *_: send_params.exc_reports.append(exc_text)
|
534
534
|
|
535
535
|
# Handler.
|
536
536
|
for handler in self.handlers:
|
537
537
|
handler = wrap_exc(handler, handler=handle_handler_exception)
|
538
|
-
handler(
|
538
|
+
handler(send_params)
|
539
539
|
|
540
540
|
# Insert.
|
541
|
-
self.wechat.database._insert_send(
|
541
|
+
self.wechat.database._insert_send(send_params)
|
542
542
|
|
543
543
|
|
544
544
|
def add_handler(
|
545
545
|
self,
|
546
|
-
handler: Callable[[
|
546
|
+
handler: Callable[[WeChatSendParameters], Any]
|
547
547
|
) -> None:
|
548
548
|
"""
|
549
549
|
Add send handler function.
|
550
550
|
Call at the after initialization, before inserting into the database queue.
|
551
551
|
Call at the after get from database queue, before sending.
|
552
552
|
Call at the after sending.
|
553
|
-
Can be use `
|
553
|
+
Can be use `WeChatSendParameters.status` judge status.
|
554
554
|
|
555
555
|
Parameters
|
556
556
|
----------
|
557
|
-
handler : Handler method, input parameter is `
|
557
|
+
handler : Handler method, input parameter is `WeChatSendParameters` instance.
|
558
558
|
"""
|
559
559
|
|
560
560
|
# Add.
|
@@ -3,14 +3,14 @@ reywechat/rall.py,sha256=5J_X-XMOyb1Vp1jyS9-oRFXGOtp2vRPX1g3tJot_Eck,371
|
|
3
3
|
reywechat/rbase.py,sha256=hbxn5spvcl_C_Bw8A9teulOXT9GMlxUw145_YbXIOzc,1124
|
4
4
|
reywechat/rcache.py,sha256=7UsHHfgFOgxuSqlTSAO6CprgUUOeBCXYus0kxmRBQxk,908
|
5
5
|
reywechat/rclient.py,sha256=lc1CPle9h08mwP8NlJN0ybzcNJxtpV0ma6q6cz1RIxk,22518
|
6
|
-
reywechat/rdb.py,sha256=
|
7
|
-
reywechat/rlog.py,sha256=
|
8
|
-
reywechat/rreceive.py,sha256=
|
9
|
-
reywechat/rsend.py,sha256=
|
6
|
+
reywechat/rdb.py,sha256=PBa1t426RS4FCGifn9em07RJIvjM_t7ZxIqM-qcPLas,51257
|
7
|
+
reywechat/rlog.py,sha256=TSA-_5pwlq0sUND2cnLDqXvdmAdMAkC7tXIz3WfJ7Xw,5259
|
8
|
+
reywechat/rreceive.py,sha256=74Re0rrNXPJ2idTUP69eK0wT93pGEN1c39pzyzctHa8,51236
|
9
|
+
reywechat/rsend.py,sha256=BB42r24x37V1tb27HLhnB_2tILv-DW26F9QbhqiNes8,20101
|
10
10
|
reywechat/rtrigger.py,sha256=WdOQwobPdGPyyE9J-qtQFPd60713T0aWqKk02PLdCRE,4966
|
11
11
|
reywechat/rwechat.py,sha256=g0pbprMPv_qWb_lGFrPDAWsJO4vPSIgFLkw0Y28CZUo,4751
|
12
12
|
reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
|
13
|
-
reywechat-1.0.
|
14
|
-
reywechat-1.0.
|
15
|
-
reywechat-1.0.
|
16
|
-
reywechat-1.0.
|
13
|
+
reywechat-1.0.65.dist-info/METADATA,sha256=Bm--OclsJue34HoWpUOC05GI0A8nldGY8RcXa_yebJI,1551
|
14
|
+
reywechat-1.0.65.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
reywechat-1.0.65.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
16
|
+
reywechat-1.0.65.dist-info/RECORD,,
|
File without changes
|
File without changes
|