def auth_2fa(self, window, password): request = aio.run(client.auth_2fa, (password,)) result = request.result() if result == 1: self.finish(window) else: print("Wrong password")
def login(self, window, phone_number): request = aio.run(client.login, (phone_number,)) auth = request.result() if auth == 1: window.confirm_code_page.set_visible_child_name('via-tg') window.page_carousel.scroll_to(window.confirm_code_page) window.prev_button.set_visible(True) window.confirm_code_tg.grab_focus() return auth
def send_code(self, window, code): # 0 - wrong code; 1 - need 2FA; 2 - all is ok request = aio.run(client.auth_code, (code,)) result = request.result() if result == 1: window.page_carousel.add(window.password_page) window.page_carousel.scroll_to(window.password_page) window.password.grab_focus() elif result == 2: self.finish(window) else: print("Wrong code")
def show_messages(self, window, chat_id): print(chat_id) actual_chat_id = self._get_actual_id(chat_id) if actual_chat_id not in self.loaded_chat_id: request = aio.run(client.get_messages, (chat_id, )) messages = request.result() self.loaded_chat_id.append(actual_chat_id) self.loaded_messages.append(messages) else: index = self.loaded_chat_id.index(actual_chat_id) messages = self.loaded_messages[index] window.update_messages_listbox(messages)
def show_dialogs(self, window): request = aio.run(client.get_dialogs, ()) dialogs = request.result() window.update_contacts_listbox(dialogs)