Fix incoming = outgoing = True not working

This commit is contained in:
Lonami Exo 2018-07-29 13:03:10 +02:00
parent 72a04a877f
commit 96742334a4

View File

@ -40,13 +40,12 @@ class NewMessage(EventBuilder):
def __init__(self, chats=None, *, blacklist_chats=False,
incoming=None, outgoing=None,
from_users=None, forwards=None, pattern=None):
if incoming is not None and outgoing is None:
if incoming and outgoing:
incoming = outgoing = None # Same as no filter
elif incoming is not None and outgoing is None:
outgoing = not incoming
elif outgoing is not None and incoming is None:
incoming = not outgoing
if incoming and outgoing:
self.incoming = self.outgoing = None # Same as no filter
elif all(x is not None and not x for x in (incoming, outgoing)):
raise ValueError("Don't create an event handler if you "
"don't want neither incoming or outgoing!")