reywechat 1.0.54__py3-none-any.whl → 1.0.56__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
@@ -318,8 +318,8 @@ class WeChatDatabase(WeChatBase):
318
318
  '50 is voice call or video call invitation message, '
319
319
  '51 is system synchronize data message, '
320
320
  '56 is real time position data message, '
321
- '1000 is system message, '
322
- '1002 is recall message, '
321
+ '10000 is system message, '
322
+ '10002 is pat or recall message, '
323
323
  'other omit.'
324
324
  )
325
325
  },
reywechat/rreceive.py CHANGED
@@ -145,6 +145,8 @@ class WeChatMessage(WeChatBase):
145
145
  self.room = self.window
146
146
  if ':\n' in self.data:
147
147
  self.user, self.data = self.data.split(':\n', 1)
148
+ if self.user == self.room:
149
+ self.user = None
148
150
  else:
149
151
  self.user = None
150
152
  else:
@@ -164,6 +166,7 @@ class WeChatMessage(WeChatBase):
164
166
  self._share_type: int | None = None
165
167
  self._share_params: MessageShareParameter | None = None
166
168
  self._is_file_uploading: bool | None = None
169
+ self._file_name_uploading: str | None = None
167
170
  self._is_file_uploaded: bool | None = None
168
171
  self._is_forward: bool | None = None
169
172
  self._is_mini_program: bool | None = None
@@ -181,6 +184,10 @@ class WeChatMessage(WeChatBase):
181
184
  self._call_text: str | None = None
182
185
  self._is_call_next: bool | None = None
183
186
  self._is_last_call: bool | None = None
187
+ self._is_pat: bool | None = None
188
+ self._is_pat_me: bool | None = None
189
+ self._pat_text: str | None = None
190
+ self._is_recall: bool | None = None
184
191
  self._is_new_user: bool | None = None
185
192
  self._is_new_room: bool | None = None
186
193
  self._is_new_room_user: bool | None = None
@@ -414,8 +421,7 @@ class WeChatMessage(WeChatBase):
414
421
 
415
422
  ### File uploading.
416
423
  elif self.is_file_uploading:
417
- file_name: str = search('<title><![CDATA[([^<>]+)]]></title>', self.data)
418
- self._text = f'[文件"{file_name}"开始上传]'
424
+ self._text = f'[文件"{self.file_name_uploading}"开始上传]'
419
425
 
420
426
  ### Transfer money.
421
427
  elif self.is_money:
@@ -456,11 +462,15 @@ class WeChatMessage(WeChatBase):
456
462
  self._text = '[实时地图位置分享中]'
457
463
 
458
464
  ## System.
459
- case 1000:
465
+ case 10000:
460
466
  self._text = '[系统信息]'
461
467
 
468
+ ## Pat.
469
+ case 10002 if self.is_pat:
470
+ self._text = f'[{self.pat_text}]'
471
+
462
472
  ## Recall.
463
- case 1002:
473
+ case 10002 if self.is_recall:
464
474
  self._text = '[撤回了一条消息]'
465
475
 
466
476
  case _:
@@ -634,6 +644,30 @@ class WeChatMessage(WeChatBase):
634
644
  return self._is_file_uploading
635
645
 
636
646
 
647
+ @property
648
+ def file_name_uploading(self) -> str:
649
+ """
650
+ Name of file uploading.
651
+
652
+ Returns
653
+ -------
654
+ Text
655
+ """
656
+
657
+ # Cache.
658
+ if self._file_name_uploading is not None:
659
+ return self._file_name_uploading
660
+
661
+ # Check.
662
+ if not self.is_file_uploading:
663
+ throw(AssertionError, self._is_file_uploading)
664
+
665
+ # Get.
666
+ self._file_name_uploading: str = search(r'<title><!\[CDATA\[([^<>]+)\]\]></title>', self.data)
667
+
668
+ return self._file_name_uploading
669
+
670
+
637
671
  @property
638
672
  def is_file_uploaded(self) -> bool:
639
673
  """
@@ -847,7 +881,7 @@ class WeChatMessage(WeChatBase):
847
881
  throw(AssertionError, self._is_money)
848
882
 
849
883
  # Judge.
850
- amount_str: str = search(r'<feedesc><![CDATA[¥([\d.,]+)]]></feedesc>', self.data)
884
+ amount_str: str = search(r'<feedesc><!\[CDATA\[¥([\d.,]+)\]\]></feedesc>', self.data)
851
885
  self._money_amount = float(amount_str)
852
886
 
853
887
  return self._money_amount
@@ -956,7 +990,7 @@ class WeChatMessage(WeChatBase):
956
990
  return self._is_call
957
991
 
958
992
  # Text.
959
- if self.type in (1, 3, 34, 42, 43, 47, 48, 49, 50, 56, 1002):
993
+ if self.type in (1, 3, 34, 42, 43, 47, 48, 49, 50, 56, 10002):
960
994
  text = self.text
961
995
  text = text.strip()
962
996
  else:
@@ -991,6 +1025,9 @@ class WeChatMessage(WeChatBase):
991
1025
  ## Private chat.
992
1026
  or self.room is None
993
1027
 
1028
+ ## Pat me.
1029
+ or self.is_pat_me
1030
+
994
1031
  ## At self.
995
1032
  or is_at_me
996
1033
 
@@ -1093,6 +1130,113 @@ class WeChatMessage(WeChatBase):
1093
1130
  return self.is_last_call
1094
1131
 
1095
1132
 
1133
+ @property
1134
+ def is_pat(self) -> bool:
1135
+ """
1136
+ Whether if is message of pat.
1137
+
1138
+ Returns
1139
+ -------
1140
+ Judge result.
1141
+ """
1142
+
1143
+ # Cache.
1144
+ if self._is_pat is not None:
1145
+ return self._is_pat
1146
+
1147
+ # Judge.
1148
+ self._is_pat = (
1149
+ self.type == 10002
1150
+ and self.data.startswith('<sysmsg type="pat">')
1151
+ )
1152
+
1153
+ return self._is_pat
1154
+
1155
+
1156
+ @property
1157
+ def is_pat_me(self) -> bool:
1158
+ """
1159
+ Whether if is message of pat me.
1160
+
1161
+ Returns
1162
+ -------
1163
+ Judge result.
1164
+ """
1165
+
1166
+ # Cache.
1167
+ if self._is_pat_me is not None:
1168
+ return self._is_pat_me
1169
+
1170
+ # Judge.
1171
+ pattern = r'<template><!\[CDATA\["\$\{[\da-z_]+\}" 拍了拍我\]\]></template>'
1172
+ self._is_pat_me = (
1173
+ self.is_pat
1174
+ and search(pattern, self.data) is not None
1175
+ )
1176
+
1177
+ return self._is_pat_me
1178
+
1179
+
1180
+ @property
1181
+ def pat_text(self) -> str:
1182
+ """
1183
+ Text of pat message.
1184
+
1185
+ Returns
1186
+ -------
1187
+ Text
1188
+ """
1189
+
1190
+ # Cache.
1191
+ if self._pat_text is not None:
1192
+ return self._pat_text
1193
+
1194
+ # Check.
1195
+ if not self.is_pat:
1196
+ throw(AssertionError, self._is_pat)
1197
+
1198
+ # Get.
1199
+
1200
+ ## Text.
1201
+ pattern = r'<template><!\[CDATA\[([^<>]+)\]\]></template>'
1202
+ text: str = search(pattern, self.data)
1203
+
1204
+ ## User name.
1205
+ pattern = r'"\$\{([\da-z_]+)\}"'
1206
+ users_id: list[str] = findall(pattern, text)
1207
+ for user_id in users_id:
1208
+ user_name = self.receiver.wechat.client.get_contact_name(user_id)
1209
+ old_text = '${%s}' % user_id
1210
+ text = text.replace(old_text, user_name)
1211
+
1212
+ self._pat_text = text
1213
+
1214
+ return self._pat_text
1215
+
1216
+
1217
+ @property
1218
+ def is_recall(self) -> bool:
1219
+ """
1220
+ Whether if is message of recall.
1221
+
1222
+ Returns
1223
+ -------
1224
+ Judge result.
1225
+ """
1226
+
1227
+ # Cache.
1228
+ if self._is_recall is not None:
1229
+ return self._is_recall
1230
+
1231
+ # Judge.
1232
+ self._is_recall = (
1233
+ self.type == 10002
1234
+ and self.data.startswith('<sysmsg type="revokemsg">')
1235
+ )
1236
+
1237
+ return self._is_recall
1238
+
1239
+
1096
1240
  @property
1097
1241
  def is_new_user(self) -> bool:
1098
1242
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.54
3
+ Version: 1.0.56
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,14 +3,14 @@ reywechat/rall.py,sha256=5J_X-XMOyb1Vp1jyS9-oRFXGOtp2vRPX1g3tJot_Eck,371
3
3
  reywechat/rbase.py,sha256=hbxn5spvcl_C_Bw8A9teulOXT9GMlxUw145_YbXIOzc,1124
4
4
  reywechat/rcache.py,sha256=7UsHHfgFOgxuSqlTSAO6CprgUUOeBCXYus0kxmRBQxk,908
5
5
  reywechat/rclient.py,sha256=lc1CPle9h08mwP8NlJN0ybzcNJxtpV0ma6q6cz1RIxk,22518
6
- reywechat/rdb.py,sha256=KfGo6OlTwh4p78VCGqw8lI6cNFGM2CSlpp1OpF7sqSI,48342
6
+ reywechat/rdb.py,sha256=4or5HV_U4mZwRSiK1fa1wZkhh_KfdtkYoWkEdBDov_Q,48351
7
7
  reywechat/rlog.py,sha256=4EsTgrgC05JvWeKAucUaWGga638CRRJISJN6qncBCAw,5249
8
- reywechat/rreceive.py,sha256=AubilVG1e95gukkhlFL9V7WjhRTbkGaqPxSPehTbf4Q,48225
8
+ reywechat/rreceive.py,sha256=sdTxF6g4094AZu1lLswcZki21ZfmKIcjZ0520UWLq54,51584
9
9
  reywechat/rsend.py,sha256=aTmc1ycL8bon4KXoX7VpRWQKTsVER6f6bRLKWWvPspY,18049
10
10
  reywechat/rtrigger.py,sha256=WdOQwobPdGPyyE9J-qtQFPd60713T0aWqKk02PLdCRE,4966
11
11
  reywechat/rwechat.py,sha256=g0pbprMPv_qWb_lGFrPDAWsJO4vPSIgFLkw0Y28CZUo,4751
12
12
  reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
13
- reywechat-1.0.54.dist-info/METADATA,sha256=qDFNVoRlHH9WQ1ej-wQR_eTifKOeGmn8eNo6aTjlWmA,1551
14
- reywechat-1.0.54.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- reywechat-1.0.54.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
- reywechat-1.0.54.dist-info/RECORD,,
13
+ reywechat-1.0.56.dist-info/METADATA,sha256=kXh3hk31yQmrqGSTMO1qP5SFuh8cgEofH7X17eJQVxk,1551
14
+ reywechat-1.0.56.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ reywechat-1.0.56.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
+ reywechat-1.0.56.dist-info/RECORD,,