Spaces:
Runtime error
Runtime error
File size: 20,007 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
import asyncio
from pyrogram import Client, filters
from pyrogram.types import ChatPermissions, ChatPrivileges, Message
from Hellbot.core import LOGS
from . import HelpMenu, custom_handler, db, group_only, handler, hellbot, on_message
@on_message(
"promote",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def promote(client: Client, message: Message):
if len(message.command) < 2 and not message.reply_to_message:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ πππππππΎ πππΎπ!"
)
if message.reply_to_message:
user = message.reply_to_message.from_user
title = await hellbot.input(message)
else:
user = await client.get_users(message.command[1])
title = (await hellbot.input(message)).split(" ", 1)[1].strip() or ""
try:
privileges = ChatPrivileges(
can_manage_chat=True,
can_delete_messages=True,
can_manage_video_chats=True,
can_restrict_members=False,
can_promote_members=False,
can_change_info=False,
can_invite_users=True,
can_pin_messages=True,
is_anonymous=False,
)
await message.chat.promote_member(user.id, privileges)
await client.set_administrator_title(message.chat.id, user.id, title)
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(message, f"**π« π―ππππππΎπ½ {user.mention} πππΌπΌπΎπππΏππ
π
π!**")
await hellbot.check_and_log(
"promote",
f"**Promoted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"demote",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def demote(client: Client, message: Message):
if len(message.command) < 2 and not message.reply_to_message:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ π½πΎππππΎ πππΎπ!"
)
if message.reply_to_message:
user = message.reply_to_message.from_user
else:
user = await client.get_users(message.command[1])
try:
privileges = ChatPrivileges(
can_manage_chat=False,
can_delete_messages=False,
can_manage_video_chats=False,
can_restrict_members=False,
can_promote_members=False,
can_change_info=False,
can_invite_users=False,
can_pin_messages=False,
is_anonymous=False,
)
await message.chat.promote_member(user.id, privileges)
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(message, f"**π π£πΎππππΎπ½ {user.mention} πππΌπΌπΎπππΏππ
π
π!**")
await hellbot.check_and_log(
"demote",
f"**Demoted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
["ban", "dban"],
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def ban(client: Client, message: Message):
if message.reply_to_message:
user = message.reply_to_message.from_user
if len(message.command) < 2:
reason = None
else:
reason = await hellbot.input(message)
if message.command[0][0].lower() == "d":
await message.reply_to_message.delete()
elif len(message.command) == 2:
user = await client.get_users(message.command[1])
reason = None
elif len(message.command) > 2:
user = await client.get_users(message.command[1])
reason = (await hellbot.input(message)).split(" ", 1)[1].strip()
else:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ π»πΊπ πππΎπ!"
)
try:
await message.chat.ban_member(user.id)
except Exception as e:
return await hellbot.error(message, e)
reason = reason if reason else "Not Specified"
await hellbot.delete(
message,
f"**β οΈ π‘πΊπππΎπ½ {user.mention} πππΌπΌπΎπππΏππ
π
π!**\n**π±πΎπΊπππ:** `{reason}`",
30,
)
await hellbot.check_and_log(
"ban",
f"**Banned User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Reason:** `{reason}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"unban",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def unban(client: Client, message: Message):
if len(message.command) < 2 and not message.reply_to_message:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ πππ»πΊπ πππΎπ!"
)
if message.reply_to_message:
user = message.reply_to_message.from_user
else:
user = await client.get_users(message.command[1])
try:
await message.chat.unban_member(user.id)
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(message, f"**π€ π΄ππ»πΊπππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**", 30)
await hellbot.check_and_log(
"unban",
f"**Unbanned User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
["kick", "dkick"],
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def kick(client: Client, message: Message):
if message.reply_to_message:
user = message.reply_to_message.from_user
if len(message.command) < 2:
reason = None
else:
reason = await hellbot.input(message)
if message.command[0][0].lower() == "d":
await message.reply_to_message.delete()
elif len(message.command) == 2:
user = await client.get_users(message.command[1])
reason = None
elif len(message.command) > 2:
user = await client.get_users(message.command[1])
reason = (await hellbot.input(message)).split(" ", 1)[1].strip()
else:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ πππΌπ πππΎπ!"
)
try:
await message.chat.ban_member(user.id)
except Exception as e:
return await hellbot.error(message, e)
reason = reason if reason else "Not Specified"
await hellbot.delete(
message,
f"**π πͺππΌππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**\n**π±πΎπΊπππ:** `{reason}`",
30,
)
await hellbot.check_and_log(
"kick",
f"**Kicked User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Reason:** `{reason}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
await asyncio.sleep(5)
await message.chat.unban_member(user.id)
@on_message(
"mute",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def mute(client: Client, message: Message):
if message.reply_to_message:
user = message.reply_to_message.from_user
if len(message.command) < 2:
reason = None
else:
reason = await hellbot.input(message)
elif len(message.command) == 2:
user = await client.get_users(message.command[1])
reason = None
elif len(message.command) > 2:
user = await client.get_users(message.command[1])
reason = (await hellbot.input(message)).split(" ", 1)[1].strip()
else:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ ππππΎ πππΎπ!"
)
try:
permissions = ChatPermissions(
can_send_messages=False,
)
await message.chat.restrict_member(user.id, permissions)
except Exception as e:
return await hellbot.error(message, e)
reason = reason if reason else "Not Specified"
await hellbot.delete(
message,
f"**π€ π¬πππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**\n**π±πΎπΊπππ:** `{reason}`",
30,
)
await hellbot.check_and_log(
"mute",
f"**Muted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Reason:** `{reason}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"unmute",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def unmute(client: Client, message: Message):
if len(message.command) < 2 and not message.reply_to_message:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ ππππππΎ πππΎπ!"
)
if message.reply_to_message:
user = message.reply_to_message.from_user
else:
user = await client.get_users(message.command[1])
try:
permissions = ChatPermissions(
can_send_messages=True,
)
await message.chat.restrict_member(user.id, permissions)
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(message, f"**π π΄πππππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**", 30)
await hellbot.check_and_log(
"unmute",
f"**Unmuted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message("dmute", allow_stan=True)
async def dmute(client: Client, message: Message):
if message.reply_to_message:
user = message.reply_to_message.from_user
if len(message.command) < 2:
reason = None
else:
reason = await hellbot.input(message)
elif len(message.command) == 2:
user = await client.get_users(message.command[1])
reason = None
elif len(message.command) > 2:
user = await client.get_users(message.command[1])
reason = (await hellbot.input(message)).split(" ", 1)[1].strip()
else:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ ππππΎ πππΎπ!"
)
if await db.is_muted(client.me.id, user.id, message.chat.id):
return await hellbot.delete(message, "This user is already dmuted.")
reason = reason if reason else "Not Specified"
await db.add_mute(client.me.id, user.id, message.chat.id, reason)
await hellbot.delete(
message,
f"**π€ π¬πππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**\n**π±πΎπΊπππ:** `{reason}`",
30,
)
await hellbot.check_and_log(
"dmute",
f"**D-Muted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Reason:** `{reason}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title or message.chat.first_name}`\n**Group ID:** `{message.chat.id}`",
)
@on_message("undmute", allow_stan=True)
async def undmute(client: Client, message: Message):
if len(message.command) < 2 and not message.reply_to_message:
return await hellbot.delete(
message, "ππΎπΎπ½ πΊ πππΎπππΊππΎ/ππ½ ππ ππΎππ
π ππ πΊ πππΎπ ππ ππππππΎ πππΎπ!"
)
if message.reply_to_message:
user = message.reply_to_message.from_user
else:
user = await client.get_users(message.command[1])
if not await db.is_muted(client.me.id, user.id, message.chat.id):
return await hellbot.delete(message, "π³ππΎ πππΎπ ππ πππ ππππΎπ½!")
reason = await db.rm_mute(client.me.id, user.id, message.chat.id)
await hellbot.delete(
message,
f"**π π΄πππππΎπ½ {user.mention} π²ππΌπΌπΎπππΏππ
π
π!**\n\n**Mute reason was:** `{reason}`",
30,
)
await hellbot.check_and_log(
"unmute",
f"**D-Unmuted User**\n\n**User:** {user.mention}\n**User ID:** `{user.id}`\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"pin",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def pin(_, message: Message):
if not message.reply_to_message:
return await hellbot.delete(message, "ππΎπΎπ½ πΊ ππΎππ
π ππ πππ πΊ ππΎπππΊππΎ!")
try:
await message.reply_to_message.pin()
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(
message,
f"**π π―ππππΎπ½ [π¬πΎπππΊππΎ]({message.reply_to_message.link}) ππ {message.chat.title}!**",
30,
)
await hellbot.check_and_log(
"pin",
f"**Pinned Message**\n\n**Message:** [Click Here]({message.reply_to_message.link})\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"unpin",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def unpin(_, message: Message):
if not message.reply_to_message:
return await hellbot.delete(message, "ππΎπΎπ½ πΊ ππΎππ
π ππ πππππ πΊ ππΎπππΊππΎ!")
try:
await message.reply_to_message.unpin()
except Exception as e:
return await hellbot.error(message, e)
await hellbot.delete(
message,
f"**π π΄ππππππΎπ½ [π¬πΎπππΊππΎ]({message.reply_to_message.link}) ππ {message.chat.title}!**",
30,
)
await hellbot.check_and_log(
"unpin",
f"**Unpinned Message**\n\n**Message:** [Click Here]({message.reply_to_message.link})\n**Admin:** `{message.from_user.mention}`\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`",
)
@on_message(
"zombies",
chat_type=group_only,
admin_only=True,
allow_stan=True,
)
async def zombies(_, message: Message):
hell = await hellbot.edit(message, "β οΈ π£πΎππΎπΌππππ ππππ»ππΎπ...")
ded_users = []
async for members in message.chat.get_members():
if members.user.is_deleted:
ded_users.append(members.user.id)
if not ded_users:
return await hell.edit(
"π«‘ π£ππ'π ππΊππΎ πΊππ ππππ»ππΎπ ππ ππππ πππππ. **π¦πππππ' πΌπ
πΎπΊπ π π₯!**"
)
if len(message.command) > 1 and message.command[1].lower() == "clean":
await hell.edit(
f"β οΈ π₯ππππ½ {len(ded_users)} ππππ»ππΎπ... **π« π³πππΎ ππ πππππΎ πππΎπ!**"
)
failed = 0
success = 0
for user in ded_users:
try:
await message.chat.ban_member(user)
success += 1
except Exception as e:
LOGS.error(e)
failed += 1
await hell.edit(f"**π―ππππΎπ½ {success} ππππ»ππΎπ!**\n`{failed}` holds immunity!")
else:
await hell.edit(
f"**β οΈ π₯ππππ½ {len(ded_users)} ππππ»ππΎπ!**\n\n__Use__ `{handler}zombies clean` __to kill them!__"
)
@custom_handler(filters.incoming)
async def multiple_handler(client: Client, message: Message):
if not message.from_user:
return
if await db.is_muted(client.me.id, message.from_user.id, message.chat.id):
try:
await message.delete()
except:
pass
elif await db.is_gmuted(message.from_user.id):
try:
await message.delete()
except:
pass
elif await db.is_echo(client.me.id, message.chat.id, message.from_user.id):
await message.copy(message.chat.id, reply_to_message_id=message.id)
HelpMenu("admin").add(
"promote",
"<πππΎπππΊππΎ/ππ½/reply> <ππππ
πΎ>",
"Promote a user to admin.",
"promote @ForGo10God hellboy",
).add(
"demote", "<username/id/reply>", "Demote a user from admin.", "demote @ForGo10God"
).add(
"ban",
"<username/id/reply> <reason>",
"Ban a user from the group.",
"ban @ForGo10God",
"You can also use dban to delete the message of the user.",
).add(
"unban", "<username/id/reply>", "Unban a user from the group.", "unban @ForGo10God"
).add(
"kick",
"<username/id/reply> <reason>",
"Kick a user from the group.",
"kick @ForGo10God",
"You can also use dkick to delete the message of the user.",
).add(
"mute",
"<username/id/reply> <reason>",
"Mute a user in the group",
"mute @ForGo10God",
"You can also use dmute to delete the message of the user.",
).add(
"unmute", "<username/id/reply>", "Unmute a user in the group.", "unmute @ForGo10God"
).add(
"dmute",
"<username/id/reply>",
"Mute a user by deleting their new messages in the group.",
"dmute @ForGo10God",
"Need delete message permission for proper functioning.",
).add(
"undmute",
"<username/id/reply>",
"Unmute a user who's muted using 'dmute' command in the group.",
"undmute @ForGo10God",
).add(
"pin", "<reply>", "Pin the replied message in the group."
).add(
"unpin", "<reply>", "Unpin the replied pinned message in the group."
).add(
"zombies",
"clean",
"Finds the total number of deleted users present in that group and ban them.",
).info(
"Admin Menu"
).done()
|