diff --git a/main.py b/main.py index 22e4f98..755567e 100644 --- a/main.py +++ b/main.py @@ -42,8 +42,61 @@ TextWithEntities, ) import re +import struct from functools import wraps import telethon.errors.rpcerrorlist +from telethon.tl.tlobject import TLRequest, TLObject + + +class GetForumTopicsRequest(TLRequest): + """ + Raw TL request for channels.getForumTopics. + Telethon 1.42 does not generate a wrapper for this method, + so we define it manually using the TL schema: + channels.getForumTopics#de560d1 flags:# channel:InputChannel + q:flags.0?string offset_date:int offset_id:int + offset_topic:int limit:int = messages.ForumTopics; + """ + CONSTRUCTOR_ID = 0x0de560d1 + SUBCLASS_OF_ID = 0x0 + + def __init__(self, channel, offset_date, offset_id, offset_topic, limit, q=None): + self.channel = channel + self.q = q + self.offset_date = offset_date + self.offset_id = offset_id + self.offset_topic = offset_topic + self.limit = limit + + async def resolve(self, client, utils): + self.channel = utils.get_input_channel(await client.get_input_entity(self.channel)) + + def _bytes(self): + flags = 0 + if self.q is not None: + flags |= 1 + return b''.join(( + struct.pack('