Best Python code snippet using tempest_python
grouputils.py
Source:grouputils.py
...35)36async def spin(client, message):37 engine = message.Engine38 if not message.reply_to_message:39 await edit_or_reply(message, engine.get_string("REPLY_TO_PIN"))40 try:41 await client.pin_chat_message(42 message.chat.id,43 message.reply_to_message.message_id,44 disable_notification=True,45 )46 except BaseException as e:47 await edit_or_reply(48 message, engine.get_string("UNABLE_TO_PIN").format(e)49 )50 return51 await edit_or_reply(message, engine.get_string("PINNED"))52@friday_on_cmd(53 ["pinloud", "pin"],54 only_if_admin=True,55 cmd_help={56 "help": "Pin Message With Sending Notification To Members!",57 "example": "{ch}pin (reply to messages)",58 },59)60async def lpin(client, message):61 engine = message.Engine62 if not message.reply_to_message:63 await edit_or_reply(message, engine.get_string("REPLY_TO_PIN"))64 try:65 await client.pin_chat_message(66 message.chat.id, message.reply_to_message.message_id67 )68 except BaseException as e:69 await edit_or_reply(70 message, engine.get_string("UNABLE_TO_PIN").format(e)71 )72 return73 await edit_or_reply(message, engine.get_string("PINNED"))74@friday_on_cmd(75 ["unpin", "rmpins"],76 only_if_admin=True,77 cmd_help={"help": "Unpin All Pinned Messages!", "example": "{ch}rmpins"},78)79async def dpins(client, message):80 engine = message.Engine81 await client.unpin_all_chat_messages(message.chat.id)82 await edit_or_reply(message, engine.get_string("UNPINNED"))83@friday_on_cmd(84 ["adminlist", "admins"],85 cmd_help={"help": "Get Adminlist Of Chat!", "example": "{ch}adminlist"},86)87async def midhunadmin(client, message):88 engine = message.Engine89 mentions = ""90 starky = get_text(message) or message.chat.id91 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))92 try:93 X = await client.get_chat_members(starky, filter="administrators")94 ujwal = await client.get_chat(starky)95 except BaseException as e:96 await pablo.edit(engine.get_string("CANT_FETCH_ADMIN").format("Admins", e))97 return98 for midhun in X:99 if not midhun.user.is_deleted:100 link = f'Ⱡ<a href="tg://user?id={midhun.user.id}">{midhun.user.first_name}</a>'101 userid = f"<code>{midhun.user.id}</code>"102 mentions += f"\n{link} {userid}"103 holy = ujwal.username or ujwal.id104 messag = f"""105<b>Admins in {ujwal.title} | {holy}</b>106{mentions}107"""108 await edit_or_send_as_file(109 messag,110 pablo,111 client,112 f"`AdminList Of {holy}!`",113 "admin-lookup-result",114 "html",115 )116@friday_on_cmd(117 ["botlist", "bot"],118 group_only=True,119 cmd_help={"help": "Get List Of Bots In Chat!", "example": "{ch}botlist"},120)121async def bothub(client, message):122 engine = message.Engine123 buts = "**Bot List** \n\n"124 starky = get_text(message) or message.chat.id125 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))126 try:127 bots = await client.get_chat_members(starky, filter="bots")128 except BaseException as e:129 await pablo.edit(engine.get_string("CANT_FETCH_ADMIN").format("Bots", e))130 return131 for nos, ujwal in enumerate(bots, start=1):132 buts += f"{nos}⪠[{ujwal.user.first_name}](tg://user?id={ujwal.user.id}) \n"133 await pablo.edit(buts)134@friday_on_cmd(135 ["zombies", "delusers"],136 cmd_help={137 "help": "Remove Deleted Accounts In The Group/Channel!",138 "example": "{ch}zombies",139 },140)141async def ujwalzombie(client, message):142 engine = message.Engine143 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))144 if len(message.text.split()) == 1:145 dm = 0146 da = 0147 dc = 0148 async for member in client.iter_chat_members(message.chat.id):149 if member.user.is_deleted:150 await sleep(1)151 if member.status == "member":152 dm += 1153 elif member.status == "administrator":154 da += 1155 elif member.status == "creator":156 dc += 1157 text = "**Zombies Report!** \n\n"158 if dm > 0:159 text += engine.get_string("TOTAL_ZOMBIES_USERS").format(dm)160 if da > 0:161 text += engine.get_string("TOTAL_ZOMBIES_ADMINS").format(da)162 if dc > 0:163 text += engine.get_string("GRP_OWNER_IS_ZOMBIE")164 d = dm + da + dc165 if d > 0:166 text += (engine.get_string("WIPE_THEM"))167 await pablo.edit(text)168 else:169 await pablo.edit(engine.get_string("NO_ZOMBIES"))170 return171 sgname = message.text.split(None, 1)[1]172 if sgname.lower().strip() == "clean":173 me = client.me174 lol = await is_admin_or_owner(message, me.id)175 if not lol:176 await pablo.edit(engine.get_string("NOT_ADMIN"))177 return178 s = 0179 f = 0180 async for member in client.iter_chat_members(message.chat.id):181 if member.user.is_deleted:182 try:183 await client.kick_chat_member(message.chat.id, member.user.id)184 s += 1185 except:186 f += 1187 text = ""188 if s > 0:189 text += engine.get_string("REMOVED_ZOMBIES").format(s)190 if f > 0:191 text += (engine.get_string("FAILED_ZOMBIES").format(f))192 await pablo.edit(text)193@friday_on_cmd(194 ["ban", "bun"],195 only_if_admin=True,196 group_only=True,197 cmd_help={198 "help": "Ban Replied User or provide his ID!",199 "example": "{ch}ban (reply to user message OR provide his ID)",200 },201)202async def ban_world(client, message):203 engine = message.Engine204 bun = await edit_or_reply(message, engine.get_string("PROCESSING"))205 me_m = client.me206 me_ = await message.chat.get_member(int(me_m.id))207 if not me_.can_restrict_members:208 await bun.edit(engine.get_string("NOT_ADMIN"))209 return210 text_ = get_text(message)211 userk, reason = get_user(message, text_)212 if not userk:213 await bun.edit(engine.get_string("TO_DO").format("Ban"))214 return215 try:216 user_ = await client.get_users(userk)217 except BaseException as e:218 await bun.edit(engine.get_string("USER_MISSING").format(e))219 return220 userz = user_.id221 if not reason:222 reason = "Not Specified!"223 if userz == me_m.id:224 await bun.edit(engine.get_string("TF_DO_IT").format("Ban"))225 return226 try:227 user_ = await client.get_users(userz)228 except BaseException as e:229 await bun.edit(engine.get_string("USER_MISSING").format(e))230 return231 try:232 await client.kick_chat_member(message.chat.id, int(user_.id))233 except BaseException as e:234 await bun.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Ban", e))235 return236 b = f"**#Banned** \n**User :** [{user_.first_name}](tg://user?id={user_.id}) \n**Chat :** `{message.chat.title}` \n**Reason :** `{reason}`"237 await bun.edit(b)238 log = LogIt(message)239 await log.log_msg(client, b)240@friday_on_cmd(241 ["unban", "unbun"],242 only_if_admin=True,243 group_only=True,244 cmd_help={245 "help": "UnBan Replied User or provide his ID!",246 "example": "{ch}unban (reply to user message OR Provide his id)",247 },248)249async def unban_world(client, message):250 engine = message.Engine251 unbun = await edit_or_reply(message, engine.get_string("PROCESSING"))252 me_m = client.me253 me_ = await message.chat.get_member(int(me_m.id))254 if not me_.can_restrict_members:255 await unbun.edit(engine.get_string("NOT_ADMIN"))256 return257 text_ = get_text(message)258 userm, reason = get_user(message, text_)259 if not userm:260 await unbun.edit(261 engine.get_string("TO_DO").format("Un-Ban")262 )263 return264 try:265 user_ = await client.get_users(userm)266 except BaseException as e:267 await unbun.edit(engine.get_string("USER_MISSING").format(e))268 return269 userz = user_.id270 if not reason:271 reason = "Not Specified!"272 if userz == me_m.id:273 await unbun.edit(engine.get_string("TF_DO_IT").format("Un-Ban"))274 return275 try:276 await client.unban_chat_member(message.chat.id, int(user_.id))277 except BaseException as e:278 await unbun.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Un-Ban", e))279 ub = f"**#UnBanned** \n**User :** [{user_.first_name}](tg://user?id={user_.id}) \n**Chat :** `{message.chat.title}` \n**Reason :** `{reason}`"280 await unbun.edit(ub)281 log = LogIt(message)282 await log.log_msg(client, ub)283@friday_on_cmd(284 ["promote", "prumote"],285 only_if_admin=True,286 group_only=True,287 cmd_help={288 "help": "Promote Replied user or provide his ID!",289 "example": "{ch}promote (reply to user message OR provide his ID)",290 },291)292async def ujwal_mote(client, message):293 engine = message.Engine294 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))295 me_m = client.me296 me_ = await message.chat.get_member(int(me_m.id))297 if not me_.can_promote_members:298 await pablo.edit(engine.get_string("NOT_ADMIN"))299 return300 asplit = get_text(message)301 userl, Res = get_user(message, asplit)302 if not userl:303 await pablo.edit(304 engine.get_string("TO_DO").format("Promote")305 )306 return307 try:308 user = await client.get_users(userl)309 except BaseException as e:310 await pablo.edit(engine.get_string("USER_MISSING").format(e))311 return312 userz = user.id313 if not Res:314 Res = "Admeme"315 if userz == me_m.id:316 await pablo.edit(engine.get_string("TF_DO_IT").format("Promote"))317 return318 try:319 await client.promote_chat_member(320 message.chat.id,321 user.id,322 can_change_info=me_.can_change_info,323 can_delete_messages=me_.can_delete_messages,324 can_restrict_members=me_.can_restrict_members,325 can_invite_users=me_.can_invite_users,326 can_pin_messages=me_.can_pin_messages,327 can_promote_members=me_.can_promote_members,328 )329 except BaseException as e:330 await pablo.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Promote", e))331 return332 p = f"**#Promote** \n**User :** [{user.first_name}](tg://user?id={user.id}) \n**Chat :** `{message.chat.title}` \n**Title :** `{Res}`"333 await pablo.edit(p)334 log = LogIt(message)335 await log.log_msg(client, p)336 try:337 if Res:338 await client.set_administrator_title(message.chat.id, user.id, Res)339 except:340 pass341@friday_on_cmd(342 ["demote", "demute"],343 only_if_admin=True,344 group_only=True,345 cmd_help={346 "help": "Demote Replied user or provide his ID!",347 "example": "{ch}demote (reply to user message OR provide his ID)",348 },349)350async def ujwal_demote(client, message):351 engine = message.Engine352 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))353 me_m = client.me354 await message.chat.get_member(int(me_m.id))355 asplit = get_text(message)356 usero = get_user(message, asplit)[0]357 if not usero:358 await pablo.edit(359 engine.get_string("TO_DO").format("Demote")360 )361 return362 try:363 user = await client.get_users(usero)364 except BaseException as e:365 await pablo.edit(engine.get_string("USER_MISSING").format(e))366 return367 userz = user.id368 if userz == me_m.id:369 await pablo.edit(engine.get_string("TF_DO_IT").format("Demote"))370 return371 try:372 await client.promote_chat_member(373 message.chat.id,374 user.id,375 is_anonymous=False,376 can_change_info=False,377 can_post_messages=False,378 can_edit_messages=False,379 can_delete_messages=False,380 can_restrict_members=False,381 can_invite_users=False,382 can_pin_messages=False,383 can_promote_members=False,384 )385 except BaseException as e:386 await pablo.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Demote", e))387 return388 d = f"**#Demote** \n**User :** [{user.first_name}](tg://user?id={user.id}) \n**Chat :** `{message.chat.title}`"389 await pablo.edit(d)390 log = LogIt(message)391 await log.log_msg(client, d)392@friday_on_cmd(393 ["mute"],394 only_if_admin=True,395 group_only=True,396 cmd_help={397 "help": "Mute Replied user or provide his ID!",398 "example": "{ch}mute (reply to user message OR provide his ID)",399 },400)401async def ujwal_mute(client, message):402 engine = message.Engine403 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))404 me_m = client.me405 me_ = await message.chat.get_member(int(me_m.id))406 if not me_.can_restrict_members:407 await pablo.edit(engine.get_string("NOT_ADMIN"))408 return409 asplit = get_text(message)410 userf = get_user(message, asplit)[0]411 if not userf:412 await pablo.edit(413 engine.get_string("TO_DO").format("Mute")414 )415 return416 try:417 user = await client.get_users(userf)418 except BaseException as e:419 await pablo.edit(engine.get_string("USER_MISSING").format(e))420 return421 userz = user.id422 if userz == me_m.id:423 await pablo.edit(engine.get_string("TF_DO_IT").format("Mute"))424 return425 try:426 await client.restrict_chat_member(427 message.chat.id, user.id, ChatPermissions(can_send_messages=False)428 )429 except BaseException as e:430 await pablo.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Mute", e))431 return432 m = f"**#Muted** \n**User :** [{user.first_name}](tg://user?id={user.id}) \n**Chat :** `{message.chat.title}`"433 await pablo.edit(m)434 log = LogIt(message)435 await log.log_msg(client, m)436@friday_on_cmd(437 ["unmute"],438 only_if_admin=True,439 group_only=True,440 cmd_help={441 "help": "Unmute Replied user or provide his ID!",442 "example": "{ch}Unmute (reply to user message OR provide his ID)",443 },444)445async def ujwal_unmute(client, message):446 engine = message.Engine447 pablo = await edit_or_reply(message, engine.get_string("PROCESSING"))448 me_m = client.me449 me_ = await message.chat.get_member(int(me_m.id))450 if not me_.can_restrict_members:451 await pablo.edit(engine.get_string("NOT_ADMIN"))452 return453 asplit = get_text(message)454 userf = get_user(message, asplit)[0]455 if not userf:456 await pablo.edit(457 engine.get_string("TO_DO").format("Un-Mute")458 )459 return460 try:461 user = await client.get_users(userf)462 except BaseException as e:463 await pablo.edit(engine.get_string("USER_MISSING").format(e))464 return465 userz = user.id466 if userz == me_m.id:467 await pablo.edit(engine.get_string("TF_DO_IT").format("un-mute"))468 return469 try:470 await client.restrict_chat_member(471 message.chat.id, user.id, ChatPermissions(can_send_messages=True)472 )473 except BaseException as e:474 await pablo.edit(engine.get_string("FAILED_ADMIN_ACTION").format("Un-mute", e))475 return476 um = f"**#Un_Muted** \n**User :** [{user.first_name}](tg://user?id={user.id}) \n**Chat :** `{message.chat.title}`"477 await pablo.edit(um)478 log = LogIt(message)479 await log.log_msg(client, um)480@friday_on_cmd(481 ["chatinfo", "grpinfo"],482 group_only=True,483 cmd_help={"help": "Get Info Of The Chat!", "example": "{ch}chatinfo"},484)485async def owo_chat_info(client, message):486 engine = message.Engine487 s = await edit_or_reply(message, engine.get_string("PROCESSING"))488 ujwal = await client.get_chat(message.chat.id)489 peer = await client.resolve_peer(message.chat.id)490 online_ = await client.send(pyrogram.raw.functions.messages.GetOnlines(peer=peer))491 msg = "**Chat Info** \n\n"492 msg += f"**Chat-ID :** __{ujwal.id}__ \n"493 msg += f"**Verified :** __{ujwal.is_verified}__ \n"494 msg += f"**Is Scam :** __{ujwal.is_scam}__ \n"495 msg += f"**Chat Title :** __{ujwal.title}__ \n"496 msg += f"**Users Online :** __{online_.onlines}__ \n"497 if ujwal.photo:498 msg += f"**Chat DC :** __{ujwal.dc_id}__ \n"499 if ujwal.username:500 msg += f"**Chat Username :** __{ujwal.username}__ \n"501 if ujwal.description:502 msg += f"**Chat Description :** __{ujwal.description}__ \n"503 msg += f"**Chat Members Count :** __{ujwal.members_count}__ \n"504 if ujwal.photo:505 kek = await client.download_media(ujwal.photo.big_file_id)506 await client.send_photo(message.chat.id, photo=kek, caption=msg)507 await s.delete()508 else:509 await s.edit(msg)510@friday_on_cmd(511 ["purge"],512 only_if_admin=True,513 cmd_help={514 "help": "Purge All Messages Till Replied Message!",515 "example": "{ch}purge (reply to message)",516 },517)518async def purge(client, message):519 engine = message.Engine520 start_time = time.time()521 message_ids = []522 purge_len = 0523 event = await edit_or_reply(message, engine.get_string("PROCESSING"))524 me_m = client.me525 if message.chat.type in ["supergroup", "channel"]:526 me_ = await message.chat.get_member(int(me_m.id))527 if not me_.can_delete_messages:528 await event.edit(engine.get_string("NOT_ADMIN"))529 return530 if not message.reply_to_message:531 await event.edit(engine.get_string("NEEDS_REPLY").format("Message To Purge."))532 return533 async for msg in client.iter_history(534 chat_id=message.chat.id,535 offset_id=message.reply_to_message.message_id,536 reverse=True,537 ):538 if msg.message_id != message.message_id:539 purge_len += 1540 message_ids.append(msg.message_id)541 if len(message_ids) >= 100:542 await client.delete_messages(543 chat_id=message.chat.id, message_ids=message_ids, revoke=True544 )545 message_ids.clear()546 if message_ids:547 await client.delete_messages(548 chat_id=message.chat.id, message_ids=message_ids, revoke=True549 )550 end_time = time.time()551 u_time = round(end_time - start_time)552 await event.edit(553 engine.get_string("PURGE_").format(purge_len, u_time)554 )555 await asyncio.sleep(3)556 await event.delete()557@friday_on_cmd(558 ["del"],559 cmd_help={560 "help": "Delete Replied Message!",561 "example": "{ch}del (reply to message)",562 },563)564async def delmsgs(client, message):565 engine = message.Engine566 if not message.reply_to_message:567 await message.delete()568 return569 await client.delete_messages(570 chat_id=message.chat.id,571 message_ids=[message.reply_to_message.message_id],572 revoke=True,573 )574 await message.delete()575@friday_on_cmd(576 ["setgrppic", "gpic"],577 cmd_help={578 "help": "Set Custom Group Pic, For Lazy Peoples!",579 "example": "{ch}setgrppic (reply to image)",580 },581)582async def magic_grps(client, message):583 engine = message.Engine584 msg_ = await edit_or_reply(message, engine.get_string("PROCESSING"))585 if not message.reply_to_message:586 await msg_.edit(engine.get_string("NEEDS_REPLY").format("image"))587 return588 me_ = await message.chat.get_member(int(client.me.id))589 if not me_.can_change_info:590 await msg_.edit(engine.get_string("NOT_ADMIN"))591 return592 cool = await convert_to_image(message, client)593 if not cool:594 await msg_.edit(engine.get_string("NEEDS_REPLY").format("a valid media"))595 return596 if not os.path.exists(cool):597 await msg_.edit(engine.get_string("INVALID_MEDIA"))598 return599 try:600 await client.set_chat_photo(message.chat.id, photo=cool)601 except BaseException as e:602 await msg_.edit(f"`Unable To Set Group Photo! TraceBack : {e}")603 return...
admintools.py
Source:admintools.py
...55 ultroid_cmd,56)57@ultroid_cmd(pattern="promote ?(.*)", admins_only=True, type=["official", "manager"])58async def prmte(ult):59 xx = await eor(ult, get_string("com_1"))60 await ult.get_chat()61 user, rank = await get_uinfo(ult)62 rank = rank or "Admin"63 if not user:64 return await xx.edit(get_string("pro_1"))65 try:66 await ult.client.edit_admin(67 ult.chat_id,68 user.id,69 invite_users=True,70 ban_users=True,71 delete_messages=True,72 pin_messages=True,73 manage_call=True,74 title=rank,75 )76 await eod(77 xx, get_string("pro_2").format(inline_mention(user), ult.chat.title, rank)78 )79 except Exception as ex:80 return await xx.edit(f"`{ex}`")81@ultroid_cmd(82 pattern="demote ?(.*)",83 admins_only=True,84 type=["official", "manager"],85)86async def dmote(ult):87 xx = await eor(ult, get_string("com_1"))88 await ult.get_chat()89 user, rank = await get_uinfo(ult)90 if not rank:91 rank = "Not Admin"92 if not user:93 return await xx.edit(get_string("de_1"))94 try:95 await ult.client.edit_admin(96 ult.chat_id,97 user.id,98 invite_users=None,99 ban_users=None,100 delete_messages=None,101 pin_messages=None,102 manage_call=None,103 title=rank,104 )105 await eod(xx, get_string("de_2").format(inline_mention(user), ult.chat.title))106 except Exception as ex:107 return await xx.edit(f"`{ex}`")108@ultroid_cmd(109 pattern="ban ?(.*)",110 admins_only=True,111 type=["official", "manager"],112)113async def bban(ult):114 user, reason = await get_uinfo(ult)115 if not user:116 return await eod(ult, get_string("ban_1"))117 if user.id in DEVLIST:118 return await eod(ult, get_string("ban_2"))119 try:120 await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)121 except BadRequestError:122 return await eod(ult, get_string("ban_3"))123 except UserIdInvalidError:124 return await eod(ult, get_string("adm_1"))125 senderme = inline_mention(await ult.get_sender())126 userme = inline_mention(user)127 text = get_string("ban_4").format(userme, senderme, ult.chat.title)128 if reason:129 text += get_string("ban_5").format(reason)130 await eod(ult, text)131@ultroid_cmd(132 pattern="unban ?(.*)",133 admins_only=True,134 type=["official", "manager"],135)136async def uunban(ult):137 xx = await eor(ult, get_string("com_1"))138 if ult.text[1:].startswith("unbanall"):139 return140 user, reason = await get_uinfo(ult)141 if not user:142 return await xx.edit(get_string("unban_1"))143 try:144 await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=True)145 except BadRequestError:146 return await xx.edit(get_string("adm_2"))147 except UserIdInvalidError:148 await xx.edit(get_string("adm_1"))149 sender = inline_mention(await ult.get_sender())150 text = get_string("unban_3").format(user, sender, ult.chat.title)151 if reason:152 text += get_string("ban_5").format(reason)153 await xx.edit(text)154@ultroid_cmd(155 pattern="kick ?(.*)",156 admins_only=True,157 type=["official", "manager"],158)159async def kck(ult):160 if "kickme" in ult.text:161 return162 ml = ult.text.split(" ", maxsplit=1)[0]163 xx = await eor(ult, get_string("com_1"))164 user, reason = await get_uinfo(ult)165 if not user:166 return await xx.edit(get_string("adm_1"))167 if user.id in DEVLIST:168 return await xx.edit(get_string("kick_2"))169 if user.is_self:170 return await xx.edit(get_string("kick_3"))171 try:172 await ult.client.kick_participant(ult.chat_id, user.id)173 except BadRequestError as er:174 LOGS.info(er)175 return await xx.edit(get_string("kick_1"))176 except Exception as e:177 LOGS.exception(e)178 text = get_string("kick_4").format(179 inline_mention(user), inline_mention(await ult.get_sender()), ult.chat.title180 )181 if reason:182 text += get_string("ban_5").format(reason)183 await xx.edit(text)184@ultroid_cmd(pattern="tban ?(.*)", type=["official", "manager"])185async def tkicki(e):186 huh = e.text.split(" ")187 try:188 tme = huh[1]189 except IndexError:190 return await eor(e, get_string("adm_3"), time=15)191 try:192 inputt = huh[2]193 except IndexError:194 pass195 chat = await e.get_chat()196 if e.is_reply:197 replied = await e.get_reply_message()198 userid = replied.sender_id199 fn = (await e.get_sender()).first_name200 elif inputt:201 userid = await get_user_id(inputt)202 fn = (await e.client.get_entity(userid)).first_name203 else:204 return await eor(e, get_string("tban_1"), time=3)205 try:206 bun = await ban_time(e, tme)207 await e.client.edit_permissions(208 e.chat_id, userid, until_date=bun, view_messages=False209 )210 await eod(211 e,212 get_string("tban_2").format(fn, chat.title, tme),213 time=15,214 )215 except Exception as m:216 return await eor(e, str(m))217@ultroid_cmd(pattern="pin$", type=["official", "manager"])218async def pin(msg):219 if not msg.is_reply:220 return await eor(msg, get_string("pin_1"))221 me = await msg.get_reply_message()222 if me.is_private:223 text = "`Pinned.`"224 else:225 text = f"Pinned [This Message]({me.message_link}) !"226 try:227 await msg.client.pin_message(msg.chat_id, me.id, notify=False)228 except BadRequestError:229 return await eor(msg, get_string("adm_2"))230 except Exception as e:231 return await eor(msg, f"**ERROR:**`{e}`")232 await eor(msg, text)233@ultroid_cmd(234 pattern="unpin($| (.*))",235 type=["official", "manager"],236)237async def unp(ult):238 xx = await eor(ult, get_string("com_1"))239 ch = (ult.pattern_match.group(1)).strip()240 msg = None241 if ult.is_reply:242 msg = ult.reply_to_msg_id243 elif ch != "all":244 return await xx.edit(get_string("unpin_1").format(HNDLR))245 try:246 await ult.client.unpin_message(ult.chat_id, msg)247 except BadRequestError:248 return await xx.edit(get_string("adm_2"))249 except Exception as e:250 return await xx.edit(f"**ERROR:**`{e}`")251 await xx.edit("`Unpinned!`")252@ultroid_cmd(253 pattern="purge ?(.*)",254 type=["official", "manager"],255)256async def fastpurger(purg):257 match = purg.pattern_match.group(1)258 try:259 ABC = purg.text[6]260 except IndexError:261 ABC = None262 if ABC and purg.text[6] in ["m", "a"]:263 return264 if not purg._client._bot and ((match) or (purg.is_reply and purg.is_private)):265 p = 0266 async for msg in purg.client.iter_messages(267 purg.chat_id,268 limit=int(match) if match else None,269 min_id=purg.reply_to_msg_id if purg.is_reply else None,270 ):271 await msg.delete()272 p += 0273 return await eor(purg, f"Purged {p} Messages! ", time=5)274 if not purg.reply_to_msg_id:275 return await eor(purg, get_string("purge_1"), time=10)276 try:277 await purg.client.delete_messages(278 purg.chat_id, [a for a in range(purg.reply_to_msg_id, purg.id + 1)]279 )280 except Exception as er:281 LOGS.info(er)282 await purg.respond(283 "__Fast purge complete!__",284 )285@ultroid_cmd(286 pattern="purgeme ?(.*)",287)288async def fastpurgerme(purg):289 num = purg.pattern_match.group(1)290 if num and not purg.is_reply:291 try:292 nnt = int(num)293 except BaseException:294 await eor(purg, get_string("com_3"), time=5)295 return296 mp = 0297 async for mm in purg.client.iter_messages(298 purg.chat_id, limit=nnt, from_user="me"299 ):300 await mm.delete()301 mp += 1302 await eor(purg, f"Purged {mp} Messages!", time=5)303 return304 chat = await purg.get_input_chat()305 msgs = []306 count = 0307 if not (purg.reply_to_msg_id or num):308 return await eod(309 purg,310 "`Reply to a message to purge from or use it like ``purgeme <num>`",311 time=10,312 )313 async for msg in purg.client.iter_messages(314 chat,315 from_user="me",316 min_id=purg.reply_to_msg_id,317 ):318 msgs.append(msg)319 count += 1320 msgs.append(purg.reply_to_msg_id)321 if len(msgs) == 100:322 await ultroid_bot.delete_messages(chat, msgs)323 msgs = []324 if msgs:325 await purg.client.delete_messages(chat, msgs)326 await eod(327 purg,328 "__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",329 )330@ultroid_cmd(331 pattern="purgeall$",332)333async def _(e):334 if not e.is_reply:335 return await eod(336 e,337 get_string("purgeall_1"),338 )339 name = (await e.get_reply_message()).sender340 try:341 await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))342 await eor(e, get_string("purgeall_2").format(name.first_name), time=5)343 except Exception as er:344 return await eor(e, str(er), time=5)345@ultroid_cmd(pattern="pinned", type=["official", "manager"], groups_only=True)346async def djshsh(event):347 chat = await event.get_chat()348 if isinstance(chat, types.Chat):349 FChat = await event.client(GetFullChatRequest(chat.id))350 elif isinstance(chat, types.Channel):351 FChat = await event.client(GetFullChannelRequest(chat.id))352 else:353 return354 msg_id = FChat.full_chat.pinned_msg_id355 if not msg_id:356 return await eor(event, get_string("pinned_1"))357 msg = await event.client.get_messages(chat.id, ids=msg_id)358 if msg:359 await eor(360 event, f"Pinned Message in Current chat is [here]({msg.message_link})."361 )362@ultroid_cmd(363 pattern="listpinned$",364)365async def get_all_pinned(event):366 x = await eor(event, get_string("com_1"))367 chat_id = (str(event.chat_id)).replace("-100", "")368 chat_name = (await event.get_chat()).title369 a = ""370 c = 1371 async for i in event.client.iter_messages(372 event.chat_id, filter=InputMessagesFilterPinned373 ):374 if i.message:375 t = " ".join(i.message.split()[0:4])376 txt = "{}....".format(t)377 else:378 txt = "Go to message."379 a += f"{c}. <a href=https://t.me/c/{chat_id}/{i.id}>{txt}</a>\n"380 c += 1381 if c == 1:382 m = f"<b>The pinned message in {chat_name}:</b>\n\n"383 else:384 m = f"<b>List of pinned message(s) in {chat_name}:</b>\n\n"385 if a == "":386 return await eor(x, get_string("listpin_1"), time=5)387 await x.edit(m + a, parse_mode="html")388@ultroid_cmd(389 pattern="autodelete ?(.*)",390 admins_only=True,391)392async def autodelte(ult):393 match = ult.pattern_match.group(1)394 if not match or match not in ["24h", "7d", "1m", "off"]:395 return await eor(ult, "`Please Use in Proper Format..`", time=5)396 if match == "24h":397 tt = 3600 * 24398 elif match == "7d":399 tt = 3600 * 24 * 7400 elif match == "1m":...
tg_helpers.py
Source:tg_helpers.py
...20 },21)22async def bleck_name(client, message):23 engine = message.Engine24 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))25 new_firstname = get_text(message)26 if not new_firstname:27 await owo.edit(engine.get_string("INPUT_REQ").format("Firstname"))28 return29 if len(new_firstname) > 64:30 await owo.edit(engine.get_string("NEEDS_C_INPUT"))31 return32 try:33 await client.update_profile(first_name=new_firstname)34 except BaseException as e:35 await owo.edit(36 engine.get_string("FIRST_NAME_CHANGE_FAILED").format("FirstName", e)37 )38 return39 await owo.edit(engine.get_string("FIRST_NAME_CHANGED").format("FirstName", new_firstname))40@friday_on_cmd(41 ["updatebio", "bio"],42 cmd_help={"help": "Change Your Account Bio!", "example": "{ch}bio (new bio)"},43)44async def bleck_bio(client, message):45 engine = message.Engine46 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))47 new_bio = get_text(message)48 if not new_bio:49 await owo.edit(engine.get_string("INPUT_REQ").format("Bio"))50 return51 if len(new_bio) > 70:52 await owo.edit(engine.get_string("NEEDS_C_INPUT"))53 return54 try:55 await client.update_profile(bio=new_bio)56 except BaseException as e:57 await owo.edit(engine.get_string("FIRST_NAME_CHANGE_FAILED").format("Bio", e))58 return59 await owo.edit(engine.get_string("FIRST_NAME_CHANGED").format("Bio", new_bio))60@friday_on_cmd(61 ["updateusername", "username"],62 cmd_help={63 "help": "Change Your Account UserName!",64 "example": "{ch}username (new username)",65 },66)67async def bleck_username(client, message):68 engine = message.Engine69 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))70 new_username = get_text(message)71 if not new_username:72 await owo.edit(engine.get_string("INPUT_REQ").format("Username"))73 return74 try:75 await client.update_username(new_username)76 except BaseException as e:77 await owo.edit(78 engine.get_string("FIRST_NAME_CHANGE_FAILED").format("Username", e)79 )80 return81 await owo.edit(engine.get_string("FIRST_NAME_CHANGED").format("Username", new_username))82@friday_on_cmd(83 ["updatelastname", "lastname"],84 cmd_help={85 "help": "Change Your Account Last Name!",86 "example": "{ch}lastname (new lastname)",87 },88)89async def bleck_name(client, message):90 engine = message.Engine91 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))92 new_lastname = get_text(message)93 if not new_lastname:94 await owo.edit(engine.get_string("INPUT_REQ").format("Last Name"))95 return96 if len(new_lastname) > 64:97 await owo.edit(engine.get_string("NEEDS_C_INPUT"))98 return99 try:100 await client.update_profile(last_name=new_lastname)101 except BaseException as e:102 await owo.edit(103 engine.get_string("FIRST_NAME_CHANGE_FAILED").format("LastName", e)104 )105 return106 await owo.edit(engine.get_string("FIRST_NAME_CHANGED").format("LastName", new_lastname))107 108 109@friday_on_cmd(110 ["join"],111 cmd_help={112 "help": "Join A Chat Easily.",113 "example": "{ch}join (chat link or username)",114 },115)116async def join_(client, message):117 engine = message.Engine118 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))119 input_ = get_text(message)120 if not input_:121 await owo.edit(engine.get_string("INPUT_REQ").format("Chat ID"))122 return123 try:124 await client.join_chat(input_)125 except BaseException as e:126 await owo.edit(127 engine.get_string("FAILED_TO_JOIN").format(e)128 )129 return130 await owo.edit(engine.get_string("JOINED"))131@friday_on_cmd(132 ["leave"],133 group_only=True,134 cmd_help={135 "help": "Leave Chat Easily.",136 "example": "{ch}leave",137 },138)139async def leave_(client, message):140 engine = message.Engine141 await edit_or_reply(message, "`GOODBYECRUELGROUP - *leaves*`")142 await client.leave_chat(message.chat.id)143@friday_on_cmd(144 ["updateppic", "ppic"],145 cmd_help={146 "help": "Change Your Profile Picture!",147 "example": "{ch}ppic (Reply To New Profile Picture)",148 },149)150async def bleck_pic(client, message):151 engine = message.Engine152 owo = await edit_or_reply(message, engine.get_string("PROCESSING"))153 if not message.reply_to_message:154 await owo.edit(engine.get_string("NEEDS_REPLY").format("Video / Pic"))155 return156 if not (157 message.reply_to_message.video158 or message.reply_to_message.animation159 or message.reply_to_message.photo160 ):161 await owo.edit(engine.get_string("NEEDS_REPLY").format("Video / Pic"))162 return163 is_video = False164 if message.reply_to_message.video or message.reply_to_message.animation:165 is_video = True166 ppics = await message.reply_to_message.download()167 try:168 if is_video:169 await client.set_profile_photo(video=ppics)170 else:171 await client.set_profile_photo(photo=ppics)172 except BaseException as e:173 await owo.edit(engine.get_string("UPDATE_PIC").format(e))174 return175 await owo.edit(engine.get_string("PIC_DONE"))176@friday_on_cmd(177 ["poll"],178 group_only=True,179 cmd_help={180 "help": "Create A Poll!",181 "example": "{ch}poll Your Message | option 1, option 2, option 3",182 },183)184async def create_poll(client, message):185 engine = message.Engine186 msg = await edit_or_reply(message, engine.get_string("PROCESSING"))187 poll_ = get_text(message)188 if not poll_:189 await msg.edit(engine.get_string("REQ_POLL"))190 return191 if "|" not in poll_:192 await msg.edit(engine.get_string("A_POLL_NEEDS"))193 return194 poll_q, poll_options = poll_.split("|")195 if "," not in poll_options:196 await msg.edit(engine.get_string("A_POLL_NEEDS"))197 return198 option_s = poll_options.split(",")199 await client.send_poll(message.chat.id, question=poll_q, options=option_s)200 await msg.delete()201@friday_on_cmd(202 ["dump"],203 cmd_help={204 "help": "Get Pyrogram Message Dumbs!",205 "example": "{ch}dump",206 },207)208async def dumb_er(client, message):209 engine = message.Engine210 ow = await edit_or_reply(message, engine.get_string("PROCESSING"))211 m_sg = message.reply_to_message or message212 owo = f"{m_sg}"213 await edit_or_send_as_file(owo, ow, client, "Json-Dump", "Dump", "md")214@friday_on_cmd(215 ["purgeme"],216 cmd_help={217 "help": "Purge Your Own Message Until Given Limit!",218 "example": "{ch}purgeme 10",219 },220)221async def pur_ge_me(client, message):222 engine = message.Engine223 nice_p = await edit_or_reply(message, engine.get_string("PROCESSING"))224 msg_ids = []225 to_purge = get_text(message)226 if not to_purge:227 nice_p.edit(engine.get_string("TO_PURGE"))228 return229 if not to_purge.isdigit():230 nice_p.edit(engine.get_string("TO_PURGE"))231 return232 async for msg in client.search_messages(233 message.chat.id, query="", limit=int(to_purge), from_user="me"234 ):235 if message.message_id != msg.message_id:236 msg_ids.append(msg.message_id)237 if len(msg_ids) == 100:238 await client.delete_messages(239 chat_id=message.chat.id, message_ids=msg_ids, revoke=True240 )241 msg_ids.clear()242 if msg_ids:243 await client.delete_messages(244 chat_id=message.chat.id, message_ids=msg_ids, revoke=True245 )246 await nice_p.edit(PURGED_MY_MSG.format(to_purge))247@friday_on_cmd(248 ["invite", "add"],249 cmd_help={250 "help": "Add Users To Channel / Groups!",251 "example": "{ch}invite @Midhun_xD @chsaiujwal @meisnub",252 },253)254async def add_user_s_to_group(client, message):255 engine = message.Engine256 mg = await edit_or_reply(message, engine.get_string("PROCESSING"))257 user_s_to_add = get_text(message)258 if not user_s_to_add:259 await mg.edit("`Give Me Users To Add! Check Help Menu For More Info!`")260 return261 user_list = user_s_to_add.split(" ")262 try:263 await client.add_chat_members(message.chat.id, user_list, forward_limit=100)264 except BaseException as e:265 await mg.edit(engine.get_string("UNABLE_TO_ADD_USER").format(e))266 return267 await mg.edit(engine.get_string("ADDED_USER").format(len(user_list)))268@friday_on_cmd(269 ["a2c"],270 cmd_help={271 "help": "Add Users To Your Contacts!",272 "example": "{ch}a2c @Meisnub",273 },274)275async def add_user_s_to_contact(client, message):276 engine = message.Engine277 msg_ = await edit_or_reply(message, engine.get_string("PROCESSING"))278 text_ = get_text(message)279 userk = get_user(message, text_)[0]280 try:281 user_ = await client.get_users(userk)282 except BaseException as e:283 await msg_.edit(engine.get_string("USER_MISSING").format(e))284 return285 custom_name = get_text(message) or user_.first_name286 await client.add_contact(user_.id, custom_name)...
yinsubot.py
Source:yinsubot.py
...12from AyiinXd.ayiin import ayiin_cmd, eor13from Stringyins import get_string14@ayiin_cmd(pattern=r"sadboy(?: |$)(.*)")15async def _(a):16 ayiin = eor(a, get_string("yibot_1"))17 sleep(2)18 await ayiin.edit(get_string("yibot_2"))19 sleep(1)20 await ayiin.edit(get_string("yibot_3"))21# Create by myself @localheart22@ayiin_cmd(pattern=r"lah(?: |$)(.*)")23async def _(y):24 ayiin = await eor(y, get_string("yibot_4"))25 sleep(1)26 await ayiin.edit(get_string("yibot_5"))27 sleep(1)28 await ayiin.edit(get_string("yibot_6"))29 sleep(1)30 await ayiin.edit(get_string("yibot_7"))31@ayiin_cmd(pattern=r"sok(?: |$)(.*)")32async def _(i):33 ayiin = await eor(i, get_string("yibot_8"))34 sleep(2)35 await ayiin.edit(get_string("yibot_9"))36 sleep(2)37 await ayiin.edit(get_string("yibot_10"))38 sleep(2)39 await ayiin.edit(get_string("yibot_11"))40 sleep(2)41 await ayiin.edit(get_string("yibot_12"))42@ayiin_cmd(pattern=r"wah(?: |$)(.*)")43async def _(i):44 ayiin = await eor(i, get_string("yibot_13"))45 sleep(2)46 await ayiin.edit(get_string("yibot_14"))47 sleep(2)48 await ayiin.edit(get_string("yibot_15"))49 sleep(2)50 await ayiin.edit(get_string("yibot_16"))51 sleep(2)52 await ayiin.edit(get_string("yibot_17"))53 sleep(2)54 await ayiin.edit(get_string("yibot_18"))55 sleep(3)56 await ayiin.edit(get_string("yibot_19"))57@ayiin_cmd(pattern=r"alay(?: |$)(.*)")58async def _(n):59 ayiin = await eor(n, get_string("yibot_20"))60 sleep(2)61 await ayiin.edit(get_string("yibot_21"))62 sleep(2)63 await ayiin.edit(get_string("yibot_22"))64 sleep(2)65 await ayiin.edit(get_string("yibot_23"))66 sleep(2)67 await ayiin.edit(get_string("yibot_24"))68@ayiin_cmd(pattern=r"erpe(?: |$)(.*)")69async def _(x):70 ayiin = await eor(x, get_string("yibot_25"))71 sleep(1)72 await ayiin.edit(get_string("yibot_26"))73 sleep(1)74 await ayiin.edit(get_string("yibot_27"))75 sleep(1)76 await ayiin.edit(get_string("yibot_28"))77 sleep(1)78 await ayiin.edit(get_string("yibot_29"))79 sleep(1)80 await ayiin.edit(get_string("yibot_30"))81 sleep(1)82 await ayiin.edit(get_string("yibot_31"))83 sleep(1)84 await ayiin.edit(get_string("yibot_32"))85 sleep(1)86 await ayiin.edit(get_string("yibot_33"))87@ayiin_cmd(pattern=r"tittle(?: |$)(.*)")88async def _(d):89 ayiin = await eor(d, get_string("yibot_34"))90 sleep(2)91 await ayiin.edit(get_string("yibot_35"))92 sleep(2)93 await ayiin.edit(get_string("yibot_36"))94 sleep(2)95 await ayiin.edit(get_string("yibot_37"))96 sleep(2)97 await ayiin.edit(get_string("yibot_38"))98 sleep(2)99 await ayiin.edit(get_string("yibot_39"))100 sleep(2)101 await ayiin.edit(get_string("yibot_40"))102 sleep(2)103 await ayiin.edit(get_string("yibot_41"))104 sleep(2)105 await ayiin.edit(get_string("yibot_42"))106 sleep(2)107 await ayiin.edit(get_string("yibot_43"))108 sleep(2)109 await ayiin.edit(get_string("yibot_44"))110 sleep(2)111 await ayiin.edit(get_string("yibot_45"))112 sleep(2)113 await ayiin.edit(get_string("yibot_46"))114 sleep(4)115 await ayiin.edit(get_string("yibot_47"))116 sleep(2)117 await ayiin.edit(get_string("yibot_48"))118 sleep(3)119 await ayiin.edit(get_string("yibot_49"))120 sleep(3)121 await ayiin.edit(get_string("yibot_50"))122CMD_HELP.update(123 {124 "yinsubot": f"**Plugin : **`yinsubot`\125 \n\n » **Perintah :** `{cmd}sadboy`\126 \n » **Kegunaan : **Gombalan sad\127 \n\n » **Perintah :** `{cmd}wah`\128 \n » **Kegunaan : **Ngeledek orang sok war\129 \n\n » **Perintah :** `{cmd}sok`\130 \n » **Kegunaan : **Ngeledek orang sok keras\131 \n\n » **Perintah :** `{cmd}lah`\132 \n » **Kegunaan : **Engga ketrigger tod\133 \n\n » **Perintah :** `{cmd}alay`\134 \n » **Kegunaan : **Ngatain orang spam bot\135 \n\n » **Perintah :** `{cmd}erpe`\...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!