mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 12:53:44 +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._input_chat = None
|
||||||
self._chat = None
|
self._chat = None
|
||||||
|
|
||||||
|
self.pattern_match = None
|
||||||
|
|
||||||
self.is_private = isinstance(chat_peer, types.PeerUser)
|
self.is_private = isinstance(chat_peer, types.PeerUser)
|
||||||
self.is_group = (
|
self.is_group = (
|
||||||
isinstance(chat_peer, (types.PeerChat, types.PeerChannel))
|
isinstance(chat_peer, (types.PeerChat, types.PeerChannel))
|
||||||
|
@ -251,8 +253,12 @@ class NewMessage(_EventBuilder):
|
||||||
return
|
return
|
||||||
if self.outgoing and not event.message.out:
|
if self.outgoing and not event.message.out:
|
||||||
return
|
return
|
||||||
if self.pattern and not self.pattern(event.message.message or ''):
|
|
||||||
|
if self.pattern:
|
||||||
|
match = self.pattern(event.message.message or '')
|
||||||
|
if not match:
|
||||||
return
|
return
|
||||||
|
event.pattern_match = match
|
||||||
|
|
||||||
return self._filter_event(event)
|
return self._filter_event(event)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user