From 9db9d1ed5c553c253b9e864435299f715c1d067a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 31 May 2018 22:39:32 +0200 Subject: [PATCH] Implement __bytes__ and use count instead sum --- telethon/tl/custom/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 6def2c0d..28b7cdb8 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -50,6 +50,9 @@ class Message: def __repr__(self): return repr(self.original_message) + def __bytes__(self): + return bytes(self.original_message) + @property def client(self): return self._client @@ -296,7 +299,7 @@ class Message: returns ``True``. The callable should accept a single `telethon.tl.custom.messagebutton.MessageButton` argument. """ - if sum(int(x is not None) for x in (i, text, filter)) >= 2: + if (i, text, filter).count(None) >= 2: raise ValueError('You can only set either of i, text or filter') if not self.buttons: