From fe86b88bef96eaf2b8ed223205ba6c3ba109103d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 4 Sep 2017 18:07:20 +0200 Subject: [PATCH] Make .sign_up() return the logged user just like .sign_in() --- telethon/telegram_client.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 2f934af8..37e9b088 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -313,16 +313,13 @@ class TelegramClient(TelegramBareClient): def sign_up(self, code, first_name, last_name=''): """Signs up to Telegram. Make sure you sent a code request first!""" - result = self( - SignUpRequest( - phone_number=self._phone, - phone_code_hash=self._phone_code_hash, - phone_code=code, - first_name=first_name, - last_name=last_name)) - - self.session.user = result.user - self.session.save() + return self(SignUpRequest( + phone_number=self._phone, + phone_code_hash=self._phone_code_hash, + phone_code=code, + first_name=first_name, + last_name=last_name + )).user def log_out(self): """Logs out and deletes the current session.