forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chats.py
117 lines (102 loc) · 3.34 KB
/
chats.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}delchat`
Delete the group this cmd is used in.
• `{i}getlink`
Get link of group this cmd is used in.
• `{i}create (b|g|c) <group_name>`
Create group woth a specific name.
b - megagroup/supergroup
g - small group
c - channel
"""
from telethon.errors import ChatAdminRequiredError as no_admin
from telethon.tl import functions
from . import *
@ultroid_cmd(
pattern="delchat$",
groups_only=True,
)
async def _(e):
xx = await eor(e, "`Processing...`")
try:
await e.client(functions.channels.DeleteChannelRequest(e.chat_id))
except TypeError:
return await eod(xx, "`Cant delete this chat`", time=10)
except no_admin:
return await eod(xx, "`I m not an admin`", time=10)
await e.client.send_message(Var.LOG_CHANNEL, f"#Deleted\nDeleted {e.chat_id}")
@ultroid_cmd(
pattern="getlink$",
groups_only=True,
)
async def _(e):
xx = await eor(e, "`Processing...`")
try:
r = await e.client(
functions.messages.ExportChatInviteRequest(e.chat_id),
)
except no_admin:
return await eod(xx, "`I m not an admin`", time=10)
await eod(xx, f"Link:- {r.link}")
@ultroid_cmd(
pattern="create (b|g|c)(?: |$)(.*)",
)
async def _(e):
type_of_group = e.pattern_match.group(1)
group_name = e.pattern_match.group(2)
xx = await eor(e, "`Processing...`")
if type_of_group == "b":
try:
r = await e.client(
functions.messages.CreateChatRequest(
users=["@missrose_bot"],
title=group_name,
)
)
created_chat_id = r.chats[0].id
await e.client(
functions.messages.DeleteChatUserRequest(
chat_id=created_chat_id,
user_id="@missrose_bot",
)
)
result = await e.client(
functions.messages.ExportChatInviteRequest(
peer=created_chat_id,
)
)
await xx.edit(
f"Your [{group_name}]({result.link}) Group Made Boss!",
link_preview=False,
)
except Exception as ex:
await xx.edit(str(ex))
elif type_of_group == "g" or type_of_group == "c":
try:
r = await e.client(
functions.channels.CreateChannelRequest(
title=group_name,
about="Join @TeamUltroid",
megagroup=False if type_of_group == "c" else True,
)
)
created_chat_id = r.chats[0].id
result = await e.client(
functions.messages.ExportChatInviteRequest(
peer=created_chat_id,
)
)
await xx.edit(
f"Your [{group_name}]({result.link}) Group/Channel Has been made Boss!",
link_preview=False,
)
except Exception as ex:
await xx.edit(str(ex))
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})