reywechat 1.0.70__py3-none-any.whl → 1.0.72__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/rclient.py CHANGED
@@ -11,6 +11,7 @@
11
11
 
12
12
  from typing import Any, TypedDict, Literal, Final
13
13
  from os.path import abspath as os_abspath
14
+ from reykit.rbase import throw
14
15
  from reykit.rdll import inject_dll
15
16
  from reykit.rnet import request as reykit_request
16
17
  from reykit.ros import find_relpath
@@ -678,6 +679,10 @@ class WeChatClient(WeChatBase):
678
679
  text : Message text.
679
680
  """
680
681
 
682
+ # Check.
683
+ if text == '':
684
+ throw(ValueError, text)
685
+
681
686
  # Handle parameter.
682
687
  api = 'sendTextMsg'
683
688
  data = {
@@ -708,6 +713,10 @@ class WeChatClient(WeChatBase):
708
713
  text : Message text.
709
714
  """
710
715
 
716
+ # Check.
717
+ if text == '':
718
+ throw(ValueError, text)
719
+
711
720
  # Handle parameter.
712
721
  api = 'sendAtText'
713
722
  if type(user_id) != str:
reywechat/rreceive.py CHANGED
@@ -202,7 +202,7 @@ class WeChatMessage(WeChatBase):
202
202
 
203
203
 
204
204
  @property
205
- def user_name(self) -> str:
205
+ def user_name(self) -> str | None:
206
206
  """
207
207
  Message sender user name.
208
208
 
@@ -211,6 +211,10 @@ class WeChatMessage(WeChatBase):
211
211
  User name.
212
212
  """
213
213
 
214
+ # Break.
215
+ if self.user is None:
216
+ return
217
+
214
218
  # Cache.
215
219
  if 'user_name' in self._cache:
216
220
  return self._cache['user_name']
@@ -329,7 +333,7 @@ class WeChatMessage(WeChatBase):
329
333
  if self.share_type == 1:
330
334
  self._cache['text'] = '[网址]'
331
335
  if self.share_params['title'] is not None:
332
- self._text += f' {self.share_params['title']}'
336
+ self._cache['text'] += f' {self.share_params['title']}'
333
337
 
334
338
  ### File uploaded.
335
339
  elif self.is_file_uploaded:
@@ -346,7 +350,7 @@ class WeChatMessage(WeChatBase):
346
350
  else:
347
351
  self._cache['text'] = f'[转发"{self.share_params['title']}"]'
348
352
  if self.share_params['desc'] is not None:
349
- self._text += f' {self.share_params['desc']}'
353
+ self._cache['text'] += f' {self.share_params['desc']}'
350
354
 
351
355
  ### Mini program.
352
356
  elif self.is_mini_program:
@@ -355,7 +359,7 @@ class WeChatMessage(WeChatBase):
355
359
  else:
356
360
  self._cache['text'] = f'[小程序"{self.share_params['name']}"分享]'
357
361
  if self.share_params['title'] is not None:
358
- self._text += f' {self.share_params['title']}'
362
+ self._cache['text'] += f' {self.share_params['title']}'
359
363
 
360
364
  ### Video channel.
361
365
  elif self.share_type == 51:
@@ -364,7 +368,7 @@ class WeChatMessage(WeChatBase):
364
368
  else:
365
369
  self._cache['text'] = f'[视频号"{self.share_params['name']}"分享]'
366
370
  if self.share_params['title'] is not None:
367
- self._text += f' {self.share_params['title']}'
371
+ self._cache['text'] += f' {self.share_params['title']}'
368
372
 
369
373
  ### Quote.
370
374
  elif self.is_quote:
@@ -389,9 +393,9 @@ class WeChatMessage(WeChatBase):
389
393
  else:
390
394
  self._cache['text'] = f'[APP"{self.share_params['name']}"分享]'
391
395
  if self.share_params["title"] is not None:
392
- self._text += f' {self.share_params["title"]}'
396
+ self._cache['text'] += f' {self.share_params["title"]}'
393
397
  if self.share_params["desc"] is not None:
394
- self._text += f' {self.share_params["desc"]}'
398
+ self._cache['text'] += f' {self.share_params["desc"]}'
395
399
 
396
400
  ### Other.
397
401
  else:
@@ -400,9 +404,9 @@ class WeChatMessage(WeChatBase):
400
404
  else:
401
405
  self._cache['text'] = f'["{self.share_params['name']}"分享]'
402
406
  if self.share_params["title"] is not None:
403
- self._text += f' {self.share_params["title"]}'
407
+ self._cache['text'] += f' {self.share_params["title"]}'
404
408
  if self.share_params["desc"] is not None:
405
- self._text += f' {self.share_params["desc"]}'
409
+ self._cache['text'] += f' {self.share_params["desc"]}'
406
410
 
407
411
  ## Voice call or video call.
408
412
  case 50:
@@ -566,7 +570,7 @@ class WeChatMessage(WeChatBase):
566
570
  if desc is None:
567
571
  desc: str | None = search('.*<desc>([^<>]+)</desc>', self.data)
568
572
  url: str | None = search('.*<url>([^<>]+)</url>', self.data)
569
- self._share_params: MessageShareParameters = {
573
+ self._cache['share_params'] = {
570
574
  'name': name,
571
575
  'title': title,
572
576
  'desc': desc,
@@ -781,7 +785,7 @@ class WeChatMessage(WeChatBase):
781
785
  quote_user_name: str = search(pattern, self.data)
782
786
  pattern = '<content>([^<>]+)</content>'
783
787
  quote_data: str = search(pattern, self.data)
784
- self._quote_params: MessageQuoteParameters = {
788
+ self._cache['quote_params'] = {
785
789
  'text': text,
786
790
  'quote_id': quote_id,
787
791
  'quote_time': quote_time,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.70
3
+ Version: 1.0.72
4
4
  Summary: WeChat method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reywechat/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -2,15 +2,15 @@ reywechat/__init__.py,sha256=FXc3XSiPLLmz9bgZdiYKxeWX-7VT9RqPc_EkXp3Kk0I,476
2
2
  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=5FIa8UB3VsLHT_EXHHmFP62a5AeS22anJCJXC8t4tWw,908
5
- reywechat/rclient.py,sha256=lc1CPle9h08mwP8NlJN0ybzcNJxtpV0ma6q6cz1RIxk,22518
5
+ reywechat/rclient.py,sha256=ayOtQ0CaF8ydXjirLdVed8FbpfdQVTKVSd0x4grs-pQ,22712
6
6
  reywechat/rdb.py,sha256=R3ZySPsLM5g0hChFBMxtG9MRZCZ433aMYa_LuggKK90,51010
7
7
  reywechat/rlog.py,sha256=TSA-_5pwlq0sUND2cnLDqXvdmAdMAkC7tXIz3WfJ7Xw,5259
8
- reywechat/rreceive.py,sha256=zT5mhXolmpaSkBuG-jL-Jt5ATVMwpyrSF3U5FamdyzU,50561
8
+ reywechat/rreceive.py,sha256=ndRLm9Y8hhOJUepa4PSURFhxfYCmgx23_zAZIQ0yCxg,50681
9
9
  reywechat/rsend.py,sha256=BB42r24x37V1tb27HLhnB_2tILv-DW26F9QbhqiNes8,20101
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.70.dist-info/METADATA,sha256=sr5yfSW75aD1S2oqSoWTUGEbmfUy_mg1mWDW1UfF8rI,1551
14
- reywechat-1.0.70.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- reywechat-1.0.70.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
- reywechat-1.0.70.dist-info/RECORD,,
13
+ reywechat-1.0.72.dist-info/METADATA,sha256=0BdkgMmH9rlg5rHX9xovbm9zlHOIfsuVH1Ls-xvDzUc,1551
14
+ reywechat-1.0.72.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ reywechat-1.0.72.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
16
+ reywechat-1.0.72.dist-info/RECORD,,