From 1d2420d549e87d237655abfdc8589e305b17fda1 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 11 Apr 2017 10:25:09 +0200 Subject: [PATCH] Add more informative error message when invoking disconnected --- telethon/telegram_client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index a3d8da6b..8e0b2c52 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -167,6 +167,9 @@ class TelegramClient: if not issubclass(type(request), MTProtoRequest): raise ValueError('You can only invoke MtProtoRequests') + if not self.sender: + raise ValueError('You must be connected to invoke requests!') + try: self.sender.send(request) self.sender.receive(request, timeout)