reywechat 1.0.53__py3-none-any.whl → 1.0.55__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
@@ -319,7 +319,7 @@ class WeChatDatabase(WeChatBase):
319
319
  '51 is system synchronize data message, '
320
320
  '56 is real time position data message, '
321
321
  '1000 is system message, '
322
- '1002 is recall message, '
322
+ '1002 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,9 @@ 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.pat_text: str | None = None
189
+ self._is_recall: bool | None = None
184
190
  self._is_new_user: bool | None = None
185
191
  self._is_new_room: bool | None = None
186
192
  self._is_new_room_user: bool | None = None
@@ -414,8 +420,7 @@ class WeChatMessage(WeChatBase):
414
420
 
415
421
  ### File uploading.
416
422
  elif self.is_file_uploading:
417
- file_name: str = search('<title><![CDATA[([^<>]+)]]></title>', self.data)
418
- self._text = f'[文件"{file_name}"开始上传]'
423
+ self._text = f'[文件"{self.file_name_uploading}"开始上传]'
419
424
 
420
425
  ### Transfer money.
421
426
  elif self.is_money:
@@ -461,7 +466,14 @@ class WeChatMessage(WeChatBase):
461
466
 
462
467
  ## Recall.
463
468
  case 1002:
464
- self._text = '[撤回了一条消息]'
469
+
470
+ ### Pat.
471
+ if self.is_pat:
472
+ self._text = f'[{self.pat_text}]'
473
+
474
+ ### Recall.
475
+ elif self.is_recall:
476
+ self._text = '[撤回了一条消息]'
465
477
 
466
478
  case _:
467
479
  self._text = '[消息]'
@@ -634,6 +646,30 @@ class WeChatMessage(WeChatBase):
634
646
  return self._is_file_uploading
635
647
 
636
648
 
649
+ @property
650
+ def file_name_uploading(self) -> str:
651
+ """
652
+ Name of file uploading.
653
+
654
+ Returns
655
+ -------
656
+ Text
657
+ """
658
+
659
+ # Cache.
660
+ if self._file_name_uploading is not None:
661
+ return self._file_name_uploading
662
+
663
+ # Check.
664
+ if not self.is_file_uploading:
665
+ throw(AssertionError, self._is_file_uploading)
666
+
667
+ # Get.
668
+ self._file_name_uploading: str = search(r'<title><!\[CDATA\[([^<>]+)\]\]></title>', self.data)
669
+
670
+ return self._file_name_uploading
671
+
672
+
637
673
  @property
638
674
  def is_file_uploaded(self) -> bool:
639
675
  """
@@ -847,7 +883,7 @@ class WeChatMessage(WeChatBase):
847
883
  throw(AssertionError, self._is_money)
848
884
 
849
885
  # Judge.
850
- amount_str: str = search(r'<feedesc><![CDATA[¥([\d.,]+)]]></feedesc>', self.data)
886
+ amount_str: str = search(r'<feedesc><!\[CDATA\[¥([\d.,]+)\]\]></feedesc>', self.data)
851
887
  self._money_amount = float(amount_str)
852
888
 
853
889
  return self._money_amount
@@ -956,10 +992,9 @@ class WeChatMessage(WeChatBase):
956
992
  return self._is_call
957
993
 
958
994
  # Text.
959
- if self.type == 1:
960
- text = self.data
961
- elif self.is_quote:
962
- text = self.quote_params['text']
995
+ if self.type in (1, 3, 34, 42, 43, 47, 48, 49, 50, 56, 1002):
996
+ text = self.text
997
+ text = text.strip()
963
998
  else:
964
999
  self._is_call = False
965
1000
  self._call_text = None
@@ -1094,6 +1129,89 @@ class WeChatMessage(WeChatBase):
1094
1129
  return self.is_last_call
1095
1130
 
1096
1131
 
1132
+ @property
1133
+ def is_pat(self) -> bool:
1134
+ """
1135
+ Whether if is message of pat.
1136
+
1137
+ Returns
1138
+ -------
1139
+ Judge result.
1140
+ """
1141
+
1142
+ # Cache.
1143
+ if self._is_pat is not None:
1144
+ return self._is_pat
1145
+
1146
+ # Judge.
1147
+ self._is_pat = (
1148
+ self.type == 10002
1149
+ and self.data.startswith('<sysmsg type="pat">')
1150
+ )
1151
+
1152
+ return self._is_pat
1153
+
1154
+
1155
+ @property
1156
+ def pat_text(self) -> str:
1157
+ """
1158
+ Text of pat message.
1159
+
1160
+ Returns
1161
+ -------
1162
+ Text
1163
+ """
1164
+
1165
+ # Cache.
1166
+ if self._pat_text is not None:
1167
+ return self._pat_text
1168
+
1169
+ # Check.
1170
+ if not self.is_pat:
1171
+ throw(AssertionError, self._is_pat)
1172
+
1173
+ # Get.
1174
+
1175
+ ## Text.
1176
+ pattern = r'<template><!\[CDATA\[([^<>]+)\]\]></template>'
1177
+ text: str = search(pattern, self.data)
1178
+
1179
+ ## User name.
1180
+ pattern = r'"\$\{([a-z_\d]+)\}"'
1181
+ users_id: list[str] = findall(pattern, text)
1182
+ for user_id in users_id:
1183
+ user_name = self.receiver.wechat.client.get_contact_name(user_id)
1184
+ old_text = '${%s}' % user_id
1185
+ text = text.replace(old_text, user_name)
1186
+
1187
+ self._pat_text = text
1188
+
1189
+ return self._pat_text
1190
+
1191
+
1192
+ @property
1193
+ def is_recall(self) -> bool:
1194
+ """
1195
+ Whether if is message of recall.
1196
+
1197
+ Returns
1198
+ -------
1199
+ Judge result.
1200
+ """
1201
+
1202
+ # Cache.
1203
+ if self._is_recall is not None:
1204
+ return self._is_recall
1205
+
1206
+ # Judge.
1207
+ self._is_recall = (
1208
+ self.type == 10002
1209
+ and self.data.startswith('<sysmsg type="revokemsg">')
1210
+ )
1211
+
1212
+ return self._is_recall
1213
+
1214
+
1097
1215
  @property
1098
1216
  def is_new_user(self) -> bool:
1099
1217
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.53
3
+ Version: 1.0.55
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=SVW_tWaMDUaQH2nmD9Dyq-6QB2GV_ECKYbwwyGAwH3g,48349
7
7
  reywechat/rlog.py,sha256=4EsTgrgC05JvWeKAucUaWGga638CRRJISJN6qncBCAw,5249
8
- reywechat/rreceive.py,sha256=WoDKU_1BT3KdOD9y7M0sdfJFkzre6eTUMNCvWnyjYR8,48224
8
+ reywechat/rreceive.py,sha256=53U262MdMoDcJfJ08CBW2c2SRGghNnjergF9ZNXFshM,50993
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.53.dist-info/METADATA,sha256=zzKQxHhpq4J4VZWdp2rDIuaJQXC8k6CAjhbAJpGuxoI,1551
14
- reywechat-1.0.53.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- reywechat-1.0.53.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
- reywechat-1.0.53.dist-info/RECORD,,
13
+ reywechat-1.0.55.dist-info/METADATA,sha256=reH-YZ5i9VYDO--neT_f2oSWj6RoG5nPWFd3JKF30Fs,1551
14
+ reywechat-1.0.55.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ reywechat-1.0.55.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
+ reywechat-1.0.55.dist-info/RECORD,,