reywechat 1.0.38__py3-none-any.whl → 1.0.39__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',
@@ -349,7 +347,7 @@ class WeChatDatabase(BaseWeChat):
349
347
 
350
348
  ### 'message_send'.
351
349
  {
352
- 'path': (self.path_names['wechat'], self.path_names['wechat.message_send']),
350
+ 'path': (self.db_names['wechat'], self.db_names['wechat.message_send']),
353
351
  'fields': [
354
352
  {
355
353
  'name': 'create_time',
@@ -373,7 +371,7 @@ class WeChatDatabase(BaseWeChat):
373
371
  'name': 'send_id',
374
372
  'type': 'int unsigned',
375
373
  'constraint': 'NOT NULL AUTO_INCREMENT',
376
- 'comment': 'Send self increase ID.'
374
+ 'comment': 'Send ID.'
377
375
  },
378
376
  {
379
377
  'name': 'status',
@@ -448,13 +446,13 @@ class WeChatDatabase(BaseWeChat):
448
446
 
449
447
  ### 'stats'.
450
448
  {
451
- 'path': (self.path_names['wechat'], self.path_names['wechat.stats']),
449
+ 'path': (self.db_names['wechat'], self.db_names['wechat.stats']),
452
450
  'items': [
453
451
  {
454
452
  'name': 'count_receive',
455
453
  'select': (
456
454
  'SELECT COUNT(1)\n'
457
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_receive']}`'
455
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
458
456
  ),
459
457
  'comment': 'Message receive count.'
460
458
  },
@@ -462,7 +460,7 @@ class WeChatDatabase(BaseWeChat):
462
460
  'name': 'count_send',
463
461
  'select': (
464
462
  'SELECT COUNT(1)\n'
465
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
463
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
466
464
  'WHERE `status` = 2'
467
465
  ),
468
466
  'comment': 'Message send count.'
@@ -471,7 +469,7 @@ class WeChatDatabase(BaseWeChat):
471
469
  'name': 'count_user',
472
470
  'select': (
473
471
  'SELECT COUNT(1)\n'
474
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_user']}`'
472
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`'
475
473
  ),
476
474
  'comment': 'Contact user count.'
477
475
  },
@@ -479,7 +477,7 @@ class WeChatDatabase(BaseWeChat):
479
477
  'name': 'count_room',
480
478
  'select': (
481
479
  'SELECT COUNT(1)\n'
482
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`'
480
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`'
483
481
  ),
484
482
  'comment': 'Contact room count.'
485
483
  },
@@ -487,7 +485,7 @@ class WeChatDatabase(BaseWeChat):
487
485
  'name': 'count_room_user',
488
486
  'select': (
489
487
  'SELECT COUNT(1)\n'
490
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`'
488
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`'
491
489
  ),
492
490
  'comment': 'Contact room user count.'
493
491
  },
@@ -495,7 +493,7 @@ class WeChatDatabase(BaseWeChat):
495
493
  'name': 'last_time_receive',
496
494
  'select': (
497
495
  'SELECT MAX(`message_time`)\n'
498
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_receive']}`'
496
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_receive']}`'
499
497
  ),
500
498
  'comment': 'Message last receive time.'
501
499
  },
@@ -503,7 +501,7 @@ class WeChatDatabase(BaseWeChat):
503
501
  'name': 'last_time_send',
504
502
  'select': (
505
503
  'SELECT MAX(`status_time`)\n'
506
- f'FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
504
+ f'FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
507
505
  'WHERE `status` = 2'
508
506
  ),
509
507
  'comment': 'Message last send time.'
@@ -554,7 +552,7 @@ class WeChatDatabase(BaseWeChat):
554
552
  ## Insert.
555
553
  if contact_table != []:
556
554
  conn.execute_insert(
557
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
555
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
558
556
  user_data,
559
557
  'update'
560
558
  )
@@ -562,12 +560,12 @@ class WeChatDatabase(BaseWeChat):
562
560
  ## Update.
563
561
  if user_ids == []:
564
562
  sql = (
565
- 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'
566
564
  'SET `contact` = 0'
567
565
  )
568
566
  else:
569
567
  sql = (
570
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_user']}`\n'
568
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_user']}`\n'
571
569
  'SET `contact` = 0\n'
572
570
  'WHERE `user_id` NOT IN :user_ids'
573
571
  )
@@ -610,7 +608,7 @@ class WeChatDatabase(BaseWeChat):
610
608
  ## Insert.
611
609
  if contact_table != []:
612
610
  conn.execute_insert(
613
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
611
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
614
612
  room_data,
615
613
  'update'
616
614
  )
@@ -618,12 +616,12 @@ class WeChatDatabase(BaseWeChat):
618
616
  ## Update.
619
617
  if room_ids == []:
620
618
  sql = (
621
- 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'
622
620
  'SET `contact` = 0'
623
621
  )
624
622
  else:
625
623
  sql = (
626
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`\n'
624
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`\n'
627
625
  'SET `contact` = 0\n'
628
626
  'WHERE `room_id` NOT IN :room_ids'
629
627
  )
@@ -688,7 +686,7 @@ class WeChatDatabase(BaseWeChat):
688
686
  ## Insert.
689
687
  if room_user_data != []:
690
688
  conn.execute_insert(
691
- (self.path_names['wechat'], self.path_names['wechat.contact_room_user']),
689
+ (self.db_names['wechat'], self.db_names['wechat.contact_room_user']),
692
690
  room_user_data,
693
691
  'update'
694
692
  )
@@ -696,18 +694,18 @@ class WeChatDatabase(BaseWeChat):
696
694
  ## Update.
697
695
  if room_user_ids == []:
698
696
  sql = (
699
- 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'
700
698
  'SET `contact` = 0'
701
699
  )
702
700
  elif room_id is None:
703
701
  sql = (
704
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
702
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
705
703
  'SET `contact` = 0\n'
706
704
  "WHERE CONCAT(`room_id`, ',', `user_id`) NOT IN :room_user_ids"
707
705
  )
708
706
  else:
709
707
  sql = (
710
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
708
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
711
709
  'SET `contact` = 0\n'
712
710
  'WHERE (\n'
713
711
  ' `room_id` = :room_id\n'
@@ -756,7 +754,7 @@ class WeChatDatabase(BaseWeChat):
756
754
 
757
755
  ## Insert.
758
756
  self.database_wechat.execute_insert(
759
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
757
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
760
758
  data,
761
759
  'update'
762
760
  )
@@ -797,7 +795,7 @@ class WeChatDatabase(BaseWeChat):
797
795
 
798
796
  ### 'contact_room'.
799
797
  self.database_wechat.execute_insert(
800
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
798
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
801
799
  data,
802
800
  'update'
803
801
  )
@@ -819,7 +817,7 @@ class WeChatDatabase(BaseWeChat):
819
817
 
820
818
  ## Update.
821
819
  self.database_wechat.execute_update(
822
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
820
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
823
821
  data
824
822
  )
825
823
 
@@ -841,7 +839,7 @@ class WeChatDatabase(BaseWeChat):
841
839
 
842
840
  ## Update.
843
841
  self.database_wechat.execute_update(
844
- (self.path_names['wechat'], self.path_names['wechat.contact_room']),
842
+ (self.db_names['wechat'], self.db_names['wechat.contact_room']),
845
843
  data
846
844
  )
847
845
 
@@ -921,7 +919,7 @@ class WeChatDatabase(BaseWeChat):
921
919
 
922
920
  # Insert.
923
921
  self.database_wechat.execute_insert(
924
- (self.path_names['wechat'], self.path_names['wechat.message_receive']),
922
+ (self.db_names['wechat'], self.db_names['wechat.message_receive']),
925
923
  data,
926
924
  'ignore'
927
925
  )
@@ -960,7 +958,7 @@ class WeChatDatabase(BaseWeChat):
960
958
 
961
959
  # Update.
962
960
  self.database_wechat.execute_update(
963
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
961
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
964
962
  data
965
963
  )
966
964
 
@@ -1028,7 +1026,7 @@ class WeChatDatabase(BaseWeChat):
1028
1026
  ')'
1029
1027
  )
1030
1028
  result = conn.execute_select(
1031
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
1029
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
1032
1030
  ['send_id', 'type', 'receive_id', 'parameter', 'file_id'],
1033
1031
  where,
1034
1032
  order='`plan_time` DESC, `send_id`'
@@ -1045,7 +1043,7 @@ class WeChatDatabase(BaseWeChat):
1045
1043
  for row in table
1046
1044
  ]
1047
1045
  sql = (
1048
- f'UPDATE `{self.path_names['wechat']}`.`{self.path_names['wechat.message_send']}`\n'
1046
+ f'UPDATE `{self.db_names['wechat']}`.`{self.db_names['wechat.message_send']}`\n'
1049
1047
  'SET `status` = 1\n'
1050
1048
  'WHERE `send_id` IN :send_ids'
1051
1049
  )
@@ -1112,7 +1110,7 @@ class WeChatDatabase(BaseWeChat):
1112
1110
  ## User.
1113
1111
  if message.room is None:
1114
1112
  result = message.receiver.wechat.database.database_wechat.execute_select(
1115
- (self.path_names['wechat'], self.path_names['wechat.contact_user']),
1113
+ (self.db_names['wechat'], self.db_names['wechat.contact_user']),
1116
1114
  ['valid'],
1117
1115
  '`user_id` = :user_id',
1118
1116
  limit=1,
@@ -1124,13 +1122,13 @@ class WeChatDatabase(BaseWeChat):
1124
1122
  sql = (
1125
1123
  'SELECT (\n'
1126
1124
  ' SELECT `valid`\n'
1127
- f' FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room_user']}`\n'
1125
+ f' FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room_user']}`\n'
1128
1126
  ' WHERE `room_id` = :room_id AND `user_id` = :user_id\n'
1129
1127
  ' LIMIT 1\n'
1130
1128
  ') AS `valid`\n'
1131
1129
  'FROM (\n'
1132
1130
  ' SELECT `valid`\n'
1133
- f' FROM `{self.path_names['wechat']}`.`{self.path_names['wechat.contact_room']}`\n'
1131
+ f' FROM `{self.db_names['wechat']}`.`{self.db_names['wechat.contact_room']}`\n'
1134
1132
  ' WHERE `room_id` = :room_id\n'
1135
1133
  ' LIMIT 1\n'
1136
1134
  ') AS `a`\n'
@@ -1264,6 +1262,6 @@ class WeChatDatabase(BaseWeChat):
1264
1262
 
1265
1263
  # Insert.
1266
1264
  self.database_wechat.execute_insert(
1267
- (self.path_names['wechat'], self.path_names['wechat.message_send']),
1265
+ (self.db_names['wechat'], self.db_names['wechat.message_send']),
1268
1266
  data
1269
1267
  )
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.39
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=1l7BGx-WC_DdDDAJrI-EsHUbdLApaQWGrxqAyggYXIA,42187
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.39.dist-info/METADATA,sha256=YpRoJrcy0zs50O7BQKnVt9ukABoVK2APC2akitEv5AA,1551
15
+ reywechat-1.0.39.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ reywechat-1.0.39.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
+ reywechat-1.0.39.dist-info/RECORD,,