Spaces:
Runtime error
Runtime error
File size: 17,632 Bytes
78b07ad |
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
import random
from pyrogram import Client
from pyrogram.enums import ChatMembersFilter, ChatMemberStatus
from pyrogram.types import Message
from Hellbot.functions.media import get_media_fileid
from Hellbot.functions.templates import chat_info_templates
from . import HelpMenu, group_n_channel, hellbot, on_message
kickme_quotes = [
"โ๏ธ ๐ฎ๐๐๐๐บ ๐๐พ๐๐พ, ๐
๐พ๐บ๐๐๐๐ ๐๐๐พ ๐๐๐บ๐๐พ ๐๐ ๐๐๐พ ๐๐พ๐บ๐
๐๐๐บ๐๐!",
"๐ ๐ค๐
๐พ๐๐บ๐๐๐๐ ๐๐ ๐๐๐ป๐พ๐, ๐
๐พ๐บ๐๐๐๐ ๐๐๐พ ๐ผ๐๐บ๐ ๐๐ ๐๐๐๐
๐พ.",
"๐๏ธ ๐ฅ๐
๐๐๐๐ ๐๐๐
๐, ๐พ๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐๐ ๐๐๐บ๐ผ๐พ๐ฟ๐๐
๐
๐.",
"๐ช๏ธ ๐ฒ๐๐๐๐๐๐๐ ๐๐ ๐๐๐พ ๐๐๐๐ฝ๐ ๐๐ฟ ๐ฝ๐พ๐๐บ๐๐๐๐๐พ, ๐ป๐๐พ!",
"๐ถโโ๏ธ ๐ถ๐บ๐
๐๐๐๐ ๐บ๐๐บ๐ ๐
๐๐๐พ ๐บ ๐ป๐๐๐, ๐๐พ๐พ ๐๐๐ ๐๐พ๐๐พ๐!",
"๐ฅ ๐ก๐๐๐๐๐๐ ๐ป๐๐๐ฝ๐๐พ๐ ๐บ๐๐ฝ ๐ผ๐๐พ๐บ๐๐๐๐ ๐๐ ๐๐๐ ๐๐บ๐๐. ๐ ๐ฝ๐๐๐!",
"๐ซ ๐ณ๐๐๐๐๐๐ ๐๐๐พ ๐๐บ๐๐พ ๐บ๐๐ฝ ๐ผ๐
๐๐๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐๐๐พ๐.",
"๐ ๐ข๐๐๐๐'๐ ๐๐๐ ๐๐พ๐บ๐๐ ๐ฟ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐จ'๐ ๐๐๐!",
"๐โโ๏ธ ๐ฒ๐๐๐๐๐๐๐๐ ๐๐๐ ๐๐ฟ ๐๐พ๐๐พ ๐๐๐๐ ๐ฟ๐
๐บ๐๐. ๐ข๐บ๐๐ผ๐ ๐๐๐ ๐๐พ๐๐พ๐!",
"๐ค ๐ฒ๐บ๐๐
๐๐๐ ๐บ๐๐บ๐ ๐ฟ๐๐๐ ๐๐๐๐ ๐๐๐๐๐ ๐ผ๐๐บ๐, ๐๐๐๐๐๐ ๐๐พ๐บ๐ ๐บ๐๐พ๐บ๐ฝ!",
"๐ ๐ซ๐๐๐พ ๐บ ๐
๐พ๐บ๐ฟ ๐๐ ๐๐๐พ ๐๐๐๐ฝ, ๐จ'๐ ๐ฝ๐๐๐ฟ๐๐๐๐ ๐บ๐๐บ๐. ๐ฅ๐บ๐๐พ๐๐พ๐
๐
!",
"๐ซ ๐ณ๐บ๐๐๐๐ ๐๐ฟ๐ฟ ๐ฟ๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐ ๐๐๐๐๐บ๐. ๐ก๐๐ ๐๐๐๐บ๐๐พ!",
"๐ผ ๐ข๐
๐๐๐๐๐ ๐๐๐พ ๐ป๐๐๐พ๐ฟ๐ผ๐บ๐๐พ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ฏ๐๐๐ฟ๐พ๐๐๐๐๐๐บ๐
๐พ๐๐๐!",
"๐ญ ๐ค๐๐๐๐๐๐ ๐๐๐พ ๐๐๐บ๐๐พ ๐๐๐๐ ๐บ ๐ฝ๐๐บ๐๐บ๐๐๐ผ ๐ฟ๐
๐บ๐๐. ๐ณ๐บ-๐ฝ๐บ!",
"๐ถ ๐ฏ๐
๐บ๐๐๐๐ ๐๐ ๐พ๐๐๐ ๐๐๐๐๐ผ. ๐ข๐๐พ ๐๐๐พ ๐ฟ๐บ๐๐พ๐๐พ๐
๐
๐๐๐๐๐๐๐๐!",
"๐ถ๏ธ ๐ฅ๐บ๐ฝ๐๐๐ ๐๐๐๐ ๐๐๐พ ๐๐๐บ๐ฝ๐๐๐, ๐
๐พ๐บ๐๐๐๐ ๐บ๐ ๐บ๐๐ ๐๐ฟ ๐๐๐๐๐พ๐๐.",
"๐ช ๐ข๐
๐๐๐๐๐ ๐๐๐พ ๐ฝ๐๐๐ ๐๐๐๐พ๐๐
๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ค๐๐๐ ๐ผ๐๐๐๐
๐พ๐๐พ!",
"๐ ๐ซ๐๐ผ๐๐๐๐ ๐๐๐พ ๐ผ๐๐บ๐ ๐ป๐พ๐๐๐๐ฝ ๐๐พ. ๐ช๐พ๐พ๐ ๐๐ ๐๐๐๐
๐๐๐, ๐ฟ๐๐
๐๐!",
"๐ ๐ต๐บ๐๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐พ ๐ผ๐๐๐๐๐ผ ๐บ๐ป๐๐๐. ๐ฒ๐พ๐พ ๐๐๐ ๐๐ ๐๐๐พ ๐๐๐บ๐๐!",
"๐ ๐ก๐๐พ๐บ๐๐๐๐ ๐ฟ๐๐พ๐พ ๐ฟ๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ด๐๐
๐พ๐บ๐๐๐๐๐ ๐๐ ๐๐๐
๐ ๐๐๐๐๐๐พ๐!",
"๐ ๐ค๐๐๐๐๐๐ ๐๐๐บ๐ผ๐พ๐ฟ๐๐
๐
๐. ๐ณ๐๐๐ ๐ผ๐๐บ๐ ๐ผ๐๐๐
๐ฝ๐'๐ ๐๐บ๐๐ฝ๐
๐พ ๐๐ ๐๐๐๐
๐พ.",
"๐ ๐ณ๐๐๐พ ๐ฟ๐๐ ๐๐พ ๐๐ ๐ป๐
๐บ๐๐ ๐๐ฟ๐ฟ. ๐ ๐ฝ๐๐๐, ๐บ๐๐๐๐๐!",
"๐ช๏ธ ๐ฒ๐๐๐๐๐๐๐ ๐๐ ๐๐๐พ ๐ฝ๐๐บ๐๐บ ๐บ๐๐ฝ ๐๐บ๐๐๐๐ ๐๐ ๐พ๐๐๐.",
]
@on_message(
"setgpic",
chat_type=group_n_channel,
admin_only=True,
allow_stan=True,
)
async def setgpic(_, message: Message):
if not message.reply_to_message or not message.reply_to_message.photo:
return await hellbot.delete(
message, "๐ฑ๐พ๐๐
๐ ๐๐ ๐บ ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐๐๐๐๐ ๐๐๐๐ฟ๐๐
๐พ ๐๐๐ผ๐๐๐๐พ."
)
status = await message.chat.set_photo(photo=message.reply_to_message.photo.file_id)
if not status:
return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.")
await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐
๐
๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐๐ฟ๐๐
๐พ ๐๐๐ผ๐๐๐๐พ.")
await hellbot.check_and_log(
"setgpic",
f"**Group Profile Picture**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`",
)
@on_message(
"setgtitle",
chat_type=group_n_channel,
admin_only=True,
allow_stan=True,
)
async def setgtitle(_, message: Message):
if len(message.command) < 2:
return await hellbot.delete(
message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐
๐พ."
)
prev_title = message.chat.title
new_title = await hellbot.input(message)
status = await message.chat.set_title(new_title)
if not status:
return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.")
await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐
๐
๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐๐
๐พ.")
await hellbot.check_and_log(
"setgtitle",
f"**Group Title**\n\n**Group:** `{prev_title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`",
)
@on_message(
"setgabout",
chat_type=group_n_channel,
admin_only=True,
allow_stan=True,
)
async def setgabout(_, message: Message):
if len(message.command) < 2:
return await hellbot.delete(
message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐ ๐บ๐ป๐๐๐."
)
new_about = await hellbot.input(message)
status = await message.chat.set_description(new_about)
if not status:
return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.")
await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐
๐
๐ ๐๐พ๐ ๐๐๐๐๐ ๐บ๐ป๐๐๐.")
await hellbot.check_and_log(
"setgabout",
f"**Group About**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`",
)
@on_message(
"setgusername",
chat_type=group_n_channel,
admin_only=True,
allow_stan=True,
)
async def setgusername(client: Client, message: Message):
user_status = (await message.chat.get_member(message.from_user.id)).status
if user_status != ChatMemberStatus.OWNER:
return await hellbot.delete(message, "๐จ ๐บ๐ ๐๐๐ ๐๐๐พ ๐๐๐๐พ๐ ๐๐ฟ ๐๐๐๐ ๐๐๐๐๐.")
if len(message.command) < 2:
return await hellbot.delete(
message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐'๐ ๐๐๐พ๐๐๐บ๐๐พ."
)
new_username = await hellbot.input(message)
status = await client.set_chat_username(message.chat.id, new_username)
if not status:
return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.")
await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐
๐
๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐พ๐๐๐บ๐๐พ.")
await hellbot.check_and_log(
"setgusername",
f"**Group Username**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`",
)
@on_message(
"getglink",
chat_type=group_n_channel,
admin_only=True,
allow_stan=True,
)
async def getglink(_, message: Message):
link = await message.chat.export_invite_link()
await hellbot.delete(message, f"**๐ฆ๐๐๐๐ ๐
๐๐๐:** `{link}`")
@on_message("kickme", chat_type=group_n_channel, allow_stan=True)
async def kickme(client: Client, message: Message):
hell = await hellbot.edit(message, random.choice(kickme_quotes))
try:
await client.leave_chat(message.chat.id)
except Exception as e:
return await hellbot.delete(
hell, f"Deym! Can't leave this chat.\n**Error:** `{e}`"
)
@on_message("newgroup", allow_stan=True)
async def new_group(client: Client, message: Message):
if len(message.command) < 2:
return await hellbot.delete(message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐๐๐๐๐ ๐๐๐๐
๐พ.")
new_title = await hellbot.input(message)
try:
new_group = await client.create_group(new_title, hellbot.bot.me.id)
await hellbot.edit(
message, f"**๐ฆ๐๐๐๐ ๐
๐๐๐:** [{new_group.title}]({new_group.invite_link})"
)
except Exception as e:
await hellbot.error(message, f"`{e}`", 20)
@on_message("newchannel", allow_stan=True)
async def new_channel(client: Client, message: Message):
if len(message.command) < 2:
return await hellbot.delete(
message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐ผ๐๐บ๐๐๐พ๐
๐๐๐๐
๐พ."
)
new_title = await hellbot.input(message)
try:
new_channel = await client.create_channel(new_title, "Created by HellBot")
await hellbot.edit(
message, f"**๐ข๐๐บ๐๐๐พ๐
๐
๐๐๐:** [{new_channel.title}]({new_channel.username})"
)
except Exception as e:
await hellbot.error(message, f"`{e}`", 20)
@on_message("chatinfo", allow_stan=True)
async def chatInfo(client: Client, message: Message):
if len(message.command) > 1:
try:
chat = await client.get_chat(message.command[1])
except Exception as e:
return await hellbot.error(message, f"`{e}`")
else:
chat = message.chat
hell = await hellbot.edit(message, "Fetching chat info...")
if chat.invite_link:
chat_link = f"[Invite Link]({chat.invite_link})"
elif chat.username:
chat_link = f"@{chat.username}"
else:
chat_link = "Private Chat"
chat_owner = None
admins_count = 0
bots_count = 0
async for admin in client.get_chat_members(
chat.id, filter=ChatMembersFilter.ADMINISTRATORS
):
admins_count += 1
if admin.status == ChatMemberStatus.OWNER:
chat_owner = admin.user.mention
async for _ in client.get_chat_members(chat.id, filter=ChatMembersFilter.BOTS):
bots_count += 1
chat_info = await chat_info_templates(
chatName=chat.title,
chatId=chat.id,
chatLink=chat_link,
chatOwner=chat_owner,
dcId=chat.dc_id,
membersCount=chat.members_count,
adminsCount=admins_count,
botsCount=bots_count,
description=chat.description,
)
if chat.photo:
async for photo in client.get_chat_photos(chat.id, 1):
await hell.delete()
await client.send_photo(
message.chat.id,
photo.file_id,
caption=chat_info,
reply_to_message_id=message.id,
disable_notification=True,
)
return
else:
await hell.edit(chat_info, disable_web_page_preview=True)
@on_message("chatadmins", allow_stan=True)
async def chatAdmins(client: Client, message: Message):
if len(message.command) < 2:
chat = message.chat
else:
try:
chat = await client.get_chat(message.command[1])
except Exception as e:
return await hellbot.error(message, f"`{e}`")
hell = await hellbot.edit(message, "Fetching chat admins...")
admin_count = 0
admins = "**๐ซ ๐ ๐ฝ๐๐๐๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐:**\n\n"
async for admin in client.get_chat_members(
chat.id, filter=ChatMembersFilter.ADMINISTRATORS
):
admin_count += 1
admins += f"**{'0' if admin_count < 10 else ''}{admin_count}:** {admin.user.mention} - `{admin.status}`\n"
await hell.edit(admins, disable_web_page_preview=True)
@on_message("chatbots", allow_stan=True)
async def chatBots(client: Client, message: Message):
if len(message.command) < 2:
chat = message.chat
else:
try:
chat = await client.get_chat(message.command[1])
except Exception as e:
return await hellbot.error(message, f"`{e}`")
hell = await hellbot.edit(message, "Fetching chat bots...")
bot_count = 0
bots = "**๐ค ๐ก๐๐๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐:**\n\n"
async for bot in client.get_chat_members(chat.id, filter=ChatMembersFilter.BOTS):
bot_count += 1
bots += (
f"**{'0' if bot_count < 10 else ''}{bot_count}:** @{bot.user.username}\n"
)
await hell.edit(bots, disable_web_page_preview=True)
@on_message("id", allow_stan=True)
async def chatId(_, message: Message):
if message.reply_to_message:
msg = message.reply_to_message
else:
msg = message
hell = await hellbot.edit(message, "Fetching message info...")
info = f"**๐ซ ChatID:** `{msg.chat.id}`\n"
info += f"**๐ชช MessageID:** `{msg.id}`\n\n"
if msg.from_user:
info += f"**๐ค UserID:** `{msg.from_user.id}`\n\n"
if msg.forward_from:
info += f"**๐ค Forwarded From:** `{msg.forward_from.id}`\n\n"
if msg.forward_from_chat:
info += f"**๐ซ Forwarded ChatID:** `{msg.forward_from_chat.id}`\n\n"
file_id = await get_media_fileid(msg)
if file_id:
info += f"**๐ FileID:** `{file_id}`\n\n"
await hell.edit(info, disable_web_page_preview=True)
@on_message("invite", allow_stan=True)
async def inviteUser(client: Client, message: Message):
if len(message.command) < 2:
return await hellbot.delete(
message, "I need a username/id to invite to this chat."
)
users = (await hellbot.input(message)).split(" ")
hell = await hellbot.edit(message, "Inviting users...")
resolved_users = await client.get_users(users)
await message.chat.add_members([user.id for user in resolved_users])
await hell.edit("Successfully invited users to this chat.")
HelpMenu("groups").add(
"setgpic", "<reply to photo>", "Set the group profile picture.", "setgpic"
).add("setgtitle", "<title>", "Set the group title.", "setgtitle chat group").add(
"setgabout",
"<text>",
"Set the group description/about",
"setgabout some group description",
).add(
"setgusername",
"<username>",
"Set the group username.",
"setgusername HellBot_Chats",
"Only group owners can use this command. Give username without '@'.",
).add(
"getglink", None, "Get the group invite link.", "getglink"
).add(
"kickme", None, "Leave the chat in swag ๐!", "kickme"
).add(
"newgroup", "<title>", "Create a new group.", "newgroup HellBot Group"
).add(
"newchannel", "<title>", "Create a new channel.", "newchannel HellBot Channel"
).add(
"chatinfo", "<chat id (optional)>", "Get info about the chat.", "chatinfo"
).add(
"chatadmins",
"<chat id (optional)>",
"Get the list of admins of mentioned chat.",
"chatadmins @Hellbot_Chats",
).add(
"chatbots",
"<chat id (optional)>",
"Get the list of bots of mentioned chat.",
"chatbots @Hellbot_Chats",
).add(
"id",
"<reply to message (optional)>",
"Get the ID of the replied message, replied user, and more.",
"id",
).add(
"invite",
"<username/id>",
"Invite the mentioned user to this chat.",
"invite @ForGo10God",
"You can invite multiple users by giving their username/id separated by space.",
).info(
"Group Menu"
).done()
|