Files
limoka/Fl1yd/FTG-Modules/groupcreator.py
2025-07-10 21:02:34 +03:00

35 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from .. import loader, utils
from telethon.tl.functions.messages import CreateChatRequest, ExportChatInviteRequest, DeleteChatUserRequest
from telethon.tl.functions.channels import CreateChannelRequest
from telethon.errors import UserRestrictedError
def register(cb):
cb(GroupCreatorMod())
class GroupCreatorMod(loader.Module):
"""Создать чат или канал."""
strings = {'name': 'GroupCreator'}
async def createcmd(self, message):
"""Используй .create <g|s|c> <название>, чтобы создать группу, супергруппу или канал."""
args = utils.get_args_raw(message).split(' ')
try:
title = utils.get_args_raw(message).split(" ", 1)[1]
if 'g' in args[0]:
r = await message.client(CreateChatRequest(users=['missrose_bot'], title=title))
created_chat = r.chats[0].id
await message.client(DeleteChatUserRequest(chat_id=created_chat, user_id='@missrose_bot'))
elif 's' in args[0]:
r = await message.client(CreateChannelRequest(title=title, about='', megagroup=True))
elif 'c' in args[0]:
r = await message.client(CreateChannelRequest(title=title, about='', megagroup=False))
created_chat = r.chats[0].id
result = await message.client(ExportChatInviteRequest(peer=created_chat))
await message.edit(f'<b>Группа \"{title}\" создана.\nЛинк: {result.link}.</b>')
except IndexError:
return await message.edit('<b>Неверно указаны аргументы.</b>')
except UnboundLocalError:
return await message.edit('<b>Неверно указаны аргументы.</b>')
except UserRestrictedError:
return await message.edit('<b>У вас спамбан, вы не можете создавать каналы или группы.</b>')