reywechat 1.0.33__py3-none-any.whl → 1.0.35__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
@@ -37,7 +37,7 @@ class WeChatDatabase(BaseWeChat):
37
37
  def __init__(
38
38
  self,
39
39
  wechat: WeChat,
40
- rdatabase: Database | dict[Literal['wechat', 'file'], Database]
40
+ database: Database | dict[Literal['wechat', 'file'], Database]
41
41
  ) -> None:
42
42
  """
43
43
  Build instance attributes.
@@ -45,31 +45,42 @@ class WeChatDatabase(BaseWeChat):
45
45
  Parameters
46
46
  ----------
47
47
  wechat : `WeChatClient` instance.
48
- rdatabase : `WeChatDatabase` instance of `reykit` package.
49
- - `WeChatDatabase`, Set all `WeChatDatabase`: instances.
50
- - `dict`, Set each `WeChatDatabase`: instance, all item is required.
51
- `Key 'wechat'`: `WeChatDatabase` instance used in WeChat methods.
52
- `Key 'file'`: `WeChatDatabase` instance used in file methods.
48
+ database : `Database` instance of `reykit` package.
49
+ - `Database`, Set all `Database`: instances.
50
+ - `dict`, Set each `Database`: instance, all item is required.
51
+ `Key 'wechat'`: `Database` instance used in WeChat methods.
52
+ `Key 'file'`: `Database` instance used in file methods.
53
53
  """
54
54
 
55
55
  # Set attribute.
56
56
  self.wechat = wechat
57
- match rdatabase:
57
+ match database:
58
58
  case Database():
59
- self.rdatabase_wechat = self.rdatabase_file = rdatabase
59
+ self.database_wechat = self.database_file = database
60
60
  case dict():
61
- self.rdatabase_wechat: Database = rdatabase.get('wechat')
62
- self.rdatabase_file: Database = rdatabase.get('file')
61
+ self.database_wechat: Database = database.get('wechat')
62
+ self.database_file: Database = database.get('file')
63
63
  if (
64
- self.rdatabase_wechat
65
- or self.rdatabase_file
64
+ self.database_wechat
65
+ or self.database_file
66
66
  ):
67
- throw(ValueError, rdatabase)
67
+ throw(ValueError, database)
68
68
  case _:
69
- throw(TypeError, rdatabase)
69
+ throw(TypeError, database)
70
+
71
+ ## Database path name.
72
+ self.path_names = {
73
+ 'wechat': 'wechat',
74
+ 'wechat.contact_user': 'contact_user',
75
+ 'wechat.contact_room': 'contact_room',
76
+ 'wechat.contact_room_user': 'contact_room_user',
77
+ 'wechat.message_receive': 'message_receive',
78
+ 'wechat.message_send': 'message_send',
79
+ 'wechat.stats': 'stats'
80
+ }
70
81
 
71
82
  # Check.
72
- if 'sqlite' in (self.rdatabase_wechat.backend, self.rdatabase_file.backend):
83
+ if 'sqlite' in (self.database_wechat.backend, self.database_file.backend):
73
84
  text='not suitable for SQLite databases'
74
85
  throw(AssertionError, text=text)
75
86
 
@@ -89,7 +100,7 @@ class WeChatDatabase(BaseWeChat):
89
100
 
90
101
  def build(self) -> None:
91
102
  """
92
- Check and build all standard databases and tables.
103
+ Check and build all standard databases and tables, by `self.path_names`.
93
104
  """
94
105
 
95
106
  # Set parameter.
@@ -97,7 +108,7 @@ class WeChatDatabase(BaseWeChat):
97
108
  ## WeChatDatabase.
98
109
  databases = [
99
110
  {
100
- 'database': 'wechat'
111
+ 'name': self.path_names['wechat']
101
112
  }
102
113
  ]
103
114
 
@@ -106,7 +117,7 @@ class WeChatDatabase(BaseWeChat):
106
117
 
107
118
  ### 'contact_user'.
108
119
  {
109
- 'path': ('wechat', 'contact_user'),
120
+ 'path': (self.path_names['wechat'], self.path_names['wechat.contact_user']),
110
121
  'fields': [
111
122
  {
112
123
  'name': 'create_time',
@@ -151,7 +162,7 @@ class WeChatDatabase(BaseWeChat):
151
162
 
152
163
  ### 'contact_room'.
153
164
  {
154
- 'path': ('wechat', 'contact_room'),
165
+ 'path': (self.path_names['wechat'], self.path_names['wechat.contact_room']),
155
166
  'fields': [
156
167
  {
157
168
  'name': 'create_time',
@@ -196,7 +207,7 @@ class WeChatDatabase(BaseWeChat):
196
207
 
197
208
  ### 'contact_room_user'.
198
209
  {
199
- 'path': ('wechat', 'contact_room_user'),
210
+ 'path': (self.path_names['wechat'], self.path_names['wechat.contact_room_user']),
200
211
  'fields': [
201
212
  {
202
213
  'name': 'create_time',
@@ -248,7 +259,7 @@ class WeChatDatabase(BaseWeChat):
248
259
 
249
260
  ### 'message_receive'.
250
261
  {
251
- 'path': ('wechat', 'message_receive'),
262
+ 'path': (self.path_names['wechat'], self.path_names['wechat.message_receive']),
252
263
  'fields': [
253
264
  {
254
265
  'name': 'create_time',
@@ -338,7 +349,7 @@ class WeChatDatabase(BaseWeChat):
338
349
 
339
350
  ### 'message_send'.
340
351
  {
341
- 'path': ('wechat', 'message_send'),
352
+ 'path': (self.path_names['wechat'], self.path_names['wechat.message_send']),
342
353
  'fields': [
343
354
  {
344
355
  'name': 'create_time',
@@ -436,7 +447,7 @@ class WeChatDatabase(BaseWeChat):
436
447
 
437
448
  ### 'stats'.
438
449
  {
439
- 'path': ('wechat', 'stats'),
450
+ 'path': (self.path_names['wechat'], self.path_names['wechat.stats']),
440
451
  'items': [
441
452
  {
442
453
  'name': 'count_receive',
@@ -503,10 +514,10 @@ class WeChatDatabase(BaseWeChat):
503
514
  # Build.
504
515
 
505
516
  ## WeChat.
506
- self.rdatabase_wechat.build.build(databases, tables, views_stats=views_stats)
517
+ self.database_wechat.build.build(databases, tables, views_stats=views_stats)
507
518
 
508
519
  ## File.
509
- self.rdatabase_file.file.build()
520
+ self.database_file.file.build()
510
521
 
511
522
  # Update.
512
523
  self.update_contact_user()
@@ -536,12 +547,12 @@ class WeChatDatabase(BaseWeChat):
536
547
  ]
537
548
 
538
549
  # Insert and update.
539
- conn = self.rdatabase_wechat.connect()
550
+ conn = self.database_wechat.connect()
540
551
 
541
552
  ## Insert.
542
553
  if contact_table != []:
543
554
  conn.execute_insert(
544
- ('wechat', 'contact_user'),
555
+ (self.path_names['wechat'], self.path_names['wechat.contact_user']),
545
556
  user_data,
546
557
  'update'
547
558
  )
@@ -592,12 +603,12 @@ class WeChatDatabase(BaseWeChat):
592
603
  ]
593
604
 
594
605
  # Insert and update.
595
- conn = self.rdatabase_wechat.connect()
606
+ conn = self.database_wechat.connect()
596
607
 
597
608
  ## Insert.
598
609
  if contact_table != []:
599
610
  conn.execute_insert(
600
- ('wechat', 'contact_room'),
611
+ (self.path_names['wechat'], self.path_names['wechat.contact_room']),
601
612
  room_data,
602
613
  'update'
603
614
  )
@@ -670,12 +681,12 @@ class WeChatDatabase(BaseWeChat):
670
681
  ]
671
682
 
672
683
  # Insert and update.
673
- conn = self.rdatabase_wechat.connect()
684
+ conn = self.database_wechat.connect()
674
685
 
675
686
  ## Insert.
676
687
  if room_user_data != []:
677
688
  conn.execute_insert(
678
- ('wechat', 'contact_room_user'),
689
+ (self.path_names['wechat'], self.path_names['wechat.contact_room_user']),
679
690
  room_user_data,
680
691
  'update'
681
692
  )
@@ -742,8 +753,8 @@ class WeChatDatabase(BaseWeChat):
742
753
  }
743
754
 
744
755
  ## Insert.
745
- self.rdatabase_wechat.execute_insert(
746
- ('wechat', 'contact_user'),
756
+ self.database_wechat.execute_insert(
757
+ (self.path_names['wechat'], self.path_names['wechat.contact_user']),
747
758
  data,
748
759
  'update'
749
760
  )
@@ -783,8 +794,8 @@ class WeChatDatabase(BaseWeChat):
783
794
  ## Insert.
784
795
 
785
796
  ### 'contact_room'.
786
- self.rdatabase_wechat.execute_insert(
787
- ('wechat', 'contact_room'),
797
+ self.database_wechat.execute_insert(
798
+ (self.path_names['wechat'], self.path_names['wechat.contact_room']),
788
799
  data,
789
800
  'update'
790
801
  )
@@ -805,8 +816,8 @@ class WeChatDatabase(BaseWeChat):
805
816
  }
806
817
 
807
818
  ## Update.
808
- self.rdatabase_wechat.execute_update(
809
- ('wechat', 'contact_room'),
819
+ self.database_wechat.execute_update(
820
+ (self.path_names['wechat'], self.path_names['wechat.contact_room']),
810
821
  data
811
822
  )
812
823
 
@@ -827,8 +838,8 @@ class WeChatDatabase(BaseWeChat):
827
838
  }
828
839
 
829
840
  ## Update.
830
- self.rdatabase_wechat.execute_update(
831
- ('wechat', 'contact_room'),
841
+ self.database_wechat.execute_update(
842
+ (self.path_names['wechat'], self.path_names['wechat.contact_room']),
832
843
  data
833
844
  )
834
845
 
@@ -887,7 +898,7 @@ class WeChatDatabase(BaseWeChat):
887
898
  if message.file is None:
888
899
  file_id = None
889
900
  else:
890
- file_id = self.rdatabase_file.file.upload(
901
+ file_id = self.database_file.file.upload(
891
902
  message.file['path'],
892
903
  message.file['name'],
893
904
  'WeChat'
@@ -907,8 +918,8 @@ class WeChatDatabase(BaseWeChat):
907
918
  }
908
919
 
909
920
  # Insert.
910
- self.rdatabase_wechat.execute_insert(
911
- ('wechat', 'message_receive'),
921
+ self.database_wechat.execute_insert(
922
+ (self.path_names['wechat'], self.path_names['wechat.message_receive']),
912
923
  data,
913
924
  'ignore'
914
925
  )
@@ -946,8 +957,8 @@ class WeChatDatabase(BaseWeChat):
946
957
  }
947
958
 
948
959
  # Update.
949
- self.rdatabase_wechat.execute_update(
950
- ('wechat', 'message_send'),
960
+ self.database_wechat.execute_update(
961
+ (self.path_names['wechat'], self.path_names['wechat.message_send']),
951
962
  data
952
963
  )
953
964
 
@@ -973,7 +984,7 @@ class WeChatDatabase(BaseWeChat):
973
984
  """
974
985
 
975
986
  # Information.
976
- file_info = self.rdatabase_file.file.query(file_id)
987
+ file_info = self.database_file.file.query(file_id)
977
988
  file_md5 = file_info['md5']
978
989
  file_name = file_info['name']
979
990
 
@@ -982,7 +993,7 @@ class WeChatDatabase(BaseWeChat):
982
993
 
983
994
  ## Download.
984
995
  if cache_path is None:
985
- file_bytes = self.rdatabase_file.file.download(file_id)
996
+ file_bytes = self.database_file.file.download(file_id)
986
997
  cache_path = self.wechat.cache.store(file_bytes, file_name)
987
998
 
988
999
  return cache_path, file_name
@@ -1002,7 +1013,7 @@ class WeChatDatabase(BaseWeChat):
1002
1013
  """
1003
1014
 
1004
1015
  # Handle parameter.
1005
- conn = self.rdatabase_wechat.connect()
1016
+ conn = self.database_wechat.connect()
1006
1017
 
1007
1018
  # Read.
1008
1019
  where = (
@@ -1015,7 +1026,7 @@ class WeChatDatabase(BaseWeChat):
1015
1026
  ')'
1016
1027
  )
1017
1028
  result = conn.execute_select(
1018
- ('wechat', 'message_send'),
1029
+ (self.path_names['wechat'], self.path_names['wechat.message_send']),
1019
1030
  ['send_id', 'type', 'receive_id', 'parameter', 'file_id'],
1020
1031
  where,
1021
1032
  order='`plan_time` DESC, `send_id`'
@@ -1098,8 +1109,8 @@ class WeChatDatabase(BaseWeChat):
1098
1109
 
1099
1110
  ## User.
1100
1111
  if message.room is None:
1101
- result = message.receiver.wechat.database.rdatabase_wechat.execute_select(
1102
- ('wechat', 'contact_user'),
1112
+ result = message.receiver.wechat.database.database_wechat.execute_select(
1113
+ (self.path_names['wechat'], self.path_names['wechat.contact_user']),
1103
1114
  ['valid'],
1104
1115
  '`user_id` = :user_id',
1105
1116
  limit=1,
@@ -1123,7 +1134,7 @@ class WeChatDatabase(BaseWeChat):
1123
1134
  ') AS `a`\n'
1124
1135
  'WHERE `valid` = 1'
1125
1136
  )
1126
- result = message.receiver.wechat.database.rdatabase_wechat.execute(
1137
+ result = message.receiver.wechat.database.database_wechat.execute(
1127
1138
  sql,
1128
1139
  room_id=message.room,
1129
1140
  user_id=message.user
@@ -1240,7 +1251,7 @@ class WeChatDatabase(BaseWeChat):
1240
1251
  ## Cache.
1241
1252
  cache_path = self.wechat.cache.store(file_path, file_name)
1242
1253
 
1243
- file_id = self.rdatabase_file.file.upload(
1254
+ file_id = self.database_file.file.upload(
1244
1255
  cache_path,
1245
1256
  file_name,
1246
1257
  'WeChat'
@@ -1250,7 +1261,7 @@ class WeChatDatabase(BaseWeChat):
1250
1261
  data['file_id'] = file_id
1251
1262
 
1252
1263
  # Insert.
1253
- self.rdatabase_wechat.execute_insert(
1254
- ('wechat', 'message_send'),
1264
+ self.database_wechat.execute_insert(
1265
+ (self.path_names['wechat'], self.path_names['wechat.message_send']),
1255
1266
  data
1256
1267
  )
reywechat/rwechat.py CHANGED
@@ -40,7 +40,7 @@ class WeChat(BaseWeChat):
40
40
 
41
41
  def __init__(
42
42
  self,
43
- rrdatabase: Database | dict[Literal['wechat', 'file'], Database] | None,
43
+ database: Database | dict[Literal['wechat', 'file'], Database] | None,
44
44
  max_receiver: int = 2,
45
45
  call_name: str | None = None,
46
46
  project_dir: str | None = None
@@ -50,11 +50,11 @@ class WeChat(BaseWeChat):
50
50
 
51
51
  Parameters
52
52
  ----------
53
- rrdatabase : `WeChatDatabase` instance of `reykit` package.
54
- - `WeChatDatabase`, Set all `WeChatDatabase`: instances.
55
- - `dict`, Set each `WeChatDatabase`: instance, all item is required.
56
- `Key 'wechat'`: `WeChatDatabase` instance used in WeChat methods.
57
- `Key 'file'`: `WeChatDatabase` instance used in file methods.
53
+ database : `Database` instance of `reykit` package.
54
+ - `Database`, Set all `Database`: instances.
55
+ - `dict`, Set each `Database`: instance, all item is required.
56
+ `Key 'wechat'`: `Database` instance used in WeChat methods.
57
+ `Key 'file'`: `Database` instance used in file methods.
58
58
  max_receiver : Maximum number of receivers.
59
59
  call_name : Trigger call name.
60
60
  - `None`: Use account nickname.
@@ -82,7 +82,7 @@ class WeChat(BaseWeChat):
82
82
  self.receiver = WechatReceiver(self, max_receiver, call_name)
83
83
  self.trigger = self.receiver.trigger
84
84
  self.sender = WeChatSender(self)
85
- self.database = WeChatDatabase(self, rrdatabase)
85
+ self.database = WeChatDatabase(self, database)
86
86
  self.schedule = WeChatSchedule(self)
87
87
 
88
88
  ## Client.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.33
3
+ Version: 1.0.35
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=euMCZBYz6b4Pw27zPUKYOwPHxK7g47pYfWFfNZMh0mU,40342
6
+ reywechat/rdb.py,sha256=tknEavihcZ3-BYb29terhO8pE6s3t0NZABvUJoBdUTI,41464
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=d9yNnLLz0YI1buatf5j4YMhj6tUH6yWsDnx91EyAhow,4926
12
+ reywechat/rwechat.py,sha256=Iir9EC0E3TmLElPf6k_Tkc7lZOr4uO1X9bpOZ0t0EV0,4884
13
13
  reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
14
- reywechat-1.0.33.dist-info/METADATA,sha256=iWpKAPaPOLLlLnmBv8bGRXGjDmlbMuVMLZtaqodYSQk,1551
15
- reywechat-1.0.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- reywechat-1.0.33.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
- reywechat-1.0.33.dist-info/RECORD,,
14
+ reywechat-1.0.35.dist-info/METADATA,sha256=XWhoKggz_4cP8rfJ9l0uMxB5--EyWWw0Zb8TsWT7YzI,1551
15
+ reywechat-1.0.35.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ reywechat-1.0.35.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
+ reywechat-1.0.35.dist-info/RECORD,,