async def unmoot(unmot): """ .unmute """ # chat = await unmot.get_chat() admin = chat.admin_rights creator = chat.creator # Yönetici değil ise geri dön if not admin and not creator: await unmot.edit(NO_ADMIN) return # try: from userbot.modules.sql_helper.spam_mute_sql import unmute except: await unmot.edit(NO_SQL) return await unmot.edit(LANG['UNMUTING']) user = await get_user_from_event(unmot) user = user[0] if user: pass else: return if unmute(unmot.chat_id, user.id) is False: return await unmot.edit(LANG['ALREADY_UNMUTED']) else: try: await unmot.client( EditBannedRequest(unmot.chat_id, user.id, UNBAN_RIGHTS)) await unmot.edit(LANG['UNMUTED'].format( id = user.id, username = '******' + user.username if user.username else f"[{user.first_name}](tg://user?id={user.id})", first_name = user.first_name, last_name = '' if not user.last_name else user.last_name, mention = f"[{user.first_name}](tg://user?id={user.id})", date = datetime.datetime.strftime(datetime.datetime.now(), '%c'), count = (chat.participants_count) if chat.participants_count else 'Bilinmiyor' )) except UserAdminInvalidError: await unmot.edit(LANG['UNMUTED'].format( id = user.id, username = '******' + user.username if user.username else f"[{user.first_name}](tg://user?id={user.id})", first_name = user.first_name, last_name = '' if not user.last_name else user.last_name, mention = f"[{user.first_name}](tg://user?id={user.id})", date = datetime.datetime.strftime(datetime.datetime.now(), '%c'), count = (chat.participants_count) if chat.participants_count else 'Bilinmiyor' )) except: await unmot.edit(LANG['WTF_MUTE']) return if BOTLOG: await unmot.client.send_message( BOTLOG_CHATID, "#UNMUTE\n" f"İSTİFADECİ: [{user.first_name}](tg://user?id={user.id})\n" f"QRUP: {unmot.chat.title}(`{unmot.chat_id}`)")
async def ban(catty): chat = await catty.get_chat() admin = chat.admin_rights creator = chat.creator # If not admin and not creator, return if not admin and not creator: await edit_or_reply(catty, NO_ADMIN) return catevent = await edit_or_reply(catty, "`banning....`") user, reason = await get_user_from_event(catty) if not user: return if reason: reason = reason.split(" ", 1) hmm = len(reason) cattime = reason[0] reason = reason[1] if hmm == 2 else None else: await catevent.edit("you haven't mentioned time, check `.info tadmin`") return self_user = await catty.client.get_me() ctime = await extract_time(catty, cattime) if not ctime: await catevent.edit( f"Invalid time type specified. Expected m , h , d or w not as {cattime}" ) return if user.id == self_user.id: await catevent.edit(f"Sorry, I can't ban myself") return await catevent.edit("`Whacking the pest!`") try: await catty.client( EditBannedRequest( catty.chat_id, user.id, ChatBannedRights(until_date=ctime, view_messages=True), )) except BadRequestError: await catevent.edit(NO_PERM) return # Helps ban group join spammers more easily try: reply = await catty.get_reply_message() if reply: await reply.delete() except BadRequestError: await catevent.edit( "`I dont have message nuking rights! But still he was banned!`") return # Delete message and then tell that the command # is done gracefully # Shout out the ID, so that fedadmins can fban later if reason: await catevent.edit( f"{user.first_name} was banned in {catty.chat.title}\n" f"banned for {cattime}\n" f"Reason:`{reason}`") if BOTLOG: await catty.client.send_message( BOTLOG_CHATID, "#TBAN\n" f"**User : **[{user.first_name}](tg://user?id={user.id})\n" f"**Chat : **{catty.chat.title}(`{catty.chat_id}`)\n" f"**Banned untill : **`{cattime}`\n" f"**Reason : **__{reason}__", ) else: await catevent.edit( f"{user.first_name} was banned in {catty.chat.title}\n" f"banned for {cattime}\n") if BOTLOG: await catty.client.send_message( BOTLOG_CHATID, "#TBAN\n" f"**User : **[{user.first_name}](tg://user?id={user.id})\n" f"**Chat : **{catty.chat.title}(`{catty.chat_id}`)\n" f"**Banned untill : **`{cattime}`", )
async def rm_deletedacc(show): """ For .ded command, list all the ded accounts in a chat. """ con = show.pattern_match.group(1).lower() del_u = 0 del_status = "`No ded accounts found, Group is clean as hell`" if con != "clean": await show.edit("`Searching for ded accounts...`") async for user in show.client.iter_participants(show.chat_id): if user.deleted: del_u += 1 if del_u > 0: del_status = f"`Found` **{del_u}** `ded account(s) in this group,\ \nclean them by using` `.ded clean`" await show.edit(del_status) return # Here laying the sanity check chat = await show.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not admin and not creator: await show.edit("`I am not an admin here!`") return await show.edit("`Deleting ded accounts...\nOh I can do that?!?!`") del_u = 0 del_a = 0 async for user in show.client.iter_participants(show.chat_id): if user.deleted: try: await show.client( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await show.edit("`I don't have ban rights in this group`") return except UserAdminInvalidError: del_u -= 1 del_a += 1 await show.client( EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"Cleaned **{del_u}** ded account(s)" if del_a > 0: del_status = f"Cleaned **{del_u}** ded account(s) \ \n**{del_a}** def admin accounts are not removed" await show.edit(del_status) await sleep(2) await show.delete() if BOTLOG: await show.client.send_message( BOTLOG_CHATID, "#CLEANUP\n" f"Cleaned **{del_u}** ded account(s) !!\ \nCHAT: {show.chat.title}(`{show.chat_id}`)")
async def startmute(event): if event.is_private: await event.edit("Unexpected issues or ugly errors may occur!") await sleep(3) await event.get_reply_message() userid = event.chat_id replied_user = await event.client(GetFullUserRequest(userid)) chat_id = event.chat_id if is_muted(userid, chat_id): return await event.edit( "This user is already muted in this chat ~~lmfao sed rip~~" ) try: mute(userid, chat_id) except Exception as e: await event.edit("Error occured!\nError is " + str(e)) else: await event.edit("Successfully muted that person.\n**`-´)⊃━☆゚.*・。゚ **") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#PM_MUTE\n" f"USER: [{replied_user.user.first_name}](tg://user?id={userid})\n" f"CHAT: {event.chat.title}(`{event.chat_id}`)", ) else: chat = await event.get_chat() user, reason = await get_user_from_event(event) if not user: return if user.id == bot.uid: return await edit_or_reply(event, "Sorry, I can't mute my self") if is_muted(user.id, event.chat_id): return await edit_or_reply( event, "This user is already muted in this chat ~~lmfao sed rip~~" ) try: admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply( event, "`You can't mute a person without admin rights niqq.` ಥ﹏ಥ " ) return result = await event.client( functions.channels.GetParticipantRequest( channel=event.chat_id, user_id=user.id ) ) try: if result.participant.banned_rights.send_messages: return await edit_or_reply( event, "This user is already muted in this chat ~~lmfao sed rip~~", ) except: pass await event.client(EditBannedRequest(event.chat_id, user.id, MUTE_RIGHTS)) except UserAdminInvalidError: if "admin_rights" in vars(chat) and vars(chat)["admin_rights"] is not None: if chat.admin_rights.delete_messages is not True: return await edit_or_reply( event, "`You can't mute a person if you dont have delete messages permission. ಥ﹏ಥ`", ) elif "creator" not in vars(chat): return await edit_or_reply( event, "`You can't mute a person without admin rights niqq.` ಥ﹏ಥ " ) try: mute(user.id, event.chat_id) except Exception as e: return await edit_or_reply(event, "Error occured!\nError is " + str(e)) except Exception as e: return await edit_or_reply(event, f"**Error : **`{str(e)}`") if reason: await edit_or_reply( event, f"{user.first_name} is muted in {event.chat.title}\n" f"`Reason:`{reason}", ) else: await edit_or_reply( event, f"{user.first_name} is muted in {event.chat.title}" ) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#MUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {event.chat.title}(`{event.chat_id}`)", )
async def catgban(cat): await cat.edit("gbaning.......") start = datetime.now() user, reason = await get_user_from_event(cat) if user: pass else: return if user.id == (await cat.client.get_me()).id: await cat.edit("why would i ban myself") return if user.id in CAT_ID: await cat.edit("why would i ban my DEVELOPER") return try: cat = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") cat = Get(cat) await catmemes.client(cat) except: pass if gban_sql.is_gbanned(user.id): await cat.edit( f"the [user](tg://user?id={user.id}) is already in gbanned list any way checking again" ) else: gban_sql.catgban(user.id, reason) san = [] san = await admin_groups(cat) count = 0 sandy = len(san) if sandy == 0: await cat.edit("you are not admin of atleast one group ") return await cat.edit( f"initiating gban of the [user](tg://user?id={user.id}) in `{len(san)}` groups" ) for i in range(0, sandy): try: await cat.client(EditBannedRequest(san[i], user.id, BANNED_RIGHTS)) await asyncio.sleep(0.5) count += 1 except BadRequestError: await borg.send_message( BOTLOG_CHATID, f"You don't have required permission in :\nCHAT: {cat.chat.title}(`{cat.chat_id}`)\nFor baning here" ) try: reply = await cat.get_reply_message() if reply: await reply.delete() except BadRequestError: await cat.edit( "`I dont have message deleting rights here! But still he was gbanned!`" ) end = datetime.now() cattaken = (end - start).seconds if reason: await cat.edit( f"[{user.first_name}](tg://user?id={user.id}) was gbanned in `{count}` groups in `{cattaken} seconds`!!\nReason: `{reason}`" ) else: await cat.edit( f"[{user.first_name}](tg://user?id={user.id}) was gbanned in `{count}` groups in `{cattaken} seconds`!!" ) if BOTLOG: if count != 0: await borg.send_message( BOTLOG_CHATID, f"#GBAN\nGlobal BAN\nUser: [{user.first_name}](tg://user?id={user.id})\nID: `{user.id}`\ \nReason: `{reason}`\nBanned in `{count}` groups\nTime taken = `{cattaken} seconds`" )
async def zombies(event): """ For .zombies command, list all the zombies in a chat. """ con = event.pattern_match.group(1).lower() del_u = 0 del_status = "bahanchod Ek bhi Deleted Accounts nhi Found, Group Is Clean savach bharat abhiyan." if con != "clean": find_zombies = await event.respond( "Searching For Zombies hmm starting savach group abhiyan.") async for user in event.client.iter_participants(event.chat_id): if user.deleted: del_u += 1 await sleep(1) if del_u > 0: del_status = f"Found **{del_u}** Zombies In This Group.\ \nClean Them By Using - `/zombies clean`" await find_zombies.edit(del_status) return # Here laying the sanity check chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not await is_administrator(user_id=event.from_id, message=event): await event.respond("You're Not An Admin!") return if not admin and not creator: await event.respond( "I Am Not An Admin Here first promote me with full rights!") return cleaning_zombies = await event.respond( "Cleaning Zombies Group ko saaf kr dege...") del_u = 0 del_a = 0 async for user in event.client.iter_participants(event.chat_id): if user.deleted: try: await event.client( EditBannedRequest(event.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await cleaning_zombies.edit( "I Don't Have Ban Rights In This Group first and last bar bolta hu give me all rights." ) return except UserAdminInvalidError: del_u -= 1 del_a += 1 await event.client( EditBannedRequest(event.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"Cleaned `{del_u}` Zombies" if del_a > 0: del_status = f"Cleaned `{del_u}` Zombies \ \n`{del_a}` Zombie Admin Accounts Are Not Removed admin ki bahut respect krta hu" await cleaning_zombies.edit(del_status)
async def rm_deletedacc(show): """ For .adminlist command, list all of the admins of the chat. """ if not show.text[0].isalpha() and show.text[0] not in ("/", "#", "@", "!"): con = show.pattern_match.group(1) del_u = 0 del_status = "`No deleted accounts found, Group is cleaned as Hell`" if not show.is_group: await show.edit("`This command is only for groups!`") return if con != "clean": await show.edit("`Searching for zombie accounts...`") async for user in show.client.iter_participants(show.chat_id): if user.deleted: del_u += 1 if del_u > 0: del_status = f"found **{del_u}** deleted account(s) in this group \ \nclean them by using .delusers clean" await show.edit(del_status) return # Here laying the sanity check chat = await show.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not admin and not creator: await show.edit("`You aren't an admin here!`") return await show.edit("`Cleaning deleted accounts...`") del_u = 0 del_a = 0 async for user in show.client.iter_participants(show.chat_id): if user.deleted: try: await show.client( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await show.edit("`you don't have ban rights in this group`" ) return except UserAdminInvalidError: del_u -= 1 del_a += 1 await show.client( EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"cleaned **{del_u}** deleted account(s)" if del_a > 0: del_status = f"cleaned **{del_u}** deleted account(s) \ \n**{del_a}** deleted admin accounts are not removed" await show.edit(del_status)
async def _(event): if event.fwd_from: return input_str = event.pattern_match.group(1) peer_id = event.chat_id reply = await event.get_reply_message() if not event.is_group: return await edit_delete( event, "`Idiot! ,This is not a group to lock things `") chat_per = (await event.get_chat()).default_banned_rights result = await event.client( functions.channels.GetParticipantRequest(channel=peer_id, user_id=reply.from_id)) admincheck = await is_admin(event.client, peer_id, reply.from_id) if admincheck: return await edit_delete( event, "`This user is admin you cant play with him`") cat = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") msg = chat_per.send_messages media = chat_per.send_media sticker = chat_per.send_stickers gif = chat_per.send_gifs gamee = chat_per.send_games ainline = chat_per.send_inline embed_link = chat_per.embed_links gpoll = chat_per.send_polls adduser = chat_per.invite_users cpin = chat_per.pin_messages changeinfo = chat_per.change_info try: umsg = result.participant.banned_rights.send_messages umedia = result.participant.banned_rights.send_media usticker = result.participant.banned_rights.send_stickers ugif = result.participant.banned_rights.send_gifs ugamee = result.participant.banned_rights.send_games uainline = result.participant.banned_rights.send_inline uembed_link = result.participant.banned_rights.embed_links ugpoll = result.participant.banned_rights.send_polls uadduser = result.participant.banned_rights.invite_users ucpin = result.participant.banned_rights.pin_messages uchangeinfo = result.participant.banned_rights.change_info except AttributeError: umsg = msg umedia = media usticker = sticker ugif = gif ugamee = gamee uainline = ainline uembed_link = embed_link ugpoll = gpoll uadduser = adduser ucpin = cpin uchangeinfo = changeinfo if input_str == "msg": if msg: return await edit_delete( event, "`This Group is locked with messaging permission.`") if not umsg: return await edit_delete( event, "`This User is already unlocked with messaging permission.`") umsg = False locktype = "messages" elif input_str == "media": if media: return await edit_delete( event, "`This Group is locked with sending media`") if not umedia: return await edit_delete( event, "`User is already unlocked with sending media`") umedia = False locktype = "media" elif input_str == "sticker": if sticker: return await edit_delete( event, "`This Group is locked with sending stickers`") if not usticker: return await edit_delete( event, "`This user is already unlocked with sending stickers`") usticker = False locktype = "stickers" elif input_str == "preview": if embed_link: return await edit_delete( event, "`This Group is locked with previewing links`") if not uembed_link: return await edit_delete( event, "`This user is already unlocked with previewing links`") uembed_link = False locktype = "preview links" elif input_str == "gif": if gif: return await edit_delete( event, "`This Group is locked with sending GIFs`") if not ugif: return await edit_delete( event, "`This user is already unlocked with sending GIFs`") ugif = False locktype = "GIFs" elif input_str == "game": if gamee: return await edit_delete( event, "`This Group is locked with sending games`") if not ugamee: return await edit_delete( event, "`This user is already unlocked with sending games`") ugamee = False locktype = "games" elif input_str == "inline": if ainline: return await edit_delete( event, "`This Group is locked with using inline bots`") if not uainline: return await edit_delete( event, "`This user is already unlocked with using inline bots`") uainline = False locktype = "inline bots" elif input_str == "poll": if gpoll: return await edit_delete( event, "`This Group is locked with sending polls`") if not ugpoll: return await edit_delete( event, "`This user is already unlocked with sending polls`") ugpoll = False locktype = "polls" elif input_str == "invite": if adduser: return await edit_delete( event, "`This Group is locked with adding members`") if not uadduser: return await edit_delete( event, "`This user is already unlocked with adding members`") uadduser = False locktype = "invites" elif input_str == "pin": if cpin: return await edit_delete( event, "`This Group is locked with pinning messages by users`", ) if not ucpin: return await edit_delete( event, "`This user is already unlocked with pinning messages by users`", ) ucpin = False locktype = "pins" elif input_str == "info": if changeinfo: return await edit_delete( event, "`This Group is locked with Changing group info by users`", ) if not uchangeinfo: return await edit_delete( event, "`This user is already unlocked with Changing group info by users`", ) uchangeinfo = False locktype = "chat info" elif input_str == "all": if not msg: umsg = False if not media: umedia = False if not sticker: usticker = False if not gif: ugif = False if not gamee: ugamee = False if not ainline: uainline = False if not embed_link: uembed_link = False if not gpoll: ugpoll = False if not adduser: uadduser = False if not cpin: ucpin = False if not changeinfo: uchangeinfo = False locktype = "everything" else: if input_str: return await edit_delete(event, f"**Invalid lock type :** `{input_str}`", time=5) return await edit_or_reply(event, "`I can't lock nothing !!`") try: cat = Get(cat) await event.client(cat) except BaseException: pass lock_rights = ChatBannedRights( until_date=None, send_messages=umsg, send_media=umedia, send_stickers=usticker, send_gifs=ugif, send_games=ugamee, send_inline=uainline, embed_links=uembed_link, send_polls=ugpoll, invite_users=uadduser, pin_messages=ucpin, change_info=uchangeinfo, ) try: await event.client( EditBannedRequest(peer_id, reply.from_id, lock_rights)) await edit_or_reply(event, f"`Unlocked {locktype} for this user !!`") except BaseException as e: await edit_delete( event, f"`Do I have proper rights for that ??`\n\n**Error:** `{str(e)}`", time=5, )
async def spider(spdr): """ This function is basically muting peeps """ # Check if the function running under SQL mode if not is_mongo_alive() or not is_redis_alive(): await spdr.edit(NO_SQL) return # Admin or creator check chat = await spdr.get_chat() admin = chat.admin_rights creator = chat.creator # If not admin and not creator, return if not admin and not creator: await spdr.edit(NO_ADMIN) return user = await get_user_from_event(spdr) if user: pass else: return self_user = await spdr.client.get_me() if user.id == self_user.id: await spdr.edit("`Mute Error! You are not supposed to mute yourself!`") return # If the targeted user is a Sudo if user.id in BRAIN_CHECKER: await spdr.edit("`Mute Error! I am not supposed to mute this user`") return # If everything goes well, do announcing and mute await spdr.edit("`Gets a tape!`") if await mute(spdr.chat_id, user.id) is False: return await spdr.edit('`Error! User probably already muted.`') else: try: await spdr.client( EditBannedRequest(spdr.chat_id, user.id, MUTE_RIGHTS)) # Announce that the function is done await spdr.edit("`Safely taped!`") # Announce to logging group if BOTLOG: await spdr.client.send_message( BOTLOG_CHATID, "#MUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {spdr.chat.title}(`{spdr.chat_id}`)") except UserIdInvalidError: return await spdr.edit("`Uh oh my unmute logic broke!`") # These indicate we couldn't hit him an API mute, possibly an # admin? except (UserAdminInvalidError, ChatAdminRequiredError, BadRequestError): return await spdr.edit("""`I couldn't mute on the API, could be an admin possibly? Anyways muted on the userbot. I'll automatically delete messages in this chat from this person`""")
async def _(event): if event.fwd_from: return if event.is_private: return if event.is_group: if await is_register_admin(event.input_chat, event.message.sender_id): pass else: return warn_reason = event.text[len("/warn "):] if not warn_reason: await event.reply("Please provide a reason for warning.") return reply_message = await event.get_reply_message() if not await is_register_admin(event.input_chat, reply_message.sender_id): pass else: await event.reply("I am not gonna warn an admin") return limit, soft_warn = sql.get_warn_setting(event.chat_id) num_warns, reasons = sql.warn_user(reply_message.sender_id, event.chat_id, warn_reason) if num_warns >= limit: sql.reset_warns(reply_message.sender_id, event.chat_id) if sql.get_warn_strength(event.chat_id) == "kick": await tbot.kick_participant(event.chat_id, reply_message.sender_id) reply = "{} warnings, <u><a href='tg://user?id={}'>user</a></u> has been kicked!".format( limit, reply_message.sender_id) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "ban": BANNED_RIGHTS = ChatBannedRights( until_date=None, view_messages=True, send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True, ) await tbot( EditBannedRequest(event.chat_id, reply_message.sender_id, BANNED_RIGHTS)) reply = "{} warnings, <u><a href='tg://user?id={}'>user</a></u> has been banned!".format( limit, reply_message.sender_id) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "mute": MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True) await tbot( EditBannedRequest(event.chat_id, reply_message.sender_id, MUTE_RIGHTS)) reply = "{} warnings, <u><a href='tg://user?id={}'>user</a></u> has been muted!".format( limit, reply_message.sender_id) await event.reply(reply, parse_mode="html") return else: reply = "<u><a href='tg://user?id={}'>user</a></u> has {}/{} warnings... watch out!".format( reply_message.sender_id, num_warns, limit) if warn_reason: reply += "\nReason: {}".format(html.escape(warn_reason)) chat_id = event.chat_id rules = rulesql.get_rules(chat_id) if rules: await event.reply( reply, buttons=[[ Button.inline('Remove Warn ✖️', data=f"rm_warn-{reply_message.sender_id}"), Button.inline( 'Rules ✝️', data=f'start-ruleswarn-{reply_message.sender_id}') ]], parse_mode="html") else: await event.reply(reply, buttons=[[ Button.inline( 'Remove Warn ✖️', data=f"rm_warn-{reply_message.sender_id}") ]], parse_mode="html")
async def leechers(event): if str(event.sender_id) in str(OWNER_ID): return global spamcounter starttimer = time.time() spamcounter += 1 sender = event.sender_id senderr = await event.get_sender() check = sender USERSPAM = [] if len(USERSPAM) >= 1: if event.sender_id == USERSPAM[0]: pass else: spamcounter = 0 USERSPAM = [] USERSPAM.append(check) else: USERSPAM = [] USERSPAM.append(check) print(spamcounter) if spamcounter > 4: spamtimecheck = time.time() - starttimer if (spamcounter > 4 and event.sender_id == USERSPAM[0] and (time.strftime("%S", time.gmtime(spamtimecheck))) <= "03"): spamcounter = 0 if senderr.username is None: st = senderr.first_name hh = senderr.id final = f"[{st}](tg://user?id={hh}) you are detected as a spammer according to my algorithms.\nYou will be restricted from using any bot commands for 24 hours !" else: st = senderr.username final = f"@{st} you are detected as a spammer according to my algorithms.\nYou will be restricted from using any bot commands for 24 hours !" pass else: return dev = await event.respond(final) client = MongoClient(MONGO_DB_URI) db = client["missElianarobot"] leechers = db.leecher users = leechers.find({}) for c in users: if USERSPAM[0] == c["id"]: print("spammers never die") return timerr = time.time() leechers.insert_one({"id": USERSPAM[0], "time": timerr}) try: MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True) await tbot( EditBannedRequest(event.chat_id, event.sender_id, MUTE_RIGHTS)) await dev.edit(final + "\nYou are now muted !") except Exception: pass
async def mutecmd(self, message): """Команда .mute даёт мут пользователю.\nИспользование: .mute <@ или реплай> <время (1m, 1h, 1d)>.""" if not message.is_private: try: reply = await message.get_reply_message() chat = await message.get_chat() if not chat.admin_rights and not chat.creator: return await utils.answer( message, self.strings('not_admin', message)) else: if chat.admin_rights.ban_users == False: return await utils.answer( message, self.strings('no_rights', message)) if reply: user = await message.client.get_entity(reply.sender_id) else: who = utils.get_args_raw(message).split(' ') user = await message.client.get_entity( who[0] if not who[0].isnumeric() else int(who[0])) if len(who) == 1: timee = ChatBannedRights(until_date=True, send_messages=True) await message.client( EditBannedRequest(message.chat_id, user.id, timee)) await message.edit('<b>{} теперь в муте.</b>'.format( user.first_name)) return if not user: return await utils.answer( message, self.strings('mute_none', message)) if user: tim = who[1] if tim: if len(tim) != 2: return await utils.answer( message, self.strings('no_args', message)) num = '' t = '' for q in tim: if q.isdigit(): num += q else: t += q text = f'<b>{num}' if t == 'm': num = int(num) * 60 text += ' минут(-ы).</b>' elif t == 'h': num = int(num) * 3600 text += ' час(-а/-ов).</b>' elif t == 'd': num = int(num) * 86400 text += ' дня(-ей).</b>' else: return await utils.answer( message, self.strings('no_args', message)) timee = ChatBannedRights(until_date=time.time() + int(num), send_messages=True) try: await message.client( EditBannedRequest(message.chat_id, user.id, timee)) await utils.answer( message, self.strings('muted', message).format( utils.escape_html(user.first_name)) + text) return except: await utils.answer( message, self.strings('no_rights', message)) else: timee = ChatBannedRights(until_date=True, send_messages=True) await message.client( EditBannedRequest(message.chat_id, user.id, timee)) await message.edit( '<b>{} теперь в муте.</b>'.format( user.first_name)) return tim = utils.get_args(message) if tim: if len(tim[0]) < 2: return await utils.answer( message, self.strings('no_args', message)) num = '' t = '' for q in tim[0]: if q.isdigit(): num += q else: t += q text = f'<b>{num}' if t == 'm': num = int(num) * 60 text += ' минут(-ы).</b>' elif t == 'd': num = int(num) * 86400 text += ' дня(-ей) .</b>' elif t == 'h': num = int(num) * 3600 text += ' час(-а/-ов).</b>' else: return await utils.answer( message, self.strings('no_args', message)) timee = ChatBannedRights(until_date=time.time() + int(num), send_messages=True) await message.client( EditBannedRequest(message.chat_id, user.id, timee)) await utils.answer( message, self.strings('muted', message).format( utils.escape_html(user.first_name)) + text) return else: timee = ChatBannedRights(until_date=True, send_messages=True) await message.client( EditBannedRequest(message.chat_id, user.id, timee)) await message.edit('<b>{} теперь в муте.</b>'.format( user.first_name)) return except ValueError: return await utils.answer(message, self.strings('no_args', message)) except UserAdminInvalidError: return await utils.answer(message, self.strings('no_rights', message)) else: await utils.answer(message, self.strings('this_isn`t_a_chat', message))
async def bancmd(self, message): """Команда .ban даёт бан пользователю.\nИспользование: .ban <@ или реплай>.""" if not message.is_private: try: args = utils.get_args_raw(message).split(' ') reason = utils.get_args_raw(message) reply = await message.get_reply_message() chat = await message.get_chat() if not chat.admin_rights and not chat.creator: return await utils.answer( message, self.strings('not_admin', message)) else: if chat.admin_rights.ban_users == False: return await utils.answer( message, self.strings('no_rights', message)) if reply: user = await message.client.get_entity(reply.sender_id) args = utils.get_args_raw(message) if args: reason = args else: user = await message.client.get_entity( args[0] if not args[0].isnumeric() else int(args[0])) if args: if len(args) == 1: args = utils.get_args_raw(message) user = await message.client.get_entity( args if not args.isnumeric() else int(args)) reason = False elif len(args) >= 2: reason = utils.get_args_raw(message).split(' ', 1)[1] try: await utils.answer(message, self.strings('banning', message)) await message.client( EditBannedRequest( message.chat_id, user.id, ChatBannedRights(until_date=None, view_messages=True))) except UserAdminInvalidError: return await utils.answer( message, self.strings('no_rights', message)) if reason == False: return await utils.answer( message, self.strings('banned', message).format(user.first_name)) if reason: return await utils.answer( message, self.strings('banned_for_reason', message).format(user.first_name, reason)) return await utils.answer( message, self.strings('banned', message).format(user.first_name)) except ValueError: return await utils.answer(message, self.strings('no_args', message)) else: return await utils.answer( message, self.strings('this_isn`t_a_chat', message))
async def rm_deletedacc(show): """ .zombies """ con = show.pattern_match.group(1).lower() del_u = 0 del_status = LANG['NO_ZOMBIE'] if con != "clean": await show.edit(LANG['ZOMBIE']) async for user in show.client.iter_participants(show.chat_id): if user.deleted: del_u += 1 await sleep(1) if del_u > 0: del_status = LANG['ZOMBIES'].format(del_u) await show.edit(del_status) return # chat = await show.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await show.edit(LANG['NO_ADMIN']) return await show.edit(LANG['CLEANING']) del_u = 0 del_a = 0 async for user in show.client.iter_participants(show.chat_id): if user.deleted: try: await show.client( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except UserAdminInvalidError: del_u -= 1 del_a += 1 except: await show.edit(LANG['NO_BAN_YT']) return await show.client( EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"**{del_u}** {LANG['DELETED']}" if del_a > 0: del_status = f"**{del_u}** {LANG['DELETED']} \ \n**{del_a}** dənə silinmiş olan admin hesabları çıxarılmadı" await show.edit(del_status) await sleep(2) await show.delete() if BOTLOG: await show.client.send_message( BOTLOG_CHATID, "#TEMIZLIK\n" f"**{del_u}** tane silinmiş hesap çıkartıldı !!\ \nQRUP: {show.chat.title}(`{show.chat_id}`)")
async def zombies(event): """ For .zombies command, list all the zombies in a chat. """ con = event.pattern_match.group(1).lower() del_u = 0 del_status = "No Deleted Accounts Found, Group Is Clean." if con != "clean": find_zombies = await event.respond("Searching For Zombies...") async for user in event.client.iter_participants(event.chat_id): if user.deleted: del_u += 1 await sleep(1) if del_u > 0: del_status = f"Found **{del_u}** Zombies In This Group.\ \nClean Them By Using :-\n 👉 `/zombies clean`" await find_zombies.edit(del_status) return # Here laying the sanity check chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not await is_administrator(user_id=event.from_id, message=event): await event.respond("You're Not An Admin!") return if not admin and not creator: await event.respond("I Am Not An Admin Here!") return cleaning_zombies = await event.respond("Cleaning Zombies...") del_u = 0 del_a = 0 async for user in event.client.iter_participants(event.chat_id): if user.deleted: try: await event.client( EditBannedRequest(event.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await cleaning_zombies.edit( "I Don't Have Ban Rights In This Group.") return except UserAdminInvalidError: del_u -= 1 del_a += 1 await event.client( EditBannedRequest(event.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"Cleaned `{del_u}` Zombies" if del_a > 0: del_status = f"Cleaned `{del_u}` Zombies \ \n`{del_a}` Zombie Admin Accounts Are Not Removed!" await cleaning_zombies.edit(del_status)
async def startmute(event): "To mute a person in that paticular chat" if event.is_private: replied_user = await event.client.get_entity(event.chat_id) if is_muted(event.chat_id, event.chat_id): return await event.edit( "`This user is already muted in this chat ~~lmfao sed rip~~`") if event.chat_id == catub.uid: return await edit_delete(event, "`You cant mute yourself`") try: mute(event.chat_id, event.chat_id) except Exception as e: await event.edit(f"**Error **\n`{e}`") else: await event.edit( "`Successfully muted that person.\n**`-´)⊃━☆゚.*・。゚ **`") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#PM_MUTE\n" f"**User :** [{replied_user.first_name}](tg://user?id={event.chat_id})\n", ) else: chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: return await edit_or_reply( event, "`You can't mute a person without admin rights niqq.` ಥ﹏ಥ ") user, reason = await get_user_from_event(event) if not user: return if user.id == catub.uid: return await edit_or_reply(event, "`Sorry, I can't mute myself`") if is_muted(user.id, event.chat_id): return await edit_or_reply( event, "`This user is already muted in this chat ~~lmfao sed rip~~`") result = await event.client.get_permissions(event.chat_id, user.id) try: if result.participant.banned_rights.send_messages: return await edit_or_reply( event, "`This user is already muted in this chat ~~lmfao sed rip~~`", ) except AttributeError: pass except Exception as e: return await edit_or_reply(event, f"**Error : **`{e}`") try: await event.client( EditBannedRequest(event.chat_id, user.id, MUTE_RIGHTS)) except UserAdminInvalidError: if "admin_rights" in vars(chat) and vars( chat)["admin_rights"] is not None: if chat.admin_rights.delete_messages is not True: return await edit_or_reply( event, "`You can't mute a person if you dont have delete messages permission. ಥ﹏ಥ`", ) elif "creator" not in vars(chat): return await edit_or_reply( event, "`You can't mute a person without admin rights niqq.` ಥ﹏ಥ " ) mute(user.id, event.chat_id) except Exception as e: return await edit_or_reply(event, f"**Error : **`{e}`") if reason: await edit_or_reply( event, f"{_format.mentionuser(user.first_name ,user.id)} `is muted in {get_display_name(await event.get_chat())}`\n" f"`Reason:`{reason}", ) else: await edit_or_reply( event, f"{_format.mentionuser(user.first_name ,user.id)} `is muted in {get_display_name(await event.get_chat())}`\n", ) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#MUTE\n" f"**User :** [{user.first_name}](tg://user?id={user.id})\n" f"**Chat :** {get_display_name(await event.get_chat())}(`{event.chat_id}`)", )
async def rm_deletedacc(show): """ For .delusers command, list all the ghost/deleted accounts in a chat. """ con = show.pattern_match.group(1).lower() del_u = 0 del_status = "`No deleted accounts found, Group is cleaned as Hell`" if not show.is_group: return if show.is_group: if not await can_ban_users(message=show): return # Here laying the sanity check chat = await show.get_chat() admin = chat.admin_rights.ban_users creator = chat.creator # Well if not admin and not creator: await show.reply("`I don't have enough permissions!`") return if con != "clean": await show.reply("`Searching for zombie accounts...`") async for user in tbot.iter_participants(show.chat_id): if user.deleted: del_u += 1 if del_u > 0: del_status = f"Found **{del_u}** deleted account(s) in this group,\ \nclean them by using `/zombies clean`" await show.reply(del_status) return await show.reply("`Deleting deleted accounts...`") del_u = 0 del_a = 0 async for user in tbot.iter_participants(show.chat_id): if user.deleted: try: await tbot( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await show.reply("`I don't have ban rights in this group`") return except UserAdminInvalidError: del_u -= 1 del_a += 1 await tbot(EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"Cleaned **{del_u}** deleted account(s)" if del_a > 0: del_status = f"Cleaned **{del_u}** deleted account(s) \ \n**{del_a}** deleted admin accounts are not removed" await show.reply(del_status)
async def ban(event): if event.fwd_from: return if not event.is_group: poppo = await edit_or_reply(event, "`I don't think this is a group.`") return """ For .ban command, bans the replied/tagged person """ # Here laying the sanity check chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not admin and not creator: poppo = await edit_or_reply(event, NO_ADMIN) return user, reason = await get_user_from_event(event) if user: pass else: return # Announce that we're going to whack the pest poppo = await edit_or_reply(event, "`Dusting Dust of ban Hammer`") try: await event.client( EditBannedRequest(event.chat_id, user.id, BANNED_RIGHTS)) except BadRequestError: await poppo.edit(NO_PERM) return # Helps ban group join spammers more easily try: reply = await event.get_reply_message() if reply: await reply.delete() except BadRequestError: poppio = await edit_or_reply( event, "`I dont have message nuking rights! But still he was banned!`") return # Delete message and then tell that the command # is done gracefully # Shout out the ID, so that fedadmins can fban later if reason: await poppo.edit( f"Sucessfully, Banned [{user.first_name}](tg://user?id={user.id}) in {event.chat.title} For Reason: {reason}" ) else: await poppo.edit( f"Sucessfully, Banned [{user.first_name}](tg://user?id={user.id}) in {event.chat.title}" ) # Announce to the logging group if we have banned the person # successfully! if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#BAN\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {event.chat.title}(`{event.chat_id}`)", )
async def rm_deletedacc(show): con = show.pattern_match.group(1).lower() del_u = 0 del_status = "`Tidak Menemukan Akun Terhapus, Grup Bersih`" if con != "clean": await show.edit("`Mencari Akun Hantu/Terhapus/Zombie...`") async for user in show.client.iter_participants(show.chat_id): if user.deleted: del_u += 1 await sleep(1) if del_u > 0: del_status = ( f"`Menemukan` **{del_u}** `Akun Hantu/Terhapus/Zombie Dalam Grup Ini," "\nBersihkan Itu Menggunakan Perintah .zombies clean`") return await show.edit(del_status) # Here laying the sanity check chat = await show.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not admin and not creator: return await show.edit("`Lord Bukan Admin Disini!`") await show.edit( "`Menghapus Akun Terhapus...\nMohon Menunggu Lord Sedang Dalam Proses`" ) del_u = 0 del_a = 0 async for user in show.client.iter_participants(show.chat_id): if user.deleted: try: await show.client( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: return await show.edit( "`Lord Tidak Memiliki Izin Banned Dalam Grup Ini`") except UserAdminInvalidError: del_u -= 1 del_a += 1 await show.client( EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"`Membersihkan` **{del_u}** `Akun Terhapus`" if del_a > 0: del_status = ( f"Membersihkan **{del_u}** Akun Terhapus " f"\n**{del_a}** `Admin Akun Terhapus Tidak Bisa Dihapus.`") await show.edit(del_status) await sleep(2) await show.delete() if BOTLOG: await show.client.send_message( BOTLOG_CHATID, "#MEMBERSIHKAN\n" f"Membersihkan **{del_u}** Akun Terhapus!" f"\nGRUP: {show.chat.title}(`{show.chat_id}`)", )
async def welcome_mute(welcm): ''' Ban a recently joined user if it matches the spammer checking algorithm.''' try: if not WELCOME_MUTE: return if welcm.user_joined or welcm.user_added: adder = None ignore = None spambot = False users = None if welcm.user_added: ignore = False adder = welcm.action_message.from_id async for admin in bot.iter_participants( welcm.chat_id, filter=ChannelParticipantsAdmins): if admin.id == adder: ignore = True break if ignore: return elif welcm.user_joined: users_list = hasattr(welcm.action_message.action, "users") if users_list: users = welcm.action_message.action.users else: users = [welcm.action_message.from_id] await sleep(5) for user_id in users: async for message in bot.iter_messages(welcm.chat_id, from_user=user_id): correct_type = isinstance(message, Message) if not message or not correct_type: break join_time = welcm.action_message.date message_date = message.date if message_date < join_time: continue # The message was sent before the user joined, thus ignore it # DEBUGGING. LEAVING IT HERE FOR SOME TIME ### print(f"User Joined: {join_time}") print(f"Message Sent: {message_date}") # user = await welcm.client.get_entity(user_id) if "http://" in message.text: spambot = True elif "t.me" in message.text: spambot = True elif message.fwd_from: spambot = True elif "https://" in message.text: spambot = True else: if user.first_name in ("Bitmex", "Promotion", "Information", "Dex", "Announcements", "Info"): if user.last_name == "Bot": spambot = True if spambot: print(f"Potential Spam Message: {message.text}") await message.delete() break continue # Check the next messsage if spambot: chat = await welcm.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await welcm.reply( "@admins\n" "`ANTI SPAMBOT DETECTOR!\n" "THIS USER MATCHES MY ALGORITHMS AS A SPAMBOT!`") else: try: await welcm.reply( "`Potential Spambot Detected! Kicking away! " "Will log the ID for further purposes!\n" f"USER:` [{user.first_name}](tg://user?id={user.id})" ) await welcm.client( EditBannedRequest(welcm.chat_id, user.id, KICK_RIGHTS)) await sleep(1) except BaseException: await welcm.reply( "@admins\n" "`ANTI SPAMBOT DETECTOR!\n" "THIS USER MATCHES MY ALGORITHMS AS A SPAMBOT!`") if BOTLOG: await welcm.client.send_message( BOTLOG_CHATID, "#SPAMBOT-KICK\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {welcm.chat.title}(`{welcm.chat_id}`)") except ValueError: pass
async def rm_deletedacc(show): """ For .delusers command, list all the ghost/deleted accounts in a chat. """ if not show.is_group: await show.edit("`I don't think this is a group.`") return con = show.pattern_match.group(1) del_u = 0 del_status = "`No deleted accounts found, Group is cleaned as Hell`" if con != "clean": await show.edit("`Searching for zombie accounts...`") async for user in show.client.iter_participants(show.chat_id, aggressive=True): if user.deleted: del_u += 1 await sleep(1) if del_u > 0: del_status = f"Found **{del_u}** deleted account(s) in this group,\ \nclean them by using .delusers clean" await show.edit(del_status) return # Here laying the sanity check chat = await show.get_chat() admin = chat.admin_rights creator = chat.creator # Well if not admin and not creator: await show.edit("`I am not an admin here!`") return await show.edit("`Deleting deleted accounts...\nOh I can do that?!?!`") del_u = 0 del_a = 0 async for user in show.client.iter_participants(show.chat_id): if user.deleted: try: await show.client( EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await show.edit("`I don't have ban rights in this group`") return except UserAdminInvalidError: del_u -= 1 del_a += 1 await show.client( EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u > 0: del_status = f"Cleaned **{del_u}** deleted account(s)" if del_a > 0: del_status = f"Cleaned **{del_u}** deleted account(s) \ \n**{del_a}** deleted admin accounts are not removed" await show.edit(del_status) await sleep(2) await show.delete() if Config.PRIVATE_GROUP_BOT_API_ID is not None: await show.client.send_message( Config.PRIVATE_GROUP_BOT_API_ID, "#CLEANUP\n" f"Cleaned **{del_u}** deleted account(s) !!\ \nCHAT: {show.chat.title}(`{show.chat_id}`)")
async def mutecmd(self, mot): """Команда .mute даёт мут пользователю.\nИспользование: .mute <реплай> <время (1m, 1h, 1d)>.""" if mot.chat: chat = await mot.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await utils.answer(mot, self.strings('not_admin', mot)) return if mot.is_reply: user = await utils.get_user(await mot.get_reply_message()) else: return await utils.answer(mot, self.strings('mute_none', mot)) if not user: return await utils.answer(mot, self.strings('who', mot)) logger.debug(user) tim = utils.get_args(mot) if tim: if len(tim[0]) < 2: return await utils.answer(mot, self.strings('no_aargs', mot)) num = '' t = '' for q in tim[0]: if q.isdigit(): num += q else: t += q text = f'<b>{num}' if t == 'm': num = int(num) * 60 text += ' минут(-ы).</b>' elif t == 'd': num = int(num) * 86400 text += ' дня(-ей) .</b>' elif t == 'h': num = int(num) * 3600 text += ' час(-а/-ов).</b>' else: return await utils.answer(mot, self.strings('no_aargs', mot)) timee = ChatBannedRights(until_date=time.time() + int(num), send_messages=True) try: await self.client( EditBannedRequest(mot.chat_id, user.id, timee)) await self.allmodules.log("mute", group=mot.chat_id, affected_uids=[user.id]) await utils.answer( mot, self.strings('muted', mot).format( utils.escape_html(user.first_name)) + text) return except: await utils.answer(mot, self.strings('no_rights', mot)) else: return await utils.answer(mot, self.strings('no_aargs', mot)) else: await utils.answer(mot, self.strings('this_isn`t_a_chat', mot))
async def spider(spdr): if spdr.fwd_from: return """ This function is basically muting peeps """ # Check if the function running under SQL mode try: from userbot.plugins.sql_helper.spam_mute_sql import mute except AttributeError: await spdr.edit(NO_SQL) return # Admin or creator check chat = await spdr.get_chat() admin = chat.admin_rights creator = chat.creator # If not admin and not creator, return if not admin and not creator: await spdr.edit(NO_ADMIN) return user, reason = await get_user_from_event(spdr) if user: pass else: return self_user = await spdr.client.get_me() if user.id == self_user.id: await spdr.edit( "`Hands too short, can't duct tape myself...\n(ヘ・_・)ヘ┳━┳`") return # If everything goes well, do announcing and mute await spdr.edit("`Gets a tape!`") if mute(spdr.chat_id, user.id) is False: return await spdr.edit("`Error! User probably already muted.`") else: try: await spdr.client( EditBannedRequest(spdr.chat_id, user.id, MUTE_RIGHTS)) # Announce that the function is done if reason: await spdr.edit(f"`Safely taped !!`\nReason: {reason}") else: await spdr.edit("`Safely taped !!`") # Announce to logging group if BOTLOG: await spdr.client.send_message( BOTLOG_CHATID, "#MUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {spdr.chat.title}(`{spdr.chat_id}`)", ) except UserIdInvalidError: return await spdr.edit("`Uh oh my mute logic broke!`")
async def deluserscmd(self, delus): """Команда .delusers показывает список всех удалённых аккаунтов в чате.\nИспользование: .delusers (clean).""" if not delus.is_group: await utils.answer(delus, self.strings('this_isn`t_a_chat', delus)) return con = utils.get_args_raw(delus) del_u = 0 del_status = '<b>Нету удалённых аккаунтов, чат очищен.</b>' if con != "clean": await utils.answer(delus, self.strings('del_u_search', delus)) async for user in delus.client.iter_participants(delus.chat_id): if user.deleted: del_u += 1 await sleep(1) if del_u == 1: del_status = f"<b>Найден {del_u} удаленный аккаунт в чате, очистите их с помощью </b><code>.delusers clean</code><b>.</b>" if del_u > 0: del_status = f"<b>Найдено {del_u} удаленных аккаунтов в чате, очистите их с помощью </b><code>.delusers clean</code><b>.</b>" await delus.edit(del_status) return chat = await delus.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await utils.answer(delus, self.strings('not_admin', delus)) return await utils.answer(delus, self.strings('del_u_kicking', delus)) del_u = 0 del_a = 0 async for user in delus.client.iter_participants(delus.chat_id): if user.deleted: try: await delus.client( EditBannedRequest(delus.chat_id, user.id, BANNED_RIGHTS)) except ChatAdminRequiredError: await utils.answer(delus, self.strings('no_rights', delus)) return except UserAdminInvalidError: del_u -= 1 del_a += 1 await delus.client( EditBannedRequest(delus.chat_id, user.id, UNBAN_RIGHTS)) del_u += 1 if del_u == 1: del_status = f"<b>Кикнут {del_u} удалённый аккаунт</b>" if del_u > 0: del_status = f"<b>Кикнуто {del_u} удалённых аккаунтов</b>" if del_a == 1: del_status = f"<b>Кикнут {del_u} удалённый аккаунт\ \n{del_a} удалённые аккаунты админов не кикнуты</b>" if del_a > 0: del_status = f"<b>Кикнуто {del_u} удалённых аккаунтов\ \n{del_a} удалённые аккаунты админов не кикнуты</b>" await delus.edit(del_status) await sleep(2) await delus.delete()
async def tmuter(catty): chat = await catty.get_chat() admin = chat.admin_rights creator = chat.creator # If not admin and not creator, return if not admin and not creator: await edit_or_reply(catty, NO_ADMIN) return catevent = await edit_or_reply(catty, "`muting....`") user, reason = await get_user_from_event(catty) if not user: return if reason: reason = reason.split(" ", 1) hmm = len(reason) cattime = reason[0] reason = reason[1] if hmm == 2 else None else: await catevent.edit("you haven't mentioned time, check `.info tadmin`") return self_user = await catty.client.get_me() ctime = await extract_time(catty, cattime) if not ctime: await catevent.edit( f"Invalid time type specified. Expected m , h , d or w not as {cattime}" ) return if user.id == self_user.id: await catevent.edit(f"Sorry, I can't mute myself") return try: await catevent.client( EditBannedRequest( catty.chat_id, user.id, ChatBannedRights(until_date=ctime, send_messages=True), )) # Announce that the function is done if reason: await catevent.edit( f"{user.first_name} was muted in {catty.chat.title}\n" f"**Muted for : **{cattime}\n" f"**Reason : **__{reason}__") if BOTLOG: await catty.client.send_message( BOTLOG_CHATID, "#TMUTE\n" f"**User : **[{user.first_name}](tg://user?id={user.id})\n" f"**Chat : **{catty.chat.title}(`{catty.chat_id}`)\n" f"**Muted for : **`{cattime}`\n" f"**Reason : **`{reason}``", ) else: await catevent.edit( f"{user.first_name} was muted in {catty.chat.title}\n" f"Muted for {cattime}\n") if BOTLOG: await catty.client.send_message( BOTLOG_CHATID, "#TMUTE\n" f"**User : **[{user.first_name}](tg://user?id={user.id})\n" f"**Chat : **{catty.chat.title}(`{catty.chat_id}`)\n" f"**Muted for : **`{cattime}`", ) # Announce to logging group except UserIdInvalidError: return await catevent.edit("`Uh oh my mute logic broke!`")
async def _(event): yep = event.pattern_match.group(1) try: if event.fwd_from: return if event.is_private: return if event.is_group: if await is_register_admin(event.input_chat, event.message.sender_id): pass else: return quew = event.pattern_match.group(2) if event.reply_to_msg_id: warn_reason = event.text[len("/warn "):] if not warn_reason: warn_reason = "None" reply_message = await event.get_reply_message() if yep == "dwarn": await reply_message.delete() else: pass if not await is_register_admin(event.input_chat, reply_message.sender_id): pass else: await event.reply("I am not gonna warn an admin") return if reply_message.sender_id == BOT_ID: await event.reply( "You are a Funny one aren't you, trying to warn me 😏?") return limit, soft_warn = sql.get_warn_setting(event.chat_id) num_warns, reasons = sql.warn_user(reply_message.sender_id, event.chat_id, warn_reason) if num_warns >= limit: sql.reset_warns(reply_message.sender_id, event.chat_id) if sql.get_warn_strength(event.chat_id) == "kick": await tbot.kick_participant(event.chat_id, reply_message.sender_id) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been kicked!".format( limit, reply_message.sender_id, reply_message.sender.first_name) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "ban": BANNED_RIGHTS = ChatBannedRights( until_date=None, view_messages=True, send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True, ) await tbot( EditBannedRequest(event.chat_id, reply_message.sender_id, BANNED_RIGHTS)) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been banned!".format( limit, reply_message.sender_id, reply_message.sender.first_name) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "mute": MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True) await tbot( EditBannedRequest(event.chat_id, reply_message.sender_id, MUTE_RIGHTS)) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been muted!".format( limit, reply_message.sender_id, reply_message.sender.first_name) await event.reply(reply, parse_mode="html") return else: pro = "User <a href='tg://user?id={}'>{}</a> has {}/{} warnings. watch out!".format( reply_message.sender_id, reply_message.sender.first_name, num_warns, limit) if warn_reason == "None": reply = pro else: pro += "\nReason: {}".format(html.escape(warn_reason)) reply = pro chat_id = event.chat_id rules = rulesql.get_rules(chat_id) if rules: await event.reply( reply, buttons=[[ Button.inline( "Remove warn (admin only)", data=f"rm_warn-{reply_message.sender_id}"), Button.inline( "Rules ✝️", data=f"start-ruleswarn-{reply_message.sender_id}"), ]], parse_mode="html", ) else: await event.reply( reply, buttons=[[ Button.inline( "Remove warn (admin only)", data=f"rm_warn-{reply_message.sender_id}") ]], parse_mode="html", ) if not event.reply_to_msg_id and quew: if "|" in quew: iid, reasonn = quew.split("|") cid = iid.strip() reason = reasonn.strip() if cid.isnumeric(): cid = int(cid) entity = await tbot.get_entity(cid) try: r_sender_id = entity.id r_sender_fname = entity.first_name except Exception: await event.reply("Couldn't fetch that user.") return if not reason: await event.reply("Please provide a reason for warning.") return warn_reason = reason if not await is_register_admin(event.input_chat, r_sender_id): pass else: await event.reply("I am not gonna warn an admin") return if r_sender_id == BOT_ID: await event.reply("Why are you trying to warn me ?") return limit, soft_warn = sql.get_warn_setting(event.chat_id) num_warns, reasons = sql.warn_user(r_sender_id, event.chat_id, warn_reason) if num_warns >= limit: sql.reset_warns(r_sender_id, event.chat_id) if sql.get_warn_strength(event.chat_id) == "kick": await tbot.kick_participant(event.chat_id, r_sender_id) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been kicked!".format( limit, r_sender_id, r_sender_fname) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "ban": BANNED_RIGHTS = ChatBannedRights( until_date=None, view_messages=True, send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True, ) await tbot( EditBannedRequest(event.chat_id, r_sender_id, BANNED_RIGHTS)) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been banned!".format( limit, r_sender_id, r_sender_fname) await event.reply(reply, parse_mode="html") return if sql.get_warn_strength(event.chat_id) == "mute": MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True) await tbot( EditBannedRequest(event.chat_id, r_sender_id, MUTE_RIGHTS)) reply = "{} warnings, <a href='tg://user?id={}'>{}</a> has been muted!".format( limit, r_sender_id, r_sender_fname) await event.reply(reply, parse_mode="html") return else: reply = "<a href='tg://user?id={}'>{}</a> has {}/{} warnings... watch out!".format( r_sender_id, r_sender_fname, num_warns, limit) if warn_reason: reply += "\nReason: {}".format(html.escape(warn_reason)) chat_id = event.chat_id rules = rulesql.get_rules(chat_id) if rules: await event.reply( reply, buttons=[[ Button.inline("Remove warn (admin only)", data=f"rm_warn-{r_sender_id}"), Button.inline("Rules ✝️", data=f"start-ruleswarn-{r_sender_id}"), ]], parse_mode="html", ) else: await event.reply( reply, buttons=[[ Button.inline("Remove warn (admin only)", data=f"rm_warn-{r_sender_id}") ]], parse_mode="html", ) except Exception as e: print(e)
async def startmute(event): if event.fwd_from: return if event.is_private: await event.edit("Podem ocorrer problemas inesperados ou erros!") await sleep(3) await event.get_reply_message() userid = event.chat_id replied_user = await event.client(GetFullUserRequest(userid)) chat_id = event.chat_id if is_muted(userid, chat_id): return await event.edit( "Este usuário já está silenciado neste chat.") try: mute(userid, chat_id) except Exception as e: await event.edit("Ocorreu um erro!\nErro é " + str(e)) else: await event.edit( "Essa pessoa foi silenciada com sucesso.\n**`-´)⊃━☆゚.*・。゚ **") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#PM_MUTE\n" f"USER: [{replied_user.user.first_name}](tg://user?id={userid})\n" f"CHAT: {event.chat.title}(`{event.chat_id}`)", ) else: chat = await event.get_chat() user, reason = await get_user_from_event(event) if not user: return if user.id == bot.uid: return await edit_or_reply(event, "Desculpe, não consigo me silenciar🤭") if is_muted(user.id, event.chat_id): return await edit_or_reply( event, "Este usuário já está silenciado neste chat.") try: admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply( event, "`Você não pode silenciar uma pessoa sem direitos de administrador.` ಥ﹏ಥ " ) return result = await event.client( functions.channels.GetParticipantRequest(channel=event.chat_id, user_id=user.id)) try: if result.participant.banned_rights.send_messages: return await edit_or_reply( event, "Este usuário já está silenciado neste chat.", ) except: pass await event.client( EditBannedRequest(event.chat_id, user.id, MUTE_RIGHTS)) except UserAdminInvalidError: if "admin_rights" in vars(chat) and vars( chat)["admin_rights"] is not None: if chat.admin_rights.delete_messages is not True: return await edit_or_reply( event, "`Você não pode silenciar uma pessoa se não tiver permissão para excluir mensagens. ಥ﹏ಥ`", ) elif "creator" not in vars(chat): return await edit_or_reply( event, "`Você não pode silenciar uma pessoa sem direitos de administrador.` ಥ﹏ಥ " ) try: mute(user.id, event.chat_id) except Exception as e: return await edit_or_reply( event, "Ocorreu um erro!\nErro é " + str(e)) except Exception as e: return await edit_or_reply(event, f"**Erro: **`{str(e)}`") if reason: await edit_or_reply( event, f"{user.first_name} está silenciado em {event.chat.title}\n" f"`Motivo:`{reason}", ) else: await edit_or_reply( event, f"{user.first_name} está silenciado em {event.chat.title}") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#MUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {event.chat.title}(`{event.chat_id}`)", )
async def rm_deletedacc(eventDeletedAccs): if not eventDeletedAccs.text[0].isalpha() and eventDeletedAccs.text[0] not in ("/", "#", "@", "!"): con = eventDeletedAccs.pattern_match.group(1) del_u = 0 del_status = "`No deleted accounts found, Group is cleaned as Hell`" if not eventDeletedAccs.is_group: await eventDeletedAccs.edit("`This command is only for groups!`") return if con != "clean": await eventDeletedAccs.edit("`Searching for ded af accounts...`") async for user in eventDeletedAccs.client.iter_participants( eventDeletedAccs.chat_id ): if user.deleted: del_u += 1 if del_u > 0: del_status = f"found **{del_u}** deleted account(s) in this group \ \nClean them by using .delusers clean" await eventDeletedAccs.edit(del_status) return chat = await eventDeletedAccs.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await eventDeletedAccs.edit("`I am not an admin here!`") return await eventDeletedAccs.edit("`Deleting deleted accounts...\nOh I can do that?!?!`") del_u = 0 del_a = 0 async for user in eventDeletedAccs.client.iter_participants( eventDeletedAccs.chat_id ): if user.deleted: try: await eventDeletedAccs.client( EditBannedRequest( eventDeletedAccs.chat_id, user.id, BANNED_RIGHTS ) ) except ChatAdminRequiredError: await eventDeletedAccs.edit("`I don't have ban rights in this group`") return except UserAdminInvalidError: del_u -= 1 del_a += 1 await eventDeletedAccs.client( EditBannedRequest( eventDeletedAccs.chat_id, user.id, UNBAN_RIGHTS ) ) del_u += 1 if del_u > 0: del_status = f"Cleaned **{del_u}** deleted account(s)" if del_a > 0: del_status = f"Cleaned **{del_u}** deleted account(s) \ \n**{del_a}** deleted admin accounts are not removed." await eventDeletedAccs.edit(del_status)
async def ban(bon): """ .ban komutu belirlenen kişiyi gruptan yasaklar """ # Yetki kontrolü chat = await bon.get_chat() admin = chat.admin_rights creator = chat.creator import datetime if not admin and not creator: await bon.edit(NO_ADMIN) return user, reason = await get_user_from_event(bon) if user: pass else: return # Eğer kullanıcı sudo ise if user.id in BRAIN_CHECKER: await bon.edit("`Ban Hatası! Asena Yetkilisini yasaklayamam.`") return # Hedefi yasaklayacağınızı duyurun await bon.edit("`Kullanıcı yollanıyor...`") try: await bon.client(EditBannedRequest(bon.chat_id, user.id, BANNED_RIGHTS)) except: await bon.edit(NO_PERM) return # Spamcılar için try: reply = await bon.get_reply_message() if reply: await reply.delete() except: await bon.edit( "`Mesaj atma hakkım yok! Ama yine de kullanıcı yasaklandı!`") return # Mesajı silin ve ardından komutun # incelikle yapıldığını söyleyin BANLAYAN = await bot.get_me() SONMESAJ = PLUGIN_MESAJLAR['ban'].replace( "$username", f"@{user.username}" if user.username else "[{}](tg://user?id={})".format(user.first_name, user.id)).replace( "$id", "`" + str(user.id) + "`").replace( "$date", datetime.datetime.strftime( datetime.datetime.now(), '%c')).replace( "$from", f"@{BANLAYAN.username}" if BANLAYAN.username else "[{}](tg://user?id={})".format( BANLAYAN.first_name, BANLAYAN.id)) if reason: await bon.edit(f"{SONMESAJ}\nNedeni: {reason}") else: await bon.edit(f"{SONMESAJ}") # Yasaklama işlemini günlüğe belirtelim if BOTLOG: await bon.client.send_message( BOTLOG_CHATID, "#BAN\n" f"KULLANICI: [{user.first_name}](tg://user?id={user.id})\n" f"GRUP: {bon.chat.title}(`{bon.chat_id}`)")
async def ban(bon): """ .ban""" # chat = await bon.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await bon.edit(NO_ADMIN) return user, reason = await get_user_from_event(bon) if user: pass else: return # if user.id in BRAIN_CHECKER or user.id in WHITELIST: await bon.edit( LANG['BRAIN'] ) return # await bon.edit(LANG['BANNING']) try: await bon.client(EditBannedRequest(bon.chat_id, user.id, BANNED_RIGHTS)) except: await bon.edit(NO_PERM) return # try: reply = await bon.get_reply_message() if reply: await reply.delete() except: await bon.edit( LANG['NO_PERM_BUT_BANNED']) return # # SONMESAJ = PLUGIN_MESAJLAR['ban'].format( id = user.id, username = '******' + user.username if user.username else f"[{user.first_name}](tg://user?id={user.id})", first_name = user.first_name, last_name = '' if not user.last_name else user.last_name, mention = f"[{user.first_name}](tg://user?id={user.id})", date = datetime.datetime.strftime(datetime.datetime.now(), '%c'), count = (chat.participants_count - 1) if chat.participants_count else 'Bilinmiyor' ) if reason: await bon.edit(f"{SONMESAJ}\n{LANG['REASON']}: {reason}") else: await bon.edit(SONMESAJ) # if BOTLOG: await bon.client.send_message( BOTLOG_CHATID, "#BAN\n" f"İSTİFADECİ: [{user.first_name}](tg://user?id={user.id})\n" f"QRUP: {bon.chat.title}(`{bon.chat_id}`)")