patch 062bc6053a000038e9edcc0af8974851f9fe753d Author: E. Bosch Date: Sat Mar 19 06:11:26 CET 2022 * Wait for Telegram authentication is checked before the "not authorized yet" message is given on IRC (by TelegramServ). This is convenient if an IRC client connects faster than Telegram connection is established when irgramd is started, so it won't give a fake "not authorized yet" message. diff -rN -u old-irgramd/irc.py new-irgramd/irc.py --- old-irgramd/irc.py 2024-11-22 20:52:17.119017100 +0100 +++ new-irgramd/irc.py 2024-11-22 20:52:17.119017100 +0100 @@ -507,6 +507,7 @@ await self.send_msg(self.service_user, None, line, user) async def check_telegram_auth(self, user): + await self.tg.auth_checked.wait() if not self.tg.authorized and not self.tg.ask_code: for line in ( '----', diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py --- old-irgramd/telegram.py 2024-11-22 20:52:17.119017100 +0100 +++ new-irgramd/telegram.py 2024-11-22 20:52:17.123017094 +0100 @@ -12,6 +12,7 @@ import datetime import re import aioconsole +import asyncio import telethon from telethon import types as tgty @@ -51,6 +52,8 @@ self.channels_date = {} self.mid = mesg_id('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%+./_~') self.webpending = {} + # Set event to be waited by irc.check_telegram_auth() + self.auth_checked = asyncio.Event() async def initialize_telegram(self): # Setup media folder @@ -92,6 +95,7 @@ while not await self.telegram_client.is_user_authorized(): self.logger.info('Telegram account not authorized') await self.telegram_client.send_code_request(self.phone) + self.auth_checked.set() if not self.ask_code: return self.logger.info('You must provide the Login code that Telegram will ' @@ -107,6 +111,7 @@ async def continue_auth(self): self.logger.info('Telegram account authorized') self.authorized = True + self.auth_checked.set() await self.init_mapping() async def init_mapping(self):