-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreate.py
86 lines (80 loc) · 2.9 KB
/
create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Made By @legendx22
# Keep Credits else gay....
"""Create Private Groups
Available Commands:
.create (b|g) GroupName"""
from telethon.tl import functions
from ULTRA import CMD_HELP
from ULTRA.utils import admin_cmd, edit_or_reply, sudo_cmd
@bot.on(admin_cmd(pattern="create (b|g|c) (.*)")) # pylint:disable=E0602
@bot.on(sudo_cmd(pattern="create (b|g|c) (.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
type_of_group = event.pattern_match.group(1)
group_name = event.pattern_match.group(2)
event = await edit_or_reply(event, "Creating wait sar.....")
if type_of_group == "b":
try:
result = await event.client(
functions.messages.CreateChatRequest( # pylint:disable=E0602
users=["@sarah_robot"],
# Not enough users (to create a chat, for example)
# Telegram, no longer allows creating a chat with ourselves
title=group_name,
)
)
created_chat_id = result.chats[0].id
await event.client(
functions.messages.DeleteChatUserRequest(
chat_id=created_chat_id, user_id="@sarah_robot"
)
)
result = await event.client(
functions.messages.ExportChatInviteRequest(
peer=created_chat_id,
)
)
await event.edit(
"Group `{}` created successfully. Join {}".format(
group_name, result.link
)
)
except Exception as e: # pylint:disable=C0103,W0703
await event.edit(str(e))
elif type_of_group in ["g", "c"]:
try:
r = await event.client(
functions.channels.CreateChannelRequest(
title=group_name,
about="Created By LEGEND BOT",
megagroup=type_of_group != "c",
)
)
created_chat_id = r.chats[0].id
result = await event.client(
functions.messages.ExportChatInviteRequest(
peer=created_chat_id,
)
)
await event.edit(
"Channel `{}` created successfully. Join {}".format(
group_name, result.link
)
)
except Exception as e: # pylint:disable=C0103,W0703
await event.edit(str(e))
else:
await event.edit("Read `.plinfo create` to know how to use me")
CMD_HELP.update(
{
"create": "**SYNTAX :** `.create b`\
\n**USAGE : **Creates a super group and send you link\
\n\n**SYNTAX : **`.create g`\
\n**USAGE : **Creates a private group and sends you link\
\n\n**SYNTAX : **`.create c`\
\n**USAGE : **Creates a Channel and sends you link\
\n\nhere the bot accout is owner\
"
}
)