reywechat 1.0.47__py3-none-any.whl → 1.0.49__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/__init__.py CHANGED
@@ -16,11 +16,10 @@ Modules
16
16
  rall : All methods.
17
17
  rbase : Base methods.
18
18
  rclient : Client methods.
19
- rdb : WeChatDatabase methods.
19
+ rdb : Database methods.
20
20
  rcache : Cache methods.
21
21
  rlog : Log methods.
22
22
  rreceive : Receive methods.
23
- rschedule : Schedule methods.
24
23
  rsend : Send methods.
25
24
  rtrigger : Trigger methods.
26
25
  rwechat : WeChat methods.
reywechat/rall.py CHANGED
@@ -15,7 +15,6 @@ from .rclient import *
15
15
  from .rdb import *
16
16
  from .rlog import *
17
17
  from .rreceive import *
18
- from .rschedule import *
19
18
  from .rsend import *
20
19
  from .rtrigger import *
21
20
  from .rwechat import *
reywechat/rbase.py CHANGED
@@ -13,7 +13,7 @@ from reykit.rbase import Base, Error, Exit
13
13
 
14
14
 
15
15
  __all__ = (
16
- 'BaseWeChat',
16
+ 'WeChatBase',
17
17
  'WeChatError',
18
18
  'WeChatClientErorr',
19
19
  'WeChatTriggerError',
@@ -22,19 +22,19 @@ __all__ = (
22
22
  )
23
23
 
24
24
 
25
- class BaseWeChat(Base):
25
+ class WeChatBase(Base):
26
26
  """
27
27
  WeChat Base type.
28
28
  """
29
29
 
30
30
 
31
- class WeChatError(BaseWeChat, Error):
31
+ class WeChatError(WeChatBase, Error):
32
32
  """
33
33
  WeChat error type.
34
34
  """
35
35
 
36
36
 
37
- class WeChatExit(BaseWeChat, Exit):
37
+ class WeChatExit(WeChatBase, Exit):
38
38
  """
39
39
  WeChat exit type.
40
40
  """
reywechat/rcache.py CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  from reykit.ros import FileCache, join_path
13
13
 
14
- from .rbase import BaseWeChat
14
+ from .rbase import WeChatBase
15
15
  from .rwechat import WeChat
16
16
 
17
17
 
@@ -20,7 +20,7 @@ __all__ = (
20
20
  )
21
21
 
22
22
 
23
- class WeChatCache(BaseWeChat, FileCache):
23
+ class WeChatCache(WeChatBase, FileCache):
24
24
  """
25
25
  WeChat file cache type.
26
26
  """
reywechat/rclient.py CHANGED
@@ -17,7 +17,7 @@ from reykit.ros import find_relpath
17
17
  from reykit.rsys import run_cmd, search_process, memory_read, memory_write, popup_select
18
18
  from reykit.rtime import wait
19
19
 
20
- from .rbase import BaseWeChat, WeChatClientErorr
20
+ from .rbase import WeChatBase, WeChatClientErorr
21
21
  from .rwechat import WeChat
22
22
 
23
23
 
@@ -42,7 +42,7 @@ CLIENT_VERSION_MEMORY_OFFSETS = (
42
42
  )
43
43
 
44
44
 
45
- class WeChatClient(BaseWeChat):
45
+ class WeChatClient(WeChatBase):
46
46
  """
47
47
  WeChat client type.
48
48
  """
@@ -348,7 +348,7 @@ class WeChatClient(BaseWeChat):
348
348
  - `Key 'head_image'`: Head image URL.
349
349
  - `Key 'account_data_path'`: Current account data save path.
350
350
  - `Key 'wechat_data_path'`: WeChat data save path.
351
- - `Key 'decrypt_key'`: WeChatDatabase decrypt key.
351
+ - `Key 'decrypt_key'`: Database decrypt key.
352
352
  """
353
353
 
354
354
  # Handle parameter.
reywechat/rdb.py CHANGED
@@ -5,11 +5,11 @@
5
5
  @Time : 2023-10-23 20:55:58
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
- @Explain : WeChatDatabase methods.
8
+ @Explain : Database methods.
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Literal, overload
12
+ from typing import Literal
13
13
  from json import loads as json_loads
14
14
  from reydb.rdb import Database
15
15
  from reykit.rbase import throw
@@ -17,7 +17,7 @@ from reykit.ros import File
17
17
  from reykit.rtime import to_time, time_to, sleep
18
18
  from reykit.rwrap import wrap_thread
19
19
 
20
- from .rbase import BaseWeChat
20
+ from .rbase import WeChatBase
21
21
  from .rreceive import WeChatMessage
22
22
  from .rsend import WeChatSendTypeEnum, WeChatSendParameter
23
23
  from .rwechat import WeChat
@@ -28,7 +28,7 @@ __all__ = (
28
28
  )
29
29
 
30
30
 
31
- class WeChatDatabase(BaseWeChat):
31
+ class WeChatDatabase(WeChatBase):
32
32
  """
33
33
  WeChat database type.
34
34
  Can create database used `self.build` method.
@@ -96,14 +96,14 @@ class WeChatDatabase(BaseWeChat):
96
96
  self.__start_from_message_send()
97
97
 
98
98
 
99
- def build(self) -> None:
99
+ def build_db(self) -> None:
100
100
  """
101
101
  Check and build all standard databases and tables, by `self.db_names`.
102
102
  """
103
103
 
104
104
  # Set parameter.
105
105
 
106
- ## WeChatDatabase.
106
+ ## Database.
107
107
  databases = [
108
108
  {
109
109
  'name': self.db_names['wechat']
@@ -444,7 +444,7 @@ class WeChatDatabase(BaseWeChat):
444
444
  'path': (self.db_names['wechat'], self.db_names['wechat.stats']),
445
445
  'items': [
446
446
  {
447
- 'name': 'count_receive',
447
+ 'name': 'receive_count',
448
448
  'select': (
449
449
  'SELECT COUNT(1)\n'
450
450
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
@@ -452,7 +452,7 @@ class WeChatDatabase(BaseWeChat):
452
452
  'comment': 'Message receive count.'
453
453
  },
454
454
  {
455
- 'name': 'count_send',
455
+ 'name': 'send_count',
456
456
  'select': (
457
457
  'SELECT COUNT(1)\n'
458
458
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
@@ -461,7 +461,7 @@ class WeChatDatabase(BaseWeChat):
461
461
  'comment': 'Message send count.'
462
462
  },
463
463
  {
464
- 'name': 'count_user',
464
+ 'name': 'user_count',
465
465
  'select': (
466
466
  'SELECT COUNT(1)\n'
467
467
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
@@ -469,7 +469,7 @@ class WeChatDatabase(BaseWeChat):
469
469
  'comment': 'Contact user count.'
470
470
  },
471
471
  {
472
- 'name': 'count_room',
472
+ 'name': 'room_count',
473
473
  'select': (
474
474
  'SELECT COUNT(1)\n'
475
475
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
@@ -477,7 +477,7 @@ class WeChatDatabase(BaseWeChat):
477
477
  'comment': 'Contact room count.'
478
478
  },
479
479
  {
480
- 'name': 'count_room_user',
480
+ 'name': 'room_user_count',
481
481
  'select': (
482
482
  'SELECT COUNT(1)\n'
483
483
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
@@ -485,7 +485,142 @@ class WeChatDatabase(BaseWeChat):
485
485
  'comment': 'Contact room user count.'
486
486
  },
487
487
  {
488
- 'name': 'last_time_receive',
488
+ 'name': 'past_day_receive_count',
489
+ 'select': (
490
+ 'SELECT COUNT(1)\n'
491
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
492
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) = 0'
493
+ ),
494
+ 'comment': 'Message receive count in the past day.'
495
+ },
496
+ {
497
+ 'name': 'past_day_send_count',
498
+ 'select': (
499
+ 'SELECT COUNT(1)\n'
500
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`'
501
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) = 0'
502
+ ),
503
+ 'comment': 'Message send count in the past day.'
504
+ },
505
+ {
506
+ 'name': 'past_day_user_count',
507
+ 'select': (
508
+ 'SELECT COUNT(1)\n'
509
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
510
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) = 0'
511
+ ),
512
+ 'comment': 'Contact user count in the past day.'
513
+ },
514
+ {
515
+ 'name': 'past_day_room_count',
516
+ 'select': (
517
+ 'SELECT COUNT(1)\n'
518
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
519
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) = 0'
520
+ ),
521
+ 'comment': 'Contact room count in the past day.'
522
+ },
523
+ {
524
+ 'name': 'past_day_room_user_count',
525
+ 'select': (
526
+ 'SELECT COUNT(1)\n'
527
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
528
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) = 0'
529
+ ),
530
+ 'comment': 'Contact room user count in the past day.'
531
+ },
532
+ {
533
+ 'name': 'past_week_receive_count',
534
+ 'select': (
535
+ 'SELECT COUNT(1)\n'
536
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
537
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 6'
538
+ ),
539
+ 'comment': 'Message receive count in the past week.'
540
+ },
541
+ {
542
+ 'name': 'past_week_send_count',
543
+ 'select': (
544
+ 'SELECT COUNT(1)\n'
545
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`'
546
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 6'
547
+ ),
548
+ 'comment': 'Message send count in the past week.'
549
+ },
550
+ {
551
+ 'name': 'past_week_user_count',
552
+ 'select': (
553
+ 'SELECT COUNT(1)\n'
554
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
555
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 6'
556
+ ),
557
+ 'comment': 'Contact user count in the past week.'
558
+ },
559
+ {
560
+ 'name': 'past_week_room_count',
561
+ 'select': (
562
+ 'SELECT COUNT(1)\n'
563
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
564
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 6'
565
+ ),
566
+ 'comment': 'Contact room count in the past week.'
567
+ },
568
+ {
569
+ 'name': 'past_week_room_user_count',
570
+ 'select': (
571
+ 'SELECT COUNT(1)\n'
572
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
573
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 6'
574
+ ),
575
+ 'comment': 'Contact room user count in the past week.'
576
+ },
577
+ {
578
+ 'name': 'past_month_receive_count',
579
+ 'select': (
580
+ 'SELECT COUNT(1)\n'
581
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
582
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 29'
583
+ ),
584
+ 'comment': 'Message receive count in the past month.'
585
+ },
586
+ {
587
+ 'name': 'past_month_send_count',
588
+ 'select': (
589
+ 'SELECT COUNT(1)\n'
590
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`'
591
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 29'
592
+ ),
593
+ 'comment': 'Message send count in the past month.'
594
+ },
595
+ {
596
+ 'name': 'past_month_user_count',
597
+ 'select': (
598
+ 'SELECT COUNT(1)\n'
599
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
600
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 29'
601
+ ),
602
+ 'comment': 'Contact user count in the past month.'
603
+ },
604
+ {
605
+ 'name': 'past_month_room_count',
606
+ 'select': (
607
+ 'SELECT COUNT(1)\n'
608
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
609
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 29'
610
+ ),
611
+ 'comment': 'Contact room count in the past month.'
612
+ },
613
+ {
614
+ 'name': 'past_month_room_user_count',
615
+ 'select': (
616
+ 'SELECT COUNT(1)\n'
617
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
618
+ 'WHERE TIMESTAMPDIFF(DAY, `create_time`, NOW()) <= 29'
619
+ ),
620
+ 'comment': 'Contact room user count in the past month.'
621
+ },
622
+ {
623
+ 'name': 'receive_last_time',
489
624
  'select': (
490
625
  'SELECT MAX(`message_time`)\n'
491
626
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
@@ -493,7 +628,7 @@ class WeChatDatabase(BaseWeChat):
493
628
  'comment': 'Message last receive time.'
494
629
  },
495
630
  {
496
- 'name': 'last_time_send',
631
+ 'name': 'send_last_time',
497
632
  'select': (
498
633
  'SELECT MAX(`status_time`)\n'
499
634
  f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
@@ -502,6 +637,7 @@ class WeChatDatabase(BaseWeChat):
502
637
  'comment': 'Message last send time.'
503
638
  }
504
639
  ]
640
+
505
641
  }
506
642
 
507
643
  ]
@@ -512,7 +648,7 @@ class WeChatDatabase(BaseWeChat):
512
648
  self.database_wechat.build.build(databases, tables, views_stats=views_stats)
513
649
 
514
650
  ## File.
515
- self.database_file.file.build()
651
+ self.database_file.file.build_db()
516
652
 
517
653
  # Update.
518
654
  self.update_contact_user()
reywechat/rlog.py CHANGED
@@ -12,7 +12,7 @@
12
12
  from reykit.rlog import Log
13
13
  from reykit.ros import Folder, join_path
14
14
 
15
- from .rbase import BaseWeChat
15
+ from .rbase import WeChatBase
16
16
  from .rreceive import WeChatMessage
17
17
  from .rsend import WeChatSendParameter
18
18
  from .rwechat import WeChat
@@ -23,7 +23,7 @@ __all__ = (
23
23
  )
24
24
 
25
25
 
26
- class WeChatLog(BaseWeChat):
26
+ class WeChatLog(WeChatBase):
27
27
  """
28
28
  WeChat log type.
29
29
  """
@@ -163,9 +163,9 @@ class WeChatLog(BaseWeChat):
163
163
  level = self.rrlog.INFO
164
164
  else:
165
165
  level = self.rrlog.ERROR
166
- exc_report = '\n'.join(message.exc_reports)
167
- content_print = '%s\n%s' % (content_print, exc_report)
168
- content_file = '%s\n%s' % (content_file, exc_report)
166
+ exc_text = '\n'.join(message.exc_reports)
167
+ content_print = '%s\n%s' % (content_print, exc_text)
168
+ content_file = '%s\n%s' % (content_file, exc_text)
169
169
 
170
170
  ## Add color.
171
171
  if self.rrlog.print_colour:
@@ -205,9 +205,9 @@ class WeChatLog(BaseWeChat):
205
205
  level = self.rrlog.INFO
206
206
  else:
207
207
  level = self.rrlog.ERROR
208
- exc_report = '\n'.join(send_param.exc_reports)
209
- content_print = '%s\n%s' % (content_print, exc_report)
210
- content_file = '%s\n%s' % (content_file, exc_report)
208
+ exc_text = '\n'.join(send_param.exc_reports)
209
+ content_print = '%s\n%s' % (content_print, exc_text)
210
+ content_file = '%s\n%s' % (content_file, exc_text)
211
211
 
212
212
  ## Add color.
213
213
  if self.rrlog.print_colour:
reywechat/rreceive.py CHANGED
@@ -26,7 +26,7 @@ from reykit.rtask import ThreadPool
26
26
  from reykit.rtime import now, sleep, wait, to_time, time_to
27
27
  from reykit.rwrap import wrap_thread, wrap_exc
28
28
 
29
- from .rbase import BaseWeChat, WeChatTriggerError
29
+ from .rbase import WeChatBase, WeChatTriggerError
30
30
  from .rsend import WeChatSendTypeEnum
31
31
  from .rwechat import WeChat
32
32
 
@@ -62,7 +62,7 @@ MessageParameter = TypedDict(
62
62
  )
63
63
 
64
64
 
65
- class WeChatMessage(BaseWeChat):
65
+ class WeChatMessage(WeChatBase):
66
66
  """
67
67
  WeChat message type.
68
68
  """
@@ -1090,7 +1090,7 @@ class WeChatMessage(BaseWeChat):
1090
1090
  )
1091
1091
 
1092
1092
 
1093
- class WechatReceiver(BaseWeChat):
1093
+ class WechatReceiver(WeChatBase):
1094
1094
  """
1095
1095
  WeChat receiver type.
1096
1096
  """
@@ -1220,17 +1220,17 @@ class WechatReceiver(BaseWeChat):
1220
1220
  # Handle.
1221
1221
 
1222
1222
  ## Define.
1223
- def handle_handler_exception(exc_report, *_) -> None:
1223
+ def handle_handler_exception(exc_text, *_) -> None:
1224
1224
  """
1225
1225
  Handle Handler exception.
1226
1226
 
1227
1227
  Parameters
1228
1228
  ----------
1229
- exc_report : Exception report text.
1229
+ exc_text : Exception report text.
1230
1230
  """
1231
1231
 
1232
1232
  # Save.
1233
- message.exc_reports.append(exc_report)
1233
+ message.exc_reports.append(exc_text)
1234
1234
 
1235
1235
 
1236
1236
  ## Loop.
reywechat/rsend.py CHANGED
@@ -21,7 +21,7 @@ from reykit.rre import sub
21
21
  from reykit.rtime import now, sleep
22
22
  from reykit.rwrap import wrap_thread, wrap_exc
23
23
 
24
- from .rbase import BaseWeChat, WeChatTriggerContinueExit, WeChatTriggerBreakExit
24
+ from .rbase import WeChatBase, WeChatTriggerContinueExit, WeChatTriggerBreakExit
25
25
  from .rwechat import WeChat
26
26
 
27
27
 
@@ -32,7 +32,7 @@ __all__ = (
32
32
  )
33
33
 
34
34
 
35
- class WeChatSendTypeEnum(BaseWeChat, IntEnum):
35
+ class WeChatSendTypeEnum(WeChatBase, IntEnum):
36
36
  """
37
37
  WeChat send type enumeration type.
38
38
 
@@ -58,13 +58,13 @@ class WeChatSendTypeEnum(BaseWeChat, IntEnum):
58
58
  FORWARD = 7
59
59
 
60
60
 
61
- class WeChatSendStatusEnum(BaseWeChat, IntEnum):
61
+ class WeChatSendStatusEnum(WeChatBase, IntEnum):
62
62
  """
63
63
  WeChat send status enumeration type.
64
64
 
65
65
  Attributes
66
66
  ----------
67
- INIT : After initialization, before inserting into database queue.
67
+ INIT : After initialization, before inserting into the database queue.
68
68
  WAIT : After get from database queue, before sending.
69
69
  SENT : After sending.
70
70
  """
@@ -74,7 +74,7 @@ class WeChatSendStatusEnum(BaseWeChat, IntEnum):
74
74
  SENT = 2
75
75
 
76
76
 
77
- class WeChatSendParameter(BaseWeChat):
77
+ class WeChatSendParameter(WeChatBase):
78
78
  """
79
79
  WeChat send parameters type.
80
80
  """
@@ -181,7 +181,7 @@ class WeChatSendParameter(BaseWeChat):
181
181
  - `Literal[WeChatSendTypeEnum.FORWARD]`: Forward message, use `WeChatClient.send_forward`: method.
182
182
  receive_id : User ID or chat room ID of receive message.
183
183
  send_id : Send ID of database.
184
- - `None`: Not inserted into database.
184
+ - `None`: Not inserted into the database.
185
185
  params : Send parameters.
186
186
  """
187
187
 
@@ -195,7 +195,7 @@ class WeChatSendParameter(BaseWeChat):
195
195
  self.status: WeChatSendStatusEnum
196
196
 
197
197
 
198
- class WeChatSender(BaseWeChat):
198
+ class WeChatSender(WeChatBase):
199
199
  """
200
200
  WeChat sender type.
201
201
 
@@ -247,7 +247,7 @@ class WeChatSender(BaseWeChat):
247
247
  break
248
248
 
249
249
  send_param = self.queue.get()
250
- handle_handler_exception = lambda exc_report, *_: send_param.exc_reports.append(exc_report)
250
+ handle_handler_exception = lambda exc_text, *_: send_param.exc_reports.append(exc_text)
251
251
 
252
252
  ## Handler.
253
253
  for handler in self.handlers:
@@ -259,13 +259,13 @@ class WeChatSender(BaseWeChat):
259
259
  self.__send(send_param)
260
260
 
261
261
  ## Exception.
262
- except:
262
+ except BaseException:
263
263
 
264
264
  # Catch exception.
265
- exc_report, *_ = catch_exc()
265
+ exc_text, *_ = catch_exc()
266
266
 
267
267
  # Save.
268
- send_param.exc_reports.append(exc_report)
268
+ send_param.exc_reports.append(exc_text)
269
269
 
270
270
  send_param.status = send_param.StatusEnum.SENT
271
271
 
@@ -463,7 +463,7 @@ class WeChatSender(BaseWeChat):
463
463
  **params
464
464
  )
465
465
  send_param.status = send_param.StatusEnum.INIT
466
- handle_handler_exception = lambda exc_report, *_: send_param.exc_reports.append(exc_report)
466
+ handle_handler_exception = lambda exc_text, *_: send_param.exc_reports.append(exc_text)
467
467
 
468
468
  # Handler.
469
469
  for handler in self.handlers:
@@ -480,7 +480,7 @@ class WeChatSender(BaseWeChat):
480
480
  ) -> None:
481
481
  """
482
482
  Add send handler function.
483
- Call at the after initialization, before inserting into database queue.
483
+ Call at the after initialization, before inserting into the database queue.
484
484
  Call at the after get from database queue, before sending.
485
485
  Call at the after sending.
486
486
  Can be use `WeChatSendParameter.status` judge status.
@@ -582,18 +582,18 @@ class WeChatSender(BaseWeChat):
582
582
  *arg,
583
583
  **kwargs
584
584
  )
585
- except:
586
- *_, exc_instance, _ = catch_exc()
585
+ except BaseException:
586
+ *_, exc, _ = catch_exc()
587
587
 
588
588
  # Report.
589
589
  if not isinstance(
590
- exc_instance,
590
+ exc,
591
591
  (WeChatTriggerContinueExit, WeChatTriggerBreakExit)
592
592
  ):
593
593
  text = '\n'.join(
594
594
  [
595
595
  str(arg)
596
- for arg in exc_instance.args
596
+ for arg in exc.args
597
597
  ]
598
598
  )
599
599
  for receive_id in receive_ids:
reywechat/rtrigger.py CHANGED
@@ -13,7 +13,7 @@ from typing import Any, TypedDict, NoReturn
13
13
  from collections.abc import Callable
14
14
  from reykit.rbase import catch_exc
15
15
 
16
- from .rbase import BaseWeChat, WeChatTriggerContinueExit, WeChatTriggerBreakExit
16
+ from .rbase import WeChatBase, WeChatTriggerContinueExit, WeChatTriggerBreakExit
17
17
  from .rreceive import WeChatMessage, WechatReceiver
18
18
 
19
19
 
@@ -25,7 +25,7 @@ __all__ = (
25
25
  TriggerRule = TypedDict('TriggerRule', {'level': float, 'execute': Callable[[WeChatMessage], None], 'is_reply': bool})
26
26
 
27
27
 
28
- class WeChatTrigger(BaseWeChat):
28
+ class WeChatTrigger(WeChatBase):
29
29
  """
30
30
  WeChat trigger type.
31
31
  """
@@ -98,13 +98,13 @@ class WeChatTrigger(BaseWeChat):
98
98
  break
99
99
 
100
100
  # Exception.
101
- except:
101
+ except BaseException:
102
102
 
103
103
  ## Catch exception.
104
- exc_report, *_ = catch_exc()
104
+ exc_text, *_ = catch_exc()
105
105
 
106
106
  ## Save.
107
- message.exc_reports.append(exc_report)
107
+ message.exc_reports.append(exc_text)
108
108
 
109
109
  finally:
110
110
  message.trigger_rule = None
reywechat/rwechat.py CHANGED
@@ -14,7 +14,7 @@ from os import getcwd as os_getcwd
14
14
  from reydb.rdb import Database
15
15
  from reykit.rbase import block
16
16
 
17
- from .rbase import BaseWeChat
17
+ from .rbase import WeChatBase
18
18
 
19
19
 
20
20
  __all__ = (
@@ -22,7 +22,7 @@ __all__ = (
22
22
  )
23
23
 
24
24
 
25
- class WeChat(BaseWeChat):
25
+ class WeChat(WeChatBase):
26
26
  """
27
27
  WeChat type.
28
28
 
@@ -69,7 +69,6 @@ class WeChat(BaseWeChat):
69
69
  from .rdb import WeChatDatabase
70
70
  from .rlog import WeChatLog
71
71
  from .rreceive import WechatReceiver
72
- from .rschedule import WeChatSchedule
73
72
  from .rsend import WeChatSender
74
73
 
75
74
  # Set attribute.
@@ -83,7 +82,6 @@ class WeChat(BaseWeChat):
83
82
  self.trigger = self.receiver.trigger
84
83
  self.sender = WeChatSender(self)
85
84
  self.database = WeChatDatabase(self, database)
86
- self.schedule = WeChatSchedule(self)
87
85
 
88
86
  ## Client.
89
87
  self.client_version = self.client.client_version
@@ -109,12 +107,7 @@ class WeChat(BaseWeChat):
109
107
  self.wrap_try_send = self.sender.wrap_try_send
110
108
 
111
109
  ## Database.
112
- self.database_build = self.database.build
113
-
114
- ## Schedule.
115
- self.schedule_add_task = self.schedule.add_task
116
- self.schedule_pause = self.schedule.pause
117
- self.schedule_resume = self.schedule.resume
110
+ self.database_build = self.database.build_db
118
111
 
119
112
 
120
113
  def start(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.47
3
+ Version: 1.0.49
4
4
  Summary: WeChat method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reywechat/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -0,0 +1,16 @@
1
+ reywechat/__init__.py,sha256=FXc3XSiPLLmz9bgZdiYKxeWX-7VT9RqPc_EkXp3Kk0I,476
2
+ reywechat/rall.py,sha256=5J_X-XMOyb1Vp1jyS9-oRFXGOtp2vRPX1g3tJot_Eck,371
3
+ reywechat/rbase.py,sha256=hbxn5spvcl_C_Bw8A9teulOXT9GMlxUw145_YbXIOzc,1124
4
+ reywechat/rcache.py,sha256=7UsHHfgFOgxuSqlTSAO6CprgUUOeBCXYus0kxmRBQxk,908
5
+ reywechat/rclient.py,sha256=lc1CPle9h08mwP8NlJN0ybzcNJxtpV0ma6q6cz1RIxk,22518
6
+ reywechat/rdb.py,sha256=9WI0sxMscGMu-PnXKGxHThoO-kr2v8VPqQbxbZdjedw,47334
7
+ reywechat/rlog.py,sha256=4EsTgrgC05JvWeKAucUaWGga638CRRJISJN6qncBCAw,5249
8
+ reywechat/rreceive.py,sha256=dVKCGv6oTrmMK-v_zf5j0Zr04p0r2kbkWWAnkFYBuSY,36181
9
+ reywechat/rsend.py,sha256=GTMAe-w8j8vEqxoqjFEb0tEg8z1qf3RtJyZgckVgvW4,17994
10
+ reywechat/rtrigger.py,sha256=WdOQwobPdGPyyE9J-qtQFPd60713T0aWqKk02PLdCRE,4966
11
+ reywechat/rwechat.py,sha256=sqXihPPXskWt34JyiUhnGZf055KhZxX-8qwf5VWpc1w,4599
12
+ reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
13
+ reywechat-1.0.49.dist-info/METADATA,sha256=c4PE8b1oGVMSBM2b8p5nIziHb5Dd9TAfEyzZa6kIlzA,1551
14
+ reywechat-1.0.49.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ reywechat-1.0.49.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
+ reywechat-1.0.49.dist-info/RECORD,,
reywechat/rschedule.py DELETED
@@ -1,93 +0,0 @@
1
- # !/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @Time : 2024-01-09 21:47:02
6
- @Author : Rey
7
- @Contact : reyxbo@163.com
8
- @Explain : Schedule methods.
9
- """
10
-
11
-
12
- from __future__ import annotations
13
- from typing import Any, Literal
14
- from collections.abc import Callable
15
- from reykit.rschedule import Schedule
16
-
17
- from .rbase import BaseWeChat
18
- from .rsend import WeChatSendTypeEnum
19
- from .rwechat import WeChat
20
-
21
-
22
- class WeChatSchedule(BaseWeChat):
23
- """
24
- WeChat schedule type.
25
- """
26
-
27
- TypeEnum = WeChatSendTypeEnum
28
-
29
-
30
- def __init__(
31
- self,
32
- wechat: WeChat
33
- ) -> None:
34
- """
35
- Build instance attributes.
36
-
37
- Parameters
38
- ----------
39
- wechat : `WeChatClient` instance.
40
- """
41
-
42
- # Set attribute.
43
- self.wechat = wechat
44
- self.rrschedule = Schedule()
45
-
46
- # Start.
47
- self.rrschedule.start()
48
-
49
-
50
- def add_task(
51
- self,
52
- trigger: Literal['date', 'interval', 'cron'],
53
- task: Callable[[WeChatSchedule], Any],
54
- **trigger_kwargs: Any
55
- ) -> None:
56
- """
57
- Add schedule send message task.
58
-
59
- Parameters
60
- ----------
61
- trigger : Trigger type.
62
- task : Function of task. The parameter is the `WeChatSchedule` instance.
63
- trigger_kwargs : Trigger keyword arguments.
64
- """
65
-
66
- # Handle parameter.
67
- args = (self,)
68
-
69
- # Add.
70
- self.rrschedule.add_task(
71
- task,
72
- trigger,
73
- args,
74
- **trigger_kwargs
75
- )
76
-
77
-
78
- def pause(self) -> None:
79
- """
80
- Pause scheduler.
81
- """
82
-
83
- # Pause.
84
- self.rrschedule.pause()
85
-
86
-
87
- def resume(self) -> None:
88
- """
89
- Resume scheduler.
90
- """
91
-
92
- # Pause.
93
- self.rrschedule.resume
@@ -1,17 +0,0 @@
1
- reywechat/__init__.py,sha256=BL4PUpTguszJ612qsZf4-sOXxRIsiYRQ_m__FGMd1RQ,513
2
- reywechat/rall.py,sha256=zEW-mLL2uP8aT2_foCMFGmMi_3RCrGl8qutnSVkmY1E,397
3
- reywechat/rbase.py,sha256=0NunIUIXra2ML2N6odwMk5oENTE0r6VSBHWXUvgI-lc,1124
4
- reywechat/rcache.py,sha256=Hh_HE-t_KUMlrz4gEFPh1AjmhnrSgH520IFJPumWb7A,908
5
- reywechat/rclient.py,sha256=MEvQB3pHb5ORukKbKntalRtFcKIOP9BGtDsMt5ihQfM,22524
6
- reywechat/rdb.py,sha256=akIQsx4CZIt-H6kXWn2vpUYjo5MgD8MluzBMnSdmLaM,40051
7
- reywechat/rlog.py,sha256=IJL2WquiOYfB9iEai9xjojkuxPxiRHkdzZ5vCeaSA98,5261
8
- reywechat/rreceive.py,sha256=dr_it4xJpohzoy0HJfcPheVBqgJcUZAksH-t6zaXT6U,36187
9
- reywechat/rschedule.py,sha256=X9kreXdClTeItJHmNPJNqb_lct-BiLCyusMQxsj5hWU,1865
10
- reywechat/rsend.py,sha256=U2YQx0bqmQwzWogbXxjaATh_2TvjnbLd4O3dkCQhaIg,17993
11
- reywechat/rtrigger.py,sha256=n8kUNovh62r7crlXrp33uaKvbILT-wcfvUqeyGt7YhM,4956
12
- reywechat/rwechat.py,sha256=OcElINAi9jM-eDb_OTtseBW3kyG_3jD4V4QmltR6MeE,4874
13
- reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
14
- reywechat-1.0.47.dist-info/METADATA,sha256=nDuY1qNlRvga5LFUJEhWB0offK0UlWA5OP5KjeRDXWU,1551
15
- reywechat-1.0.47.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- reywechat-1.0.47.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
- reywechat-1.0.47.dist-info/RECORD,,