reywechat 1.0.34__py3-none-any.whl → 1.0.36__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 +34 -34
- reywechat/rwechat.py +7 -7
- {reywechat-1.0.34.dist-info → reywechat-1.0.36.dist-info}/METADATA +1 -1
- {reywechat-1.0.34.dist-info → reywechat-1.0.36.dist-info}/RECORD +6 -6
- {reywechat-1.0.34.dist-info → reywechat-1.0.36.dist-info}/WHEEL +0 -0
- {reywechat-1.0.34.dist-info → reywechat-1.0.36.dist-info}/licenses/LICENSE +0 -0
reywechat/rdb.py
CHANGED
@@ -37,7 +37,7 @@ class WeChatDatabase(BaseWeChat):
|
|
37
37
|
def __init__(
|
38
38
|
self,
|
39
39
|
wechat: WeChat,
|
40
|
-
|
40
|
+
database: Database | dict[Literal['wechat', 'file'], Database]
|
41
41
|
) -> None:
|
42
42
|
"""
|
43
43
|
Build instance attributes.
|
@@ -45,28 +45,28 @@ class WeChatDatabase(BaseWeChat):
|
|
45
45
|
Parameters
|
46
46
|
----------
|
47
47
|
wechat : `WeChatClient` instance.
|
48
|
-
|
49
|
-
- `
|
50
|
-
- `dict`, Set each `
|
51
|
-
`Key 'wechat'`: `
|
52
|
-
`Key 'file'`: `
|
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
|
57
|
+
match database:
|
58
58
|
case Database():
|
59
|
-
self.
|
59
|
+
self.database_wechat = self.database_file = database
|
60
60
|
case dict():
|
61
|
-
self.
|
62
|
-
self.
|
61
|
+
self.database_wechat: Database = database.get('wechat')
|
62
|
+
self.database_file: Database = database.get('file')
|
63
63
|
if (
|
64
|
-
self.
|
65
|
-
or self.
|
64
|
+
self.database_wechat is None
|
65
|
+
or self.database_file is None
|
66
66
|
):
|
67
|
-
throw(ValueError,
|
67
|
+
throw(ValueError, database)
|
68
68
|
case _:
|
69
|
-
throw(TypeError,
|
69
|
+
throw(TypeError, database)
|
70
70
|
|
71
71
|
## Database path name.
|
72
72
|
self.path_names = {
|
@@ -80,7 +80,7 @@ class WeChatDatabase(BaseWeChat):
|
|
80
80
|
}
|
81
81
|
|
82
82
|
# Check.
|
83
|
-
if 'sqlite' in (self.
|
83
|
+
if 'sqlite' in (self.database_wechat.backend, self.database_file.backend):
|
84
84
|
text='not suitable for SQLite databases'
|
85
85
|
throw(AssertionError, text=text)
|
86
86
|
|
@@ -514,10 +514,10 @@ class WeChatDatabase(BaseWeChat):
|
|
514
514
|
# Build.
|
515
515
|
|
516
516
|
## WeChat.
|
517
|
-
self.
|
517
|
+
self.database_wechat.build.build(databases, tables, views_stats=views_stats)
|
518
518
|
|
519
519
|
## File.
|
520
|
-
self.
|
520
|
+
self.database_file.file.build()
|
521
521
|
|
522
522
|
# Update.
|
523
523
|
self.update_contact_user()
|
@@ -547,7 +547,7 @@ class WeChatDatabase(BaseWeChat):
|
|
547
547
|
]
|
548
548
|
|
549
549
|
# Insert and update.
|
550
|
-
conn = self.
|
550
|
+
conn = self.database_wechat.connect()
|
551
551
|
|
552
552
|
## Insert.
|
553
553
|
if contact_table != []:
|
@@ -603,7 +603,7 @@ class WeChatDatabase(BaseWeChat):
|
|
603
603
|
]
|
604
604
|
|
605
605
|
# Insert and update.
|
606
|
-
conn = self.
|
606
|
+
conn = self.database_wechat.connect()
|
607
607
|
|
608
608
|
## Insert.
|
609
609
|
if contact_table != []:
|
@@ -681,7 +681,7 @@ class WeChatDatabase(BaseWeChat):
|
|
681
681
|
]
|
682
682
|
|
683
683
|
# Insert and update.
|
684
|
-
conn = self.
|
684
|
+
conn = self.database_wechat.connect()
|
685
685
|
|
686
686
|
## Insert.
|
687
687
|
if room_user_data != []:
|
@@ -753,7 +753,7 @@ class WeChatDatabase(BaseWeChat):
|
|
753
753
|
}
|
754
754
|
|
755
755
|
## Insert.
|
756
|
-
self.
|
756
|
+
self.database_wechat.execute_insert(
|
757
757
|
(self.path_names['wechat'], self.path_names['wechat.contact_user']),
|
758
758
|
data,
|
759
759
|
'update'
|
@@ -794,7 +794,7 @@ class WeChatDatabase(BaseWeChat):
|
|
794
794
|
## Insert.
|
795
795
|
|
796
796
|
### 'contact_room'.
|
797
|
-
self.
|
797
|
+
self.database_wechat.execute_insert(
|
798
798
|
(self.path_names['wechat'], self.path_names['wechat.contact_room']),
|
799
799
|
data,
|
800
800
|
'update'
|
@@ -816,7 +816,7 @@ class WeChatDatabase(BaseWeChat):
|
|
816
816
|
}
|
817
817
|
|
818
818
|
## Update.
|
819
|
-
self.
|
819
|
+
self.database_wechat.execute_update(
|
820
820
|
(self.path_names['wechat'], self.path_names['wechat.contact_room']),
|
821
821
|
data
|
822
822
|
)
|
@@ -838,7 +838,7 @@ class WeChatDatabase(BaseWeChat):
|
|
838
838
|
}
|
839
839
|
|
840
840
|
## Update.
|
841
|
-
self.
|
841
|
+
self.database_wechat.execute_update(
|
842
842
|
(self.path_names['wechat'], self.path_names['wechat.contact_room']),
|
843
843
|
data
|
844
844
|
)
|
@@ -898,7 +898,7 @@ class WeChatDatabase(BaseWeChat):
|
|
898
898
|
if message.file is None:
|
899
899
|
file_id = None
|
900
900
|
else:
|
901
|
-
file_id = self.
|
901
|
+
file_id = self.database_file.file.upload(
|
902
902
|
message.file['path'],
|
903
903
|
message.file['name'],
|
904
904
|
'WeChat'
|
@@ -918,7 +918,7 @@ class WeChatDatabase(BaseWeChat):
|
|
918
918
|
}
|
919
919
|
|
920
920
|
# Insert.
|
921
|
-
self.
|
921
|
+
self.database_wechat.execute_insert(
|
922
922
|
(self.path_names['wechat'], self.path_names['wechat.message_receive']),
|
923
923
|
data,
|
924
924
|
'ignore'
|
@@ -957,7 +957,7 @@ class WeChatDatabase(BaseWeChat):
|
|
957
957
|
}
|
958
958
|
|
959
959
|
# Update.
|
960
|
-
self.
|
960
|
+
self.database_wechat.execute_update(
|
961
961
|
(self.path_names['wechat'], self.path_names['wechat.message_send']),
|
962
962
|
data
|
963
963
|
)
|
@@ -984,7 +984,7 @@ class WeChatDatabase(BaseWeChat):
|
|
984
984
|
"""
|
985
985
|
|
986
986
|
# Information.
|
987
|
-
file_info = self.
|
987
|
+
file_info = self.database_file.file.query(file_id)
|
988
988
|
file_md5 = file_info['md5']
|
989
989
|
file_name = file_info['name']
|
990
990
|
|
@@ -993,7 +993,7 @@ class WeChatDatabase(BaseWeChat):
|
|
993
993
|
|
994
994
|
## Download.
|
995
995
|
if cache_path is None:
|
996
|
-
file_bytes = self.
|
996
|
+
file_bytes = self.database_file.file.download(file_id)
|
997
997
|
cache_path = self.wechat.cache.store(file_bytes, file_name)
|
998
998
|
|
999
999
|
return cache_path, file_name
|
@@ -1013,7 +1013,7 @@ class WeChatDatabase(BaseWeChat):
|
|
1013
1013
|
"""
|
1014
1014
|
|
1015
1015
|
# Handle parameter.
|
1016
|
-
conn = self.
|
1016
|
+
conn = self.database_wechat.connect()
|
1017
1017
|
|
1018
1018
|
# Read.
|
1019
1019
|
where = (
|
@@ -1109,7 +1109,7 @@ class WeChatDatabase(BaseWeChat):
|
|
1109
1109
|
|
1110
1110
|
## User.
|
1111
1111
|
if message.room is None:
|
1112
|
-
result = message.receiver.wechat.database.
|
1112
|
+
result = message.receiver.wechat.database.database_wechat.execute_select(
|
1113
1113
|
(self.path_names['wechat'], self.path_names['wechat.contact_user']),
|
1114
1114
|
['valid'],
|
1115
1115
|
'`user_id` = :user_id',
|
@@ -1134,7 +1134,7 @@ class WeChatDatabase(BaseWeChat):
|
|
1134
1134
|
') AS `a`\n'
|
1135
1135
|
'WHERE `valid` = 1'
|
1136
1136
|
)
|
1137
|
-
result = message.receiver.wechat.database.
|
1137
|
+
result = message.receiver.wechat.database.database_wechat.execute(
|
1138
1138
|
sql,
|
1139
1139
|
room_id=message.room,
|
1140
1140
|
user_id=message.user
|
@@ -1251,7 +1251,7 @@ class WeChatDatabase(BaseWeChat):
|
|
1251
1251
|
## Cache.
|
1252
1252
|
cache_path = self.wechat.cache.store(file_path, file_name)
|
1253
1253
|
|
1254
|
-
file_id = self.
|
1254
|
+
file_id = self.database_file.file.upload(
|
1255
1255
|
cache_path,
|
1256
1256
|
file_name,
|
1257
1257
|
'WeChat'
|
@@ -1261,7 +1261,7 @@ class WeChatDatabase(BaseWeChat):
|
|
1261
1261
|
data['file_id'] = file_id
|
1262
1262
|
|
1263
1263
|
# Insert.
|
1264
|
-
self.
|
1264
|
+
self.database_wechat.execute_insert(
|
1265
1265
|
(self.path_names['wechat'], self.path_names['wechat.message_send']),
|
1266
1266
|
data
|
1267
1267
|
)
|
reywechat/rwechat.py
CHANGED
@@ -40,7 +40,7 @@ class WeChat(BaseWeChat):
|
|
40
40
|
|
41
41
|
def __init__(
|
42
42
|
self,
|
43
|
-
|
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
|
-
|
54
|
-
- `
|
55
|
-
- `dict`, Set each `
|
56
|
-
`Key 'wechat'`: `
|
57
|
-
`Key 'file'`: `
|
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,
|
85
|
+
self.database = WeChatDatabase(self, database)
|
86
86
|
self.schedule = WeChatSchedule(self)
|
87
87
|
|
88
88
|
## Client.
|
@@ -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=
|
6
|
+
reywechat/rdb.py,sha256=JsBBZmASZd0rYqI0kwMmscTDlan2Z0T2aZlLycybQTs,41480
|
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=
|
12
|
+
reywechat/rwechat.py,sha256=Iir9EC0E3TmLElPf6k_Tkc7lZOr4uO1X9bpOZ0t0EV0,4884
|
13
13
|
reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
|
14
|
-
reywechat-1.0.
|
15
|
-
reywechat-1.0.
|
16
|
-
reywechat-1.0.
|
17
|
-
reywechat-1.0.
|
14
|
+
reywechat-1.0.36.dist-info/METADATA,sha256=9Wn2n48CxZ2OSV1l_HUs3PcziqDtAyMJXdp1b-7_DHY,1551
|
15
|
+
reywechat-1.0.36.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
reywechat-1.0.36.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
17
|
+
reywechat-1.0.36.dist-info/RECORD,,
|
File without changes
|
File without changes
|