reywechat 1.0.30__py3-none-any.whl → 1.0.31__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 +73 -18
- {reywechat-1.0.30.dist-info → reywechat-1.0.31.dist-info}/METADATA +1 -1
- {reywechat-1.0.30.dist-info → reywechat-1.0.31.dist-info}/RECORD +5 -5
- {reywechat-1.0.30.dist-info → reywechat-1.0.31.dist-info}/WHEEL +0 -0
- {reywechat-1.0.30.dist-info → reywechat-1.0.31.dist-info}/licenses/LICENSE +0 -0
reywechat/rreceive.py
CHANGED
@@ -134,6 +134,7 @@ class WeChatMessage(BaseWeChat):
|
|
134
134
|
self._is_at: bool | None = None
|
135
135
|
self._is_at_self: bool | None = None
|
136
136
|
self._is_call: bool | None = None
|
137
|
+
self._call_text: str | None = None
|
137
138
|
self._is_new_user: bool | None = None
|
138
139
|
self._is_new_room: bool | None = None
|
139
140
|
self._is_new_room_user: bool | None = None
|
@@ -414,7 +415,7 @@ class WeChatMessage(BaseWeChat):
|
|
414
415
|
text = self.data
|
415
416
|
elif self.is_quote:
|
416
417
|
text = self.quote_params['text']
|
417
|
-
pattern = r'
|
418
|
+
pattern = r'@(\w+)\u2005'
|
418
419
|
self._at_names = findall(pattern, text)
|
419
420
|
|
420
421
|
return self._at_names
|
@@ -455,8 +456,7 @@ class WeChatMessage(BaseWeChat):
|
|
455
456
|
return self._is_at_self
|
456
457
|
|
457
458
|
# Judge.
|
458
|
-
|
459
|
-
self._is_at_self = pattern in self.at_names
|
459
|
+
self._is_at_self = self.receiver.wechat.client.login_info['name'] in self.at_names
|
460
460
|
|
461
461
|
return self._is_at_self
|
462
462
|
|
@@ -464,7 +464,7 @@ class WeChatMessage(BaseWeChat):
|
|
464
464
|
@property
|
465
465
|
def is_call(self) -> bool:
|
466
466
|
"""
|
467
|
-
Whether if is message of call self.
|
467
|
+
Whether if is message of call self name.
|
468
468
|
|
469
469
|
Returns
|
470
470
|
-------
|
@@ -475,39 +475,83 @@ class WeChatMessage(BaseWeChat):
|
|
475
475
|
if self._is_call is not None:
|
476
476
|
return self._is_call
|
477
477
|
|
478
|
+
# Text.
|
479
|
+
if self.type == 1:
|
480
|
+
text = self.data
|
481
|
+
elif self.is_quote:
|
482
|
+
text = self.quote_params['text']
|
483
|
+
else:
|
484
|
+
self._is_call = False
|
485
|
+
self._call_text = None
|
486
|
+
return self._is_call
|
487
|
+
text = text.strip()
|
488
|
+
|
489
|
+
## At self.
|
490
|
+
at_self_keyword = '@%s\u2005' % self.receiver.wechat.client.login_info['name']
|
491
|
+
if at_self_keyword in text:
|
492
|
+
is_at_self = True
|
493
|
+
text = text.replace(at_self_keyword, '')
|
494
|
+
else:
|
495
|
+
is_at_self = False
|
496
|
+
|
497
|
+
## Call self.
|
498
|
+
pattern = fr'^{self.receiver.call_name}[\s,,]*(.*)$'
|
499
|
+
result: str | None = search(pattern, text)
|
500
|
+
if result is not None:
|
501
|
+
is_call_name = True
|
502
|
+
text = result
|
503
|
+
else:
|
504
|
+
is_call_name = False
|
505
|
+
|
478
506
|
# Judge.
|
479
|
-
is_call = False
|
480
507
|
if (
|
481
508
|
|
482
509
|
## Private chat.
|
483
510
|
self.room is None
|
484
511
|
|
485
512
|
## At self.
|
486
|
-
or
|
513
|
+
or is_at_self
|
514
|
+
|
515
|
+
## Call self.
|
516
|
+
or is_call_name
|
487
517
|
|
488
518
|
## Quote self.
|
489
519
|
or self.is_quote_self
|
520
|
+
|
490
521
|
):
|
491
522
|
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']
|
523
|
+
call_text = text
|
498
524
|
else:
|
499
|
-
|
500
|
-
|
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
|
525
|
+
is_call = False
|
526
|
+
call_text = None
|
505
527
|
|
506
528
|
self._is_call = is_call
|
529
|
+
self._call_text = call_text
|
507
530
|
|
508
531
|
return self._is_call
|
509
532
|
|
510
533
|
|
534
|
+
@property
|
535
|
+
def call_text(self) -> str:
|
536
|
+
"""
|
537
|
+
Message call text of call self name.
|
538
|
+
|
539
|
+
Returns
|
540
|
+
-------
|
541
|
+
Call text.
|
542
|
+
"""
|
543
|
+
|
544
|
+
# Cache.
|
545
|
+
if self._call_text is not None:
|
546
|
+
return self._call_text
|
547
|
+
|
548
|
+
# Check.
|
549
|
+
if not self.is_call:
|
550
|
+
throw(AssertionError, self.is_call)
|
551
|
+
|
552
|
+
return self._call_text
|
553
|
+
|
554
|
+
|
511
555
|
@property
|
512
556
|
def is_new_user(self) -> bool:
|
513
557
|
"""
|
@@ -845,6 +889,17 @@ class WeChatMessage(BaseWeChat):
|
|
845
889
|
return self._valid
|
846
890
|
|
847
891
|
|
892
|
+
@property
|
893
|
+
def check_call(self) -> None:
|
894
|
+
"""
|
895
|
+
Check if is call self name, if not, throw exception `WeChatTriggerContinueExit`.
|
896
|
+
"""
|
897
|
+
|
898
|
+
# Check.
|
899
|
+
if not self.is_call:
|
900
|
+
self.trigger_continue()
|
901
|
+
|
902
|
+
|
848
903
|
@overload
|
849
904
|
def reply(
|
850
905
|
self,
|
@@ -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=
|
8
|
+
reywechat/rreceive.py,sha256=0S7GZkLuUdLeccSQJT0-ASBqo_IFmNNQfwk_Qn-SC1E,34178
|
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
12
|
reywechat/rwechat.py,sha256=igeG0XhfBN1BRQ9RDmYrPZIKdnIK2tmS05wb-eMdlzs,4923
|
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.31.dist-info/METADATA,sha256=hx4R2CIjrn41MVLGtuLYKwrdiFZw97UQnzRxYfsc9Es,1551
|
15
|
+
reywechat-1.0.31.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
reywechat-1.0.31.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
17
|
+
reywechat-1.0.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|