reywechat 1.0.29__py3-none-any.whl → 1.0.30__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/rreceive.py CHANGED
@@ -133,6 +133,7 @@ class WeChatMessage(BaseWeChat):
133
133
  self._at_names: list[str] = None
134
134
  self._is_at: bool | None = None
135
135
  self._is_at_self: bool | None = None
136
+ self._is_call: bool | None = None
136
137
  self._is_new_user: bool | None = None
137
138
  self._is_new_room: bool | None = None
138
139
  self._is_new_room_user: bool | None = None
@@ -460,6 +461,53 @@ class WeChatMessage(BaseWeChat):
460
461
  return self._is_at_self
461
462
 
462
463
 
464
+ @property
465
+ def is_call(self) -> bool:
466
+ """
467
+ Whether if is message of call self.
468
+
469
+ Returns
470
+ -------
471
+ Judge result.
472
+ """
473
+
474
+ # Cache.
475
+ if self._is_call is not None:
476
+ return self._is_call
477
+
478
+ # Judge.
479
+ is_call = False
480
+ if (
481
+
482
+ ## Private chat.
483
+ self.room is None
484
+
485
+ ## At self.
486
+ or self.is_at_self
487
+
488
+ ## Quote self.
489
+ or self.is_quote_self
490
+ ):
491
+ is_call = True
492
+
493
+ ## Call name.
494
+ if self.type == 1:
495
+ text = self.data
496
+ elif self.is_quote:
497
+ text = self.quote_params['text']
498
+ else:
499
+ self._is_call = False
500
+ return self._is_call
501
+ pattern = fr'^\s*{self.receiver.call_name}[\s,,]*(.*?)\s*$'
502
+ result: str | None = search(pattern, text)
503
+ if result is not None:
504
+ is_call = True
505
+
506
+ self._is_call = is_call
507
+
508
+ return self._is_call
509
+
510
+
463
511
  @property
464
512
  def is_new_user(self) -> bool:
465
513
  """
@@ -907,7 +955,8 @@ class WechatReceiver(BaseWeChat):
907
955
  def __init__(
908
956
  self,
909
957
  wechat: WeChat,
910
- max_receiver: int
958
+ max_receiver: int,
959
+ call_name: str | None
911
960
  ) -> None:
912
961
  """
913
962
  Build instance attributes.
@@ -916,6 +965,8 @@ class WechatReceiver(BaseWeChat):
916
965
  ----------
917
966
  wechat : `WeChatClient` instance.
918
967
  max_receiver : Maximum number of receivers.
968
+ call_name : Trigger call name.
969
+ - `None`: Use account nickname.
919
970
  """
920
971
 
921
972
  # Import.
@@ -924,6 +975,9 @@ class WechatReceiver(BaseWeChat):
924
975
  # Set attribute.
925
976
  self.wechat = wechat
926
977
  self.max_receiver = max_receiver
978
+ if call_name is None:
979
+ call_name = self.wechat.client.login_info['name']
980
+ self.call_name = call_name
927
981
  self.queue: Queue[WeChatMessage] = Queue()
928
982
  self.handlers: list[Callable[[WeChatMessage], Any]] = []
929
983
  self.started: bool | None = False
reywechat/rwechat.py CHANGED
@@ -42,6 +42,7 @@ class WeChat(BaseWeChat):
42
42
  self,
43
43
  rrdatabase: Database | dict[Literal['wechat', 'file'], Database] | None,
44
44
  max_receiver: int = 2,
45
+ call_name: str | None = None,
45
46
  project_dir: str | None = None
46
47
  ) -> None:
47
48
  """
@@ -55,6 +56,8 @@ class WeChat(BaseWeChat):
55
56
  `Key 'wechat'`: `WeChatDatabase` instance used in WeChat methods.
56
57
  `Key 'file'`: `WeChatDatabase` instance used in file methods.
57
58
  max_receiver : Maximum number of receivers.
59
+ call_name : Trigger call name.
60
+ - `None`: Use account nickname.
58
61
  project_dir: Project directory, will create sub folders.
59
62
  - `None`: Use working directory.
60
63
  - `str`: Use this directory.
@@ -76,7 +79,7 @@ class WeChat(BaseWeChat):
76
79
  self.client = WeChatClient(self)
77
80
  self.cache = WeChatCache(self)
78
81
  self.log = WeChatLog(self)
79
- self.receiver = WechatReceiver(self, max_receiver)
82
+ self.receiver = WechatReceiver(self, max_receiver, call_name)
80
83
  self.trigger = self.receiver.trigger
81
84
  self.sender = WeChatSender(self)
82
85
  self.database = WeChatDatabase(self, rrdatabase)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reywechat
3
- Version: 1.0.29
3
+ Version: 1.0.30
4
4
  Summary: WeChat method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reywechat/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -5,13 +5,13 @@ reywechat/rcache.py,sha256=Hh_HE-t_KUMlrz4gEFPh1AjmhnrSgH520IFJPumWb7A,908
5
5
  reywechat/rclient.py,sha256=gtTYaoqhgh9kRFslETKjBJiAAdzJfeOxIJbdCkGAFhM,22577
6
6
  reywechat/rdb.py,sha256=Gcj3d-uIospaacjHY8B4HHdru5OwiS9PO6cceAWvXqY,40333
7
7
  reywechat/rlog.py,sha256=d3S0eHMUZ92OLE7fjP3zzikIYANtnbAxhnE_DIV_1OY,5251
8
- reywechat/rreceive.py,sha256=5emlgnIChYL60yx6PoQc1h5aGHFXNuFJ71a585gamEg,31550
8
+ reywechat/rreceive.py,sha256=VgDMNc_Lrnnm-eYinK-aCt1qXK1bEuyGYePSGrZtObk,32892
9
9
  reywechat/rschedule.py,sha256=fn11rH0HqxbnJYxARCBBiSdzBpYfQFhcjNmkvihVMTc,1854
10
10
  reywechat/rsend.py,sha256=s2sR6l74reDShBAu_MwpavVunz0g42pIga0zX4ElIuI,13717
11
11
  reywechat/rtrigger.py,sha256=GHfkhNrS8rV4uXWC3N54UTjak7nKGfqJWX6pe57Hsgg,4953
12
- reywechat/rwechat.py,sha256=K9fwje_Sos3Pvke8tFexDNZsRD7FsLtH3Jktg9xREpk,4788
12
+ reywechat/rwechat.py,sha256=igeG0XhfBN1BRQ9RDmYrPZIKdnIK2tmS05wb-eMdlzs,4923
13
13
  reywechat/data/client_api.dll,sha256=H9uj-x9Ztg0jFZK0yY6NsnyH5_119dQRFfoVVMidxRs,592384
14
- reywechat-1.0.29.dist-info/METADATA,sha256=GQNNn2iqWueYDLoZuKQGnmmQqMgEJlBPAtqQeFY3U3s,1551
15
- reywechat-1.0.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- reywechat-1.0.29.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
- reywechat-1.0.29.dist-info/RECORD,,
14
+ reywechat-1.0.30.dist-info/METADATA,sha256=ajAREqSPl0WJjajG78Ogwz7dftRrwy1-BtQykfUMqLg,1551
15
+ reywechat-1.0.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ reywechat-1.0.30.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
+ reywechat-1.0.30.dist-info/RECORD,,