mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Allow access to events' pattern match (#654)
This commit is contained in:
parent
3655df50dc
commit
3184641549
|
@ -77,6 +77,8 @@ class _EventCommon(abc.ABC):
|
|||
self._input_chat = None
|
||||
self._chat = None
|
||||
|
||||
self.pattern_match = None
|
||||
|
||||
self.is_private = isinstance(chat_peer, types.PeerUser)
|
||||
self.is_group = (
|
||||
isinstance(chat_peer, (types.PeerChat, types.PeerChannel))
|
||||
|
@ -251,8 +253,12 @@ class NewMessage(_EventBuilder):
|
|||
return
|
||||
if self.outgoing and not event.message.out:
|
||||
return
|
||||
if self.pattern and not self.pattern(event.message.message or ''):
|
||||
return
|
||||
|
||||
if self.pattern:
|
||||
match = self.pattern(event.message.message or '')
|
||||
if not match:
|
||||
return
|
||||
event.pattern_match = match
|
||||
|
||||
return self._filter_event(event)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user