@loader.tds
class test(loader.Module):
'''test'''
strings = {
"name": "test",
async def client_ready(self, client, db):
result = await self.client(functions.channels.CreateChannelRequest(
title='FORUM_NAME',
about='ABOUT',
broadcast=False,
megagroup=True,
for_import=False,
forum=True
))
self.forum_id = result.chats[0].id
# create 1st topic
topic1_result = await self.client(functions.channels.CreateForumTopicRequest(
channel=self.forum_id,
title='TOPIC_NAME_1'
))
self.topic1_id = topic1_result.updates[0].id
# create 2nd topic
topic2_result = await self.client(functions.channels.CreateForumTopicRequest(
channel=self.forum_id,
title='TOPIC_NAME_2'
))
self.topic2_id = topic2_result.updates[0].id
def __init__(self):
self.forum_id = None
self.topic1_id = None
self.topic2_id = None
In the last thread, I had a question about how to create a forum with topics. I got the answer, but there was another question. How to make sure that another group is not created when reinstalling the module / rebooting the user bot.
The code is written using hikka.tl (telethon). Below I will give an example of creating a regular group, in the code below the group is not recreated when the module or the user bot is rebooted
async def client_ready(self, client, db):
self.test_channel, _ = await utils.asset_channel(
self._client,
"Test - chat",
"check descr",
silent=True,
archive=True,
_folder="m",
)
await self.client(functions.channels.InviteToChannelRequest(self.test_channel, ['@my_bot']))
await self.client(functions.channels.EditAdminRequest(
channel=self.test_channel,
user_id="@my_bot",
admin_rights=ChatAdminRights(ban_users=True, post_messages=True, edit_messages=True),
rank="xTest",
)
)
In the last thread, I had a question about how to create a forum with topics. I got the answer, but there was another question. How to make sure that another group is not created when reinstalling the module / rebooting the user bot.
The code is written using hikka.tl (telethon). Below I will give an example of creating a regular group, in the code below the group is not recreated when the module or the user bot is rebooted