From fbd53e2126f8f46a86ed3bee824817a3dad793af Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 1 Feb 2018 12:10:03 +0100 Subject: [PATCH] Override TLObject's __eq__ and __ne__ methods --- telethon/tl/tlobject.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telethon/tl/tlobject.py b/telethon/tl/tlobject.py index db1982c4..b048158c 100644 --- a/telethon/tl/tlobject.py +++ b/telethon/tl/tlobject.py @@ -144,6 +144,12 @@ class TLObject: def on_response(self, reader): self.result = reader.tgread_object() + def __eq__(self, o): + return isinstance(o, type(self)) and self.to_dict() == o.to_dict() + + def __ne__(self, o): + return not isinstance(o, type(self)) or self.to_dict() != o.to_dict() + def __str__(self): return TLObject.pretty_format(self)