telegram, irc: Set topic in IRC with Telegram channel/chat description --> to head
patch 89bc0957a4fb31bf8066e338bc4548cd2d52c821
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Nov 2 20:20:45 CET 2024
* telegram, irc: Set topic in IRC with Telegram channel/chat description
hunk ./include.py 14
+MAX_LINE = 400
hunk ./irc.py 21
-from include import VERSION, CHAN_MAX_LENGTH, NICK_MAX_LENGTH
+from include import VERSION, CHAN_MAX_LENGTH, NICK_MAX_LENGTH, MAX_LINE
hunk ./irc.py 262
- await self.reply_code(user, 'RPL_LIST', (real_chan, users_count, topic))
+ await self.reply_code(user, 'RPL_LIST', (real_chan, users_count, topic[:MAX_LINE]))
hunk ./irc.py 615
- await self.reply_code(user, 'RPL_TOPIC', (channel, topic))
+ await self.reply_code(user, 'RPL_TOPIC', (channel, topic[:MAX_LINE]))
hunk ./telegram.py 18
-from telethon.tl.functions.messages import GetMessagesReactionsRequest
+from telethon.tl.functions.messages import GetMessagesReactionsRequest, GetFullChatRequest
+from telethon.tl.functions.channels import GetFullChannelRequest
hunk ./telegram.py 313
+ if isinstance(entity, tgty.Channel): [_$_]
+ full = await self.telegram_client(GetFullChannelRequest(channel=entity))
+ elif isinstance(entity, tgty.Chat):
+ full = await self.telegram_client(GetFullChatRequest(chat_id=tid))
+ else:
+ return ''
hunk ./telegram.py 320
- return 'Telegram ' + entity_type + ' ' + str(tid) + ': ' + entity.title
+ topic = full.full_chat.about
+ sep = ': ' if topic else ''
+ return entity_type + sep + topic
hunk ./utils.py 23
+from include import MAX_LINE
+
hunk ./utils.py 66
- MAX = 400
hunk ./utils.py 67
- wr = textwrap.TextWrapper(width=MAX)
+ wr = textwrap.TextWrapper(width=MAX_LINE)