reywechat 1.0.38__py3-none-any.whl → 1.0.40__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 CHANGED
@@ -31,6 +31,7 @@ __all__ = (
31
31
  class WeChatDatabase(BaseWeChat):
32
32
  """
33
33
  WeChat database type.
34
+ Can create database used `self.build` method.
34
35
  """
35
36
 
36
37
 
@@ -69,7 +70,7 @@ class WeChatDatabase(BaseWeChat):
69
70
  throw(TypeError, database)
70
71
 
71
72
  ## Database path name.
72
- self.path_names = {
73
+ self.db_names = {
73
74
  'wechat': 'wechat',
74
75
  'wechat.contact_user': 'contact_user',
75
76
  'wechat.contact_room': 'contact_room',
@@ -84,9 +85,6 @@ class WeChatDatabase(BaseWeChat):
84
85
  text='not suitable for SQLite databases'
85
86
  throw(AssertionError, text=text)
86
87
 
87
- # Build.
88
- self.build()
89
-
90
88
  # Add handler.
91
89
  self.__add_receiver_handler_to_contact_user()
92
90
  self.__add_receiver_handler_to_contact_room()
@@ -100,7 +98,7 @@ class WeChatDatabase(BaseWeChat):
100
98
 
101
99
  def build(self) -> None:
102
100
  """
103
- Check and build all standard databases and tables, by `self.path_names`.
101
+ Check and build all standard databases and tables, by `self.db_names`.
104
102
  """
105
103
 
106
104
  # Set parameter.
@@ -108,7 +106,7 @@ class WeChatDatabase(BaseWeChat):
108
106
  ## WeChatDatabase.
109
107
  databases = [
110
108
  {
111
- 'name': self.path_names['wechat']
109
+ 'name': self.db_names['wechat']
112
110
  }
113
111
  ]
114
112
 
@@ -117,7 +115,7 @@ class WeChatDatabase(BaseWeChat):
117
115
 
118
116
  ### 'contact_user'.
119
117
  {
120
- 'path': (self.path_names['wechat'], self.path_names['wechat.contact_user']),
118
+ 'path': (self.db_names['wechat'], self.db_names['wechat.contact_user']),
121
119
  'fields': [
122
120
  {
123
121
  'name': 'create_time',
@@ -162,7 +160,7 @@ class WeChatDatabase(BaseWeChat):
162
160
 
163
161
  ### 'contact_room'.
164
162
  {
165
- 'path': (self.path_names['wechat'], self.path_names['wechat.contact_room']),
163
+ 'path': (self.db_names['wechat'], self.db_names['wechat.contact_room']),
166
164
  'fields': [
167
165
  {
168
166
  'name': 'create_time',
@@ -207,7 +205,7 @@ class WeChatDatabase(BaseWeChat):
207
205
 
208
206
  ### 'contact_room_user'.
209
207
  {
210
- 'path': (self.path_names['wechat'], self.path_names['wechat.contact_room_user']),
208
+ 'path': (self.db_names['wechat'], self.db_names['wechat.contact_room_user']),
211
209
  'fields': [
212
210
  {
213
211
  'name': 'create_time',
@@ -259,7 +257,7 @@ class WeChatDatabase(BaseWeChat):
259
257
 
260
258
  ### 'message_receive'.
261
259
  {
262
- 'path': (self.path_names['wechat'], self.path_names['wechat.message_receive']),
260
+ 'path': (self.db_names['wechat'], self.db_names['wechat.message_receive']),
263
261
  'fields': [
264
262
  {
265
263
  'name': 'create_time',
@@ -282,13 +280,11 @@ class WeChatDatabase(BaseWeChat):
282
280
  {
283
281
  'name': 'room_id',
284
282
  'type': 'varchar(31)',
285
- 'constraint': 'DEFAULT NULL',
286
283
  'comment': 'Message chat room ID, null for private chat.'
287
284
  },
288
285
  {
289
286
  'name': 'user_id',
290
287
  'type': 'varchar(24)',
291
- 'constraint': 'DEFAULT NULL',
292
288
  'comment': 'Message sender user ID, null for system message.'
293
289
  },
294
290
  {
@@ -319,7 +315,6 @@ class WeChatDatabase(BaseWeChat):
319
315
  {
320
316
  'name': 'file_id',
321
317
  'type': 'mediumint unsigned',
322
- 'constraint': 'DEFAULT NULL',
323
318
  'comment': 'Message file ID, from the file database.'
324
319
  }
325
320
  ],
@@ -349,7 +344,7 @@ class WeChatDatabase(BaseWeChat):
349
344
 
350
345
  ### 'message_send'.
351
346
  {
352
- 'path': (self.path_names['wechat'], self.path_names['wechat.message_send']),
347
+ 'path': (self.db_names['wechat'], self.db_names['wechat.message_send']),
353
348
  'fields': [
354
349
  {
355
350
  'name': 'create_time',
@@ -366,14 +361,13 @@ class WeChatDatabase(BaseWeChat):
366
361
  {
367
362
  'name': 'plan_time',
368
363
  'type': 'datetime',
369
- 'constraint': 'DEFAULT NULL',
370
364
  'comment': 'Send plan time.'
371
365
  },
372
366
  {
373
367
  'name': 'send_id',
374
368
  'type': 'int unsigned',
375
369
  'constraint': 'NOT NULL AUTO_INCREMENT',
376
- 'comment': 'Send self increase ID.'
370
+ 'comment': 'Send ID.'
377
371
  },
378
372
  {
379
373
  'name': 'status',
@@ -419,7 +413,6 @@ class WeChatDatabase(BaseWeChat):
419
413
  {
420
414
  'name': 'file_id',
421
415
  'type': 'mediumint unsigned',
422
- 'constraint': 'DEFAULT NULL',
423
416
  'comment': 'Send file ID, from the file database.'
424
417
  }
425
418
  ],
@@ -448,13 +441,13 @@ class WeChatDatabase(BaseWeChat):
448
441
 
449
442
  ### 'stats'.
450
443
  {
451
- 'path': (self.path_names['wechat'], self.path_names['wechat.stats']),
444
+ 'path': (self.db_names['wechat'], self.db_names['wechat.stats']),
452
445
  'items': [
453
446
  {
454
447
  'name': 'count_receive',
455
448
  'select': (
456
449
  'SELECT COUNT(1)\n'
457
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_receive']}`'
450
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
458
451
  ),
459
452
  'comment': 'Message receive count.'
460
453
  },
@@ -462,7 +455,7 @@ class WeChatDatabase(BaseWeChat):
462
455
  'name': 'count_send',
463
456
  'select': (
464
457
  'SELECT COUNT(1)\n'
465
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
458
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
466
459
  'WHERE `status` = 2'
467
460
  ),
468
461
  'comment': 'Message send count.'
@@ -471,7 +464,7 @@ class WeChatDatabase(BaseWeChat):
471
464
  'name': 'count_user',
472
465
  'select': (
473
466
  'SELECT COUNT(1)\n'
474
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_user']}`'
467
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
475
468
  ),
476
469
  'comment': 'Contact user count.'
477
470
  },
@@ -479,7 +472,7 @@ class WeChatDatabase(BaseWeChat):
479
472
  'name': 'count_room',
480
473
  'select': (
481
474
  'SELECT COUNT(1)\n'
482
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`'
475
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
483
476
  ),
484
477
  'comment': 'Contact room count.'
485
478
  },
@@ -487,7 +480,7 @@ class WeChatDatabase(BaseWeChat):
487
480
  'name': 'count_room_user',
488
481
  'select': (
489
482
  'SELECT COUNT(1)\n'
490
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`'
483
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
491
484
  ),
492
485
  'comment': 'Contact room user count.'
493
486
  },
@@ -495,7 +488,7 @@ class WeChatDatabase(BaseWeChat):
495
488
  'name': 'last_time_receive',
496
489
  'select': (
497
490
  'SELECT MAX(`message_time`)\n'
498
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_receive']}`'
491
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
499
492
  ),
500
493
  'comment': 'Message last receive time.'
501
494
  },
@@ -503,7 +496,7 @@ class WeChatDatabase(BaseWeChat):
503
496
  'name': 'last_time_send',
504
497
  'select': (
505
498
  'SELECT MAX(`status_time`)\n'
506
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
499
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
507
500
  'WHERE `status` = 2'
508
501
  ),
509
502
  'comment': 'Message last send time.'
@@ -554,7 +547,7 @@ class WeChatDatabase(BaseWeChat):
554
547
  ## Insert.
555
548
  if contact_table != []:
556
549
  conn.execute_insert(
557
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
550
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
558
551
  user_data,
559
552
  'update'
560
553
  )
@@ -562,12 +555,12 @@ class WeChatDatabase(BaseWeChat):
562
555
  ## Update.
563
556
  if user_ids == []:
564
557
  sql = (
565
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_user']}`\n'
558
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`\n'
566
559
  'SET `contact` = 0'
567
560
  )
568
561
  else:
569
562
  sql = (
570
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_user']}`\n'
563
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`\n'
571
564
  'SET `contact` = 0\n'
572
565
  'WHERE `user_id` NOT IN :user_ids'
573
566
  )
@@ -610,7 +603,7 @@ class WeChatDatabase(BaseWeChat):
610
603
  ## Insert.
611
604
  if contact_table != []:
612
605
  conn.execute_insert(
613
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
606
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
614
607
  room_data,
615
608
  'update'
616
609
  )
@@ -618,12 +611,12 @@ class WeChatDatabase(BaseWeChat):
618
611
  ## Update.
619
612
  if room_ids == []:
620
613
  sql = (
621
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`\n'
614
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`\n'
622
615
  'SET `contact` = 0'
623
616
  )
624
617
  else:
625
618
  sql = (
626
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`\n'
619
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`\n'
627
620
  'SET `contact` = 0\n'
628
621
  'WHERE `room_id` NOT IN :room_ids'
629
622
  )
@@ -688,7 +681,7 @@ class WeChatDatabase(BaseWeChat):
688
681
  ## Insert.
689
682
  if room_user_data != []:
690
683
  conn.execute_insert(
691
- (self.path_names['wechat'], self.path_names['wechat.contact_room_user']),
684
+ (self.db_names['wechat'], self.db_names['wechat.contact_room_user']),
692
685
  room_user_data,
693
686
  'update'
694
687
  )
@@ -696,18 +689,18 @@ class WeChatDatabase(BaseWeChat):
696
689
  ## Update.
697
690
  if room_user_ids == []:
698
691
  sql = (
699
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
692
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
700
693
  'SET `contact` = 0'
701
694
  )
702
695
  elif room_id is None:
703
696
  sql = (
704
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
697
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
705
698
  'SET `contact` = 0\n'
706
699
  "WHERE CONCAT(`room_id`, ',', `user_id`) NOT IN :room_user_ids"
707
700
  )
708
701
  else:
709
702
  sql = (
710
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
703
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
711
704
  'SET `contact` = 0\n'
712
705
  'WHERE (\n'
713
706
  ' `room_id` = :room_id\n'
@@ -756,7 +749,7 @@ class WeChatDatabase(BaseWeChat):
756
749
 
757
750
  ## Insert.
758
751
  self.database_wechat.execute_insert(
759
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
752
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
760
753
  data,
761
754
  'update'
762
755
  )
@@ -797,7 +790,7 @@ class WeChatDatabase(BaseWeChat):
797
790
 
798
791
  ### 'contact_room'.
799
792
  self.database_wechat.execute_insert(
800
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
793
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
801
794
  data,
802
795
  'update'
803
796
  )
@@ -819,7 +812,7 @@ class WeChatDatabase(BaseWeChat):
819
812
 
820
813
  ## Update.
821
814
  self.database_wechat.execute_update(
822
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
815
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
823
816
  data
824
817
  )
825
818
 
@@ -841,7 +834,7 @@ class WeChatDatabase(BaseWeChat):
841
834
 
842
835
  ## Update.
843
836
  self.database_wechat.execute_update(
844
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
837
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
845
838
  data
846
839
  )
847
840
 
@@ -921,7 +914,7 @@ class WeChatDatabase(BaseWeChat):
921
914
 
922
915
  # Insert.
923
916
  self.database_wechat.execute_insert(
924
- (self.path_names['wechat'], self.path_names['wechat.message_receive']),
917
+ (self.db_names['wechat'], self.db_names['wechat.message_receive']),
925
918
  data,
926
919
  'ignore'
927
920
  )
@@ -960,7 +953,7 @@ class WeChatDatabase(BaseWeChat):
960
953
 
961
954
  # Update.
962
955
  self.database_wechat.execute_update(
963
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
956
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
964
957
  data
965
958
  )
966
959
 
@@ -1028,7 +1021,7 @@ class WeChatDatabase(BaseWeChat):
1028
1021
  ')'
1029
1022
  )
1030
1023
  result = conn.execute_select(
1031
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
1024
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
1032
1025
  ['send_id', 'type', 'receive_id', 'parameter', 'file_id'],
1033
1026
  where,
1034
1027
  order='`plan_time` DESC, `send_id`'
@@ -1045,7 +1038,7 @@ class WeChatDatabase(BaseWeChat):
1045
1038
  for row in table
1046
1039
  ]
1047
1040
  sql = (
1048
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
1041
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
1049
1042
  'SET `status` = 1\n'
1050
1043
  'WHERE `send_id` IN :send_ids'
1051
1044
  )
@@ -1112,7 +1105,7 @@ class WeChatDatabase(BaseWeChat):
1112
1105
  ## User.
1113
1106
  if message.room is None:
1114
1107
  result = message.receiver.wechat.database.database_wechat.execute_select(
1115
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
1108
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
1116
1109
  ['valid'],
1117
1110
  '`user_id` = :user_id',
1118
1111
  limit=1,
@@ -1124,13 +1117,13 @@ class WeChatDatabase(BaseWeChat):
1124
1117
  sql = (
1125
1118
  'SELECT (\n'
1126
1119
  ' SELECT `valid`\n'
1127
- f' FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
1120
+ f' FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
1128
1121
  ' WHERE `room_id` = :room_id AND `user_id` = :user_id\n'
1129
1122
  ' LIMIT 1\n'
1130
1123
  ') AS `valid`\n'
1131
1124
  'FROM (\n'
1132
1125
  ' SELECT `valid`\n'
1133
- f' FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`\n'
1126
+ f' FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`\n'
1134
1127
  ' WHERE `room_id` = :room_id\n'
1135
1128
  ' LIMIT 1\n'
1136
1129
  ') AS `a`\n'
@@ -1264,6 +1257,6 @@ class WeChatDatabase(BaseWeChat):
1264
1257
 
1265
1258
  # Insert.
1266
1259
  self.database_wechat.execute_insert(
1267
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
1260
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
1268
1261
  data
1269
1262
  )
reywechat/rwechat.py CHANGED
@@ -110,6 +110,7 @@ class WeChat(BaseWeChat):
110
110
 
111
111
  ## Database.
112
112
  self.send = self.sender.send = self.database.send
113
+ self.database_build = self.database.build
113
114
 
114
115
  ## Schedule.
115
116
  self.schedule_add_task = self.schedule.add_task
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.38
3
+ Version: 1.0.40
4
4
  Summary: WeChat method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reywechat/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -3,15 +3,15 @@ reywechat/rall.py,sha256=zEW-mLL2uP8aT2_foCMFGmMi_3RCrGl8qutnSVkmY1E,397
3
3
  reywechat/rbase.py,sha256=0NunIUIXra2ML2N6odwMk5oENTE0r6VSBHWXUvgI-lc,1124
4
4
  reywechat/rcache.py,sha256=Hh_HE-t_KUMlrz4gEFPh1AjmhnrSgH520IFJPumWb7A,908
5
5
  reywechat/rclient.py,sha256=MEvQB3pHb5ORukKbKntalRtFcKIOP9BGtDsMt5ihQfM,22524
6
- reywechat/rdb.py,sha256=i4YvgKPU9Z5M7N6-X8L93A8qa24FyFS-YkNLcGAC6Y8,42338
6
+ reywechat/rdb.py,sha256=ETy7EZFDBK6nUmtJFNV6kSfSKMnMiLBO771RA89jVqY,41912
7
7
  reywechat/rlog.py,sha256=x4WFLNoeKqGjPVoI81ZZNEd9ctdYToSg5hEFuESmCQY,5254
8
8
  reywechat/rreceive.py,sha256=RkUwPsWz6k_Ua3ovrbXRMVajeNOJQqvpPXz_CvJyUPQ,35162
9
9
  reywechat/rschedule.py,sha256=bZEEZV3K4zrJvupe1Eq6kGR7kunbVq5dfGnqFKYF3JI,1857
10
10
  reywechat/rsend.py,sha256=UmdKCOb1cPKEmBPHt9htjxB8fPyi5jW5pGwpRQIZdKA,13720
11
11
  reywechat/rtrigger.py,sha256=n8kUNovh62r7crlXrp33uaKvbILT-wcfvUqeyGt7YhM,4956
12
- reywechat/rwechat.py,sha256=Iir9EC0E3TmLElPf6k_Tkc7lZOr4uO1X9bpOZ0t0EV0,4884
12
+ reywechat/rwechat.py,sha256=xkHQUUXDEqq4Q_DHF6vc3Dd33A8oOCkKyJN7v7p2leM,4935
13
13
  reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
14
- reywechat-1.0.38.dist-info/METADATA,sha256=pLvQOMbIjktqYHZNIxl6hpvffAbFvcfqXMHheIJgWQI,1551
15
- reywechat-1.0.38.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- reywechat-1.0.38.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
- reywechat-1.0.38.dist-info/RECORD,,
14
+ reywechat-1.0.40.dist-info/METADATA,sha256=5MJCWQ_8cNLimLjDz3zhGJvWaredMvtBtAFiJWF50ok,1551
15
+ reywechat-1.0.40.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ reywechat-1.0.40.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
+ reywechat-1.0.40.dist-info/RECORD,,