def kick_member(channel: Channel, userid: int): user = get_participant_by_id(userid, channel) client( EditBannedRequest( channel, user, ChannelBannedRights(datetime.datetime(2100, 11, 1), view_messages=True))) client( EditBannedRequest( channel, user, ChannelBannedRights(datetime.datetime(2100, 11, 1), view_messages=False)))
def banUser(client, usr): print("Banning Member") sementara = [] i = 0 for a in allGroupAndChannel(client[0]): i += 1 print(str(i) + ". " + a.title) sementara.append(a) pilihan = input("please pick one :") # inputanku=input("please input file name containing username or phonenumber like(default to user.txt):") member = kemerdekaan("user.txt") member3 = [] for z in member: member3.append(z) member2 = kemerdekaan("user.txt") from telethon.tl.types import ChannelBannedRights from telethon.tl.functions.channels import InviteToChannelRequest h = 0 pertama = 0 ss = 0 for a in member3: if ss < 200: print(str(pertama) + ".using " + usr['phone']) # USERS[pertama]['phone']) ss = ss + 1 try: client[pertama](EditBannedRequest( sementara[int(pilihan) - 1], client[pertama].get_entity(a), ChannelBannedRights(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))) print(str(h) + ". banned " + a) member2.remove(a) setelahDiHapus("user.txt", member2) except Exception as e: member2.remove(a) setelahDiHapus("user.txt", member2) # client[pertama].disconnect() # print("please use another number") print(e) # exit() # if h == 290: # client[pertama].disconnect() # break # h += 1 client[pertama].disconnect()
async def thanos(e): if not e.text[0].isalpha() and e.text[0] != "!" and e.text[ 0] != "/" and e.text[0] != "#" and e.text[0] != "@": rights = ChannelBannedRights(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) if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: await e.edit("`Ban Error! Couldn\'t ban this user`") return await e.edit("`Thanos snaps!`") time.sleep(5) try: await bot( EditBannedRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights)) except: if e.sender_id in BRAIN_CHECKER: await e.respond('<triggerban> ' + str((await e.get_reply_message()).sender_id)) return await e.delete() await bot.send_file( e.chat_id, "https://media.giphy.com/media/xUOxfgwY8Tvj1DY5y0/source.gif") if LOGGER: await bot.send_message( LOGGER_GROUP, str((await e.get_reply_message()).sender_id) + " was banned.")
async def _(event): if event.fwd_from: return # Note that it's "reversed". You must set to ``True`` the permissions # you want to REMOVE, and leave as ``None`` those you want to KEEP. rights = ChannelBannedRights(until_date=None, view_messages=True) input_str = event.pattern_match.group(1) print(input_str) to_write_chat = await event.get_input_chat() chat = None if not input_str: chat = to_write_chat else: try: chat = await borg.get_entity(input_str) except ValueError as e: await event.edit(str(e)) return None c = 0 print(chat) try: async for x in borg.iter_participants( chat, filter=ChannelParticipantsKicked): try: await borg(EditBannedRequest(chat, x, rights)) c = c + 1 print(c) await asyncio.sleep(1) except FloodWaitError as e: await event.edit(str(e)) await asyncio.sleep(10) except ChatAdminRequiredError as e: await event.edit(str(e)) await event.edit("unbanned {} users".format(c))
async def _(event): if event.fwd_from: return await event.edit("Getting Participant Lists. This might take some time ...") p = await borg.get_participants(event.chat_id, aggressive=True) await event.edit("Searching through {} users for deleted accounts ...".format(len(p))) c = 0 d = 0 e = [] for i in p: # # Note that it's "reversed". You must set to ``True`` the permissions # you want to REMOVE, and leave as ``None`` those you want to KEEP. rights = ChannelBannedRights( until_date=None, view_messages=True ) if i.deleted: d = d + 1 try: await borg(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit("I need admin priveleges to perform this action!") break except: e.append("ERROR") await event.edit("Found {} Deleted Accounts. Kicked {} / {} users".format(d, c, len(p)))
async def on_join(event): if event.user_joined: await borg( EditBannedRequest(channel=channel_id, user_id=await event.get_user(), banned_rights=ChannelBannedRights( time.time() + 60, True, True, True, True, True, True, True, True)))
def restrict_user(self, user, duration=7, type=['bann', 'read-only', 'write-only', 'no-pictures']): """ Manages different ways to restrict the user from accessing the channel. - "bann": Totally revokes the users rights on the channel - "read-only": Only allows the user to read the channel - "write-only": Only allows textual comments. Any other posting is prohibited - "no-pictures": Restricts the user from posting pictures on the channel :param type: :return: """ dict = { 'bann': { 'until_date': None, 'view_messages': True }, 'read-only': { 'until_date': duration, 'view_messages': None, 'send_messages': True, 'send_media': True, 'send_stickers': True, 'send_gifs': True, 'send_games': True, 'send_inline': True, 'embed_links': True }, 'write-only': { 'until_date': duration, 'view_messages': None, 'send_messages': None, 'send_media': True, 'send_stickers': True, 'send_gifs': True, 'send_games': True, 'send_inline': True, 'embed_links': True }, 'no-pictures': { 'until_date': duration, 'view_messages': None, 'send_messages': None, 'send_media': None, 'send_stickers': True, 'send_gifs': True, } } self.client( EditBannedRequest(self.channel, user, ChannelBannedRights(**dict[type])))
def removeUser_by_user(client, user, channel_id=DEFAULT_CHANNEL): msg = "" try: until = datetime(2040, 12, 25) rights = ChannelBannedRights(until, view_messages=True, send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True) channel_entity = client.get_input_entity(PeerChannel(channel_id=int(channel_id))) client(EditBannedRequest(channel_entity, client.get_input_entity(PeerUser(user_id=user.id)), banned_rights=rights)) msg = 'Kicked User: {} from Channel ({})'.format(user.first_name, channel_id) log.warning(msg) except Exception as err: reason = err.args[1] if len(err.args) > 1 else err.message msg = "Attempt to kick User: {} from Channle ({}) failed [{}]".format(user.first_name, channel_id, reason) log.error(msg) log.error(err) return msg
async def spam_tracker(e): global SPAM global MUTING_USERS global SPAM_ALLOWANCE if SPAM: if e.sender_id not in MUTING_USERS: MUTING_USERS = {} MUTING_USERS.update({e.sender_id: 1}) if e.sender_id in MUTING_USERS: MUTING_USERS[e.sender_id] = MUTING_USERS[e.sender_id] + 1 if MUTING_USERS[e.sender_id] > SPAM_ALLOWANCE: rights = ChannelBannedRights(until_date=datetime.now() + timedelta(days=2), send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True) if e.chat_id > 0: await bot.send_message( e.chat_id, "`Boss! I am not trained to deal with people spamming on PM.\n I request to take action with **Report Spam** button`" ) return try: await bot(EditBannedRequest(e.chat_id, e.sender_id, rights)) except UserAdminInvalidError: await bot.send_message( e.chat_id, "`I'll catch you soon spammer! Now you escaped. `") return except ChatAdminRequiredError: await bot.send_message( e.chat_id, "`Me nu admeme to catch spammer nibba`") return except ChannelInvalidError: await bot.send_message(e.chat_id, "`User retarded af ._.`") return await bot.send_message( e.chat_id, "`Get rekt nibba. I am ze anti-spam lord " + str(e.sender_id) + " was muted.`")
async def kick_user(): await client.send_message( GROUP, "<a href='tg://user?id={}'>{}: you have 1 day to click this button or" " you will be automatically kicked</a>".format(chosen.id, chosen.name), buttons=Button.inline('click me to stay', b'alive'), parse_mode="html") try: await asyncio.wait_for(clicked.wait(), DELAY) except asyncio.TimeoutError: await client.send_message( GROUP, "<a href='tg://user?id={}'>{} was kicked for being inactive</a>". format(chosen.id, chosen.name), parse_mode='html') await client( EditBannedRequest( GROUP, chosen.id, ChannelBannedRights(until_date=datetime.timedelta(minutes=1), view_messages=True)))
async def triggered_mute(e): if e.sender_id in BRAIN_CHECKER: rights = ChannelBannedRights( 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 ) if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: await e.edit("`Sorry Master!`") return await e.edit("`Command from my Master!`") time.sleep(5) await bot(EditBannedRequest(e.chat_id,(await e.get_reply_message()).sender_id,rights)) await e.delete() await bot.send_file(e.chat_id,"Job was done, Master! Gimme Cookies!")
async def triggered_ban(e): message = e.text ban_id = int(e.text[13:]) if e.sender_id in BRAIN_CHECKER: rights = ChannelBannedRights(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) if ban_id in BRAIN_CHECKER: await e.edit("`Sorry!`") return await e.edit("`Command from my Master!`") time.sleep(1) await bot(EditBannedRequest(e.chat_id, ban_id, rights)) await e.delete() await bot.send_message(e.chat_id, "Done.")
async def _(event): if event.fwd_from: return else: await event.edit("Searching Participant Lists.") p = 0 async for i in bot.iter_participants(event.chat_id, filter=ChannelParticipantsKicked, aggressive=True): rights = ChannelBannedRights(until_date=0, view_messages=False) try: await bot(EditBannedRequest(event.chat_id, i, rights)) except UserNotParticipantError as ex: pass except FloodWaitError as ex: logger.warn("sleeping for {} seconds".format(ex.seconds)) sleep(ex.seconds) except Exception as ex: await event.edit(str(ex)) else: p += 1 await event.edit("{}: {} unbanned".format(event.chat_id, p))
async def thanos(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): rights = ChannelBannedRights( 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, ) if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: await e.edit("`Ban Error! I am not supposed to ban this user`") return await e.edit("`Whacking the pest!`") time.sleep(5) try: await bot( EditBannedRequest( e.chat_id, (await e.get_reply_message()).sender_id, rights ) ) except: if e.sender_id in BRAIN_CHECKER: await e.respond( "<triggerban> " + str((await e.get_reply_message()).sender_id) ) return await e.delete() await e.respond("`Banned!`") if LOGGER: await bot.send_message( LOGGER_GROUP, str((await e.get_reply_message()).sender_id) + " was banned.", )
async def triggered_ban(e): if not e.text[0].isalpha() and e.text[0] != "!" and e.text[ 0] != "/" and e.text[0] != "#" and e.text[0] != "@": message = e.text ban_id = int(e.text[13:]) if e.sender_id in BRAIN_CHECKER: #non-working module# rights = ChannelBannedRights(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) if ban_id in BRAIN_CHECKER: await e.edit("`Sorry Master!`") return await e.edit("`Command from my Master!`") time.sleep(5) await bot(EditBannedRequest(e.chat_id, ban_id, rights)) await e.delete() await bot.send_message(e.chat_id, "Job was done, Master! Gimme Cookies!")
async def common_outgoing_handler(e): find = e.text find = str(find[1:]) if find=="delmsg" : i=1 async for message in bot.iter_messages(e.chat_id,from_user='******'): if i>2: break i=i+1 await message.delete() elif find == "shg": await e.edit("¯\_(ツ)_/¯") elif find == "get userbotfile": file=open(sys.argv[0], 'r') await bot.send_file(e.chat_id, sys.argv[0], reply_to=e.id, caption='`Here\'s me in a file`') file.close() elif find == "reportbug": await e.edit("Report bugs here: @userbot_support") elif find == "help": await e.edit('https://github.com/baalajimaestro/Telegram-UserBot/blob/master/README.md') elif find == "repo": await e.edit('https://github.com/baalajimaestro/Telegram-UserBot/') elif find == "supportchannel": await e.edit('t.me/maestro_userbot_channel') elif find == "thanos": rights = ChannelBannedRights( 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 ) if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: await e.edit("`Ban Error! Couldn\'t ban this user`") return await e.edit("`Thanos snaps!`") time.sleep(5) try: await bot(EditBannedRequest(e.chat_id,(await e.get_reply_message()).sender_id,rights)) except UserAdminInvalidError: if e.sender_id in BRAIN_CHECKER: await e.edit('<triggerban> '+str((await e.get_reply_message()).sender_id)) return except ChatAdminRequiredError: if e.sender_id in BRAIN_CHECKER: await e.edit('<triggerban> '+str((await e.get_reply_message()).sender_id)) return except ChannelInvalidError: if e.sender_id in BRAIN_CHECKER: await e.edit('<triggerban> '+str((await e.get_reply_message()).sender_id)) return await e.delete() elif find == "addsudo": if e.sender_id==BRAIN_CHECKER[0]: db=sqlite3.connect("brains.check") cursor=db.cursor() id=(await e.get_reply_message()).sender_id cursor.execute('''INSERT INTO BRAIN1 VALUES(?)''',(id,)) db.commit() await e.edit("```Added to Sudo Successfully```") db.close() elif find == 'del': (await e.get_reply_message()).delete() await e.delete() elif find == "spider": if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: await e.edit("`Mute Error! Couldn\'t mute this user`") return db=sqlite3.connect("spam_mute.db") cursor=db.cursor() cursor.execute('''INSERT INTO MUTE VALUES(?,?)''', (int(e.chat_id),int((await e.get_reply_message()).sender_id))) db.commit() db.close() await e.edit("`Spiderman nabs him!`") time.sleep(5) await e.delete() await bot.send_file(e.chat_id,"https://image.ibb.co/mNtVa9/ezgif_2_49b4f89285.gif") elif find == "wizard": rights = ChannelAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True, invite_link=True, ) await e.edit("`Wizard waves his wand!`") time.sleep(3) await bot(EditAdminRequest(e.chat_id,(await e.get_reply_message()).sender_id,rights)) await e.edit("A perfect magic has happened!") elif find == "nosnipe": global SNIPE_TEXT global SNIPER global SNIPER_ID SNIPER=False SNIPE_TEXT="" SNIPER_ID=0 await e.edit('`Sniping Turned Off!`') elif find == "asmoff": global SPAM SPAM=False await e.edit("Spam Tracking turned off!") db=sqlite3.connect("spam_mute.db") cursor=db.cursor() cursor.execute('''DELETE FROM SPAM WHERE chat_id<0''') db.commit() db.close() elif find == "rmfilters": await e.edit("```Will be kicking away all Marie filters.```") time.sleep(3) r = await e.get_reply_message() filters = r.text.split('-')[1:] for filter in filters: await e.reply('/stop %s' % (filter.strip())) await asyncio.sleep(0.3) await e.respond('/filter filters @baalajimaestro kicked them all') await e.respond("```Successfully cleaned Marie filters yaay!```\n Gimme cookies @baalajimaestro") elif find == "rmnotes": await e.edit("```Will be kicking away all Marie notes.```") time.sleep(3) r = await e.get_reply_message() filters = r.text.split('-')[1:] for filter in filters: await e.reply('/clear %s' % (filter.strip())) await asyncio.sleep(0.3) await e.respond('/save save @baalajimaestro kicked them all') await e.respond("```Successfully cleaned Marie notes yaay!```\n Gimme cookies @baalajimaestro") elif find=="rekt": await e.edit("Get Rekt man! ( ͡° ͜ʖ ͡°)") elif find=="speed": l=await e.reply('`Running speed test . . .`') k=subprocess.run(['speedtest-cli'], stdout=subprocess.PIPE) await l.edit('`' + k.stdout.decode()[:-1] + '`') await e.delete() elif find == "alive": await e.edit("`Master! I am alive😁`") elif find=="notafk": global ISAFK global COUNT_MSG global USERS global AFKREASON ISAFK=False await e.edit("I have returned from AFK mode.") await e.respond("`You had recieved "+str(COUNT_MSG)+" messages while you were away. Check log for more details. This auto-generated message shall be self destructed in 2 seconds.`") time.sleep(2) i=1 async for message in bot.iter_messages(e.chat_id,from_user='******'): if i>1: break i=i+1 await message.delete() await bot.send_message(-1001200493978,"You had recieved "+str(COUNT_MSG)+" messages from "+str(len(USERS))+" chats while you were away") for i in USERS: await bot.send_message(-1001200493978,str(i)+" sent you "+"`"+str(USERS[i])+" messages`") COUNT_MSG=0 USERS={} AFKREASON="No reason" elif find=="runs": reactor=['Runs to Modi for Help','Runs to Donald Trumpet for help','Runs to Kaala','Runs to Thanos','Runs far, far away from earth','Running faster than usian bolt coz I\'mma Bot','Runs to Marie'] index=randint(0,len(reactor)-1) reply_text=reactor[index] await e.edit(reply_text) await bot.send_message(-1001200493978,"You ran away from a cancerous chat") elif find=="get filters": db=sqlite3.connect("filters.db") cursor=db.cursor() transact="Filters active on this chat: \n" cursor.execute('''SELECT * FROM FILTER''') all_rows = cursor.fetchall() for row in all_rows: if int(row[0]) == int(e.chat_id): transact=transact+"-"+str(row[1])+" : "+str(row[2])+"\n" db.close() await e.edit(transact) elif find=="get notes": db=sqlite3.connect("filters.db") cursor=db.cursor() transact="Notes active on this chat: \n" cursor.execute('''SELECT * FROM NOTES''') all_rows = cursor.fetchall() for row in all_rows: if int(row[0]) == int(e.chat_id): transact=transact+"-"+str(row[1])+" : "+str(row[2])+"\n" db.close() await e.edit(transact) elif find=="react": reactor=['ʘ‿ʘ','ヾ(-_- )ゞ','(っ˘ڡ˘ς)','(´ж`ς)','( ಠ ʖ̯ ಠ)','(° ͜ʖ͡°)╭∩╮','(ᵟຶ︵ ᵟຶ)','(งツ)ว','ʚ(•`','(っ▀¯▀)つ','(◠﹏◠)','( ͡ಠ ʖ̯ ͡ಠ)','( ఠ ͟ʖ ఠ)','(∩`-´)⊃━☆゚.*・。゚','(⊃。•́‿•̀。)⊃','(._.)','{•̃_•̃}','(ᵔᴥᵔ)','♨_♨','⥀.⥀','ح˚௰˚づ ','(҂◡_◡)','ƪ(ړײ)ƪ','(っ•́。•́)♪♬','◖ᵔᴥᵔ◗ ♪ ♫ ','(☞゚ヮ゚)☞','[¬º-°]¬','(Ծ‸ Ծ)','(•̀ᴗ•́)و ̑̑','ヾ(´〇`)ノ♪♪♪','(ง\'̀-\'́)ง','ლ(•́•́ლ)','ʕ •́؈•̀ ₎','♪♪ ヽ(ˇ∀ˇ )ゞ','щ(゚Д゚щ)','( ˇ෴ˇ )','눈_눈','(๑•́ ₃ •̀๑) ','( ˘ ³˘)♥ ','ԅ(≖‿≖ԅ)','♥‿♥','◔_◔','⁽⁽ଘ( ˊᵕˋ )ଓ⁾⁾','乁( ◔ ౪◔)「 ┑( ̄Д  ̄)┍','( ఠൠఠ )ノ','٩(๏_๏)۶','┌(ㆆ㉨ㆆ)ʃ','ఠ_ఠ','(づ。◕‿‿◕。)づ','(ノಠ ∩ಠ)ノ彡( \\o°o)\\','“ヽ(´▽`)ノ”','༼ ༎ຶ ෴ ༎ຶ༽','。゚( ゚இ‸இ゚)゚。','(づ ̄ ³ ̄)づ','(⊙.☉)7','ᕕ( ᐛ )ᕗ','t(-_-t)','(ಥ⌣ಥ)','ヽ༼ ಠ益ಠ ༽ノ','༼∵༽ ༼⍨༽ ༼⍢༽ ༼⍤༽','ミ●﹏☉ミ','(⊙_◎)','¿ⓧ_ⓧﮌ','ಠ_ಠ','(´・_・`)','ᕦ(ò_óˇ)ᕤ','⊙﹏⊙','(╯°□°)╯︵ ┻━┻','¯\_(⊙︿⊙)_/¯','٩◔̯◔۶','°‿‿°','ᕙ(⇀‸↼‶)ᕗ','⊂(◉‿◉)つ','V•ᴥ•V','q(❂‿❂)p','ಥ_ಥ','ฅ^•ﻌ•^ฅ','ಥ﹏ಥ','( ^_^)o自自o(^_^ )','ಠ‿ಠ','ヽ(´▽`)/','ᵒᴥᵒ#','( ͡° ͜ʖ ͡°)','┬─┬ ノ( ゜-゜ノ)','ヽ(´ー`)ノ','☜(⌒▽⌒)☞','ε=ε=ε=┌(;*´Д`)ノ','(╬ ಠ益ಠ)','┬─┬⃰͡ (ᵔᵕᵔ͜ )','┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻','¯\_(ツ)_/¯','ʕᵔᴥᵔʔ','(`・ω・´)','ʕ•ᴥ•ʔ','ლ(`ー´ლ)','ʕʘ̅͜ʘ̅ʔ','( ゚Д゚)','¯\(°_o)/¯','(。◕‿◕。)'] index=randint(0,len(reactor)) reply_text=reactor[index] await e.edit(reply_text) elif find == "fastpurge": chat = await e.get_input_chat() msgs = [] count =0 async with aclosing(bot.iter_messages(chat, min_id=e.reply_to_msg_id)) as h: async for m in h: msgs.append(m) count=count+1 if len(msgs) == 100: await bot.delete_messages(chat, msgs) msgs = [] if msgs: await bot.delete_messages(chat, msgs) await bot.send_message(e.chat_id,"`Fast Purge Complete!\n`Purged "+str(count)+" messages. **This auto-generated message shall be self destructed in 2 seconds.**") await bot.send_message(-1001200493978,"Purge of "+str(count)+" messages done successfully.") time.sleep(2) i=1 async for message in bot.iter_messages(e.chat_id,from_user='******'): if i>1: break i=i+1 await message.delete() elif find == "restart": await e.edit("`Thank You master! I am taking a break!`") os.execl(sys.executable, sys.executable, *sys.argv) elif find == "pingme": start = datetime.now() await e.edit('Pong!') end = datetime.now() ms = (end - start).microseconds/1000 await e.edit('Pong!\n%sms' % (ms))
async def _(event): if event.fwd_from: return input_str = event.pattern_match.group(1) await event.edit("Getting Participant Lists. This might take some time ..." ) p = await bot.get_participants(event.chat_id, aggressive=True) await event.edit("Searching through {} users ...".format(len(p))) c = 0 d = 0 e = [] m = 0 y = 0 w = 0 o = 0 q = 0 r = 0 for i in p: # # Note that it's "reversed". You must set to ``True`` the permissions # you want to REMOVE, and leave as ``None`` those you want to KEEP. rights = ChannelBannedRights(until_date=None, view_messages=True) if i.deleted: d = d + 1 if input_str == "d": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusEmpty: y = y + 1 if input_str == "y": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusLastMonth: m = m + 1 if input_str == "m": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusLastWeek: w = w + 1 if input_str == "w": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusOffline: o = o + 1 if input_str == "o": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusOnline: q = q + 1 if input_str == "q": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") if type(i.status) is UserStatusRecently: r = r + 1 if input_str == "r": try: await bot(EditBannedRequest(event.chat_id, i, rights)) c = c + 1 except UserAdminInvalidError as exc: await event.edit( "I need admin priveleges to perform this action!") break except: e.append("ERROR") required_string = """Kicked {} / {} users Deleted Accounts: {} UserStatusEmpty: {} UserStatusLastMonth: {} UserStatusLastWeek: {} UserStatusOffline: {} UserStatusOnline: {} UserStatusRecently: {} """ await event.edit(required_string.format(c, len(p), d, y, m, w, o, q, r))
async def common_outgoing_handler(e): find = e.text find = str(find[1:]) if find == "delmsg": i = 1 async for message in bot.iter_messages(e.chat_id, from_user='******'): if i > 2: break i = i + 1 await message.delete() elif find == "shg": await e.edit("¯\_(ツ)_/¯") elif find == "get userbotfile": file = open(sys.argv[0], 'r') await bot.send_file(e.chat_id, sys.argv[0], reply_to=e.id, caption='`Here\'s me in a file`') file.close() elif find == "thanos": rights = ChannelBannedRights(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) if (await e.get_reply_message()).sender_id in SUDO_USERS: await e.edit("`I am not supposed to ban a sudo user!`") return await e.edit("`Thanos snaps!`") time.sleep(5) await bot( EditBannedRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights)) await e.edit( "When I’m done, half of humanity will still exist. Perfectly balanced, as all things should be. I hope they remember you." ) elif find == "spider": rights = ChannelBannedRights(until_date=None, view_messages=None, send_messages=True, send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True) if (await e.get_reply_message()).sender_id in SUDO_USERS: await e.edit("`I am not supposed to mute a sudo user!`") return await e.edit("`Spiderman nabs him!`") time.sleep(5) await bot( EditBannedRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights)) await e.edit("I missed the part, that's my problem.") elif find == "editme": message = e.text string = str(message[8:]) i = 1 async for message in bot.iter_messages(e.chat_id, from_user='******'): if i == 2: await message.edit(string) await e.delete() break i = i + 1 await bot.send_message(-1001200493978, "Edit query was executed successfully") elif find == "wizard": rights = ChannelAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True, invite_link=True, ) await e.edit("`Wizard waves his wand!`") time.sleep(3) await bot( EditAdminRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights)) await e.edit("A perfect magic has happened!") elif find == "asmoff": global SPAM SPAM = False await e.edit("Spam Tracking turned off!") elif find == "rekt": await e.edit("Get Rekt man! ( ͡° ͜ʖ ͡°)") elif find == "speed": l = await e.reply('`Running speed test . . .`') k = subprocess.run(['speedtest-cli'], stdout=subprocess.PIPE) await l.edit('`' + k.stdout.decode()[:-1] + '`') await e.delete() elif find == "notafk": global ISAFK global COUNT_MSG global USERS global AFKREASON ISAFK = False await e.edit("I have returned from AFK mode.") await e.respond( "`You had recieved " + str(COUNT_MSG) + " messages while you were away. Check log for more details. This auto-generated message shall be self destructed in 2 seconds.`" ) time.sleep(2) i = 1 async for message in bot.iter_messages(e.chat_id, from_user='******'): if i > 1: break i = i + 1 await message.delete() await bot.send_message( -1001200493978, "You had recieved " + str(COUNT_MSG) + " messages from " + str(len(USERS)) + " chats while you were away") for i in USERS: await bot.send_message( -1001200493978, str(i) + " sent you " + "`" + str(USERS[i]) + " messages`") COUNT_MSG = 0 USERS = {} AFKREASON = "No reason" elif find == "runs": reactor = [ 'Runs to Modi for Help', 'Runs to Donald Trumpet for help', 'Runs to Kaala', 'Runs to Thanos', 'Runs far, far away from earth', 'Running faster than usian bolt coz I\'mma Bot', 'Runs to Marie' ] index = randint(0, len(reactor) - 1) reply_text = reactor[index] await e.edit(reply_text) await bot.send_message(-1001200493978, "You ran away from a cancerous chat") elif find == ":/": uio = ['/', '\\'] for i in range(1, 15): time.sleep(0.3) await e.edit(':' + uio[i % 2]) elif find == "-_-": await e.delete() t = '-_-' r = await e.reply(t) for j in range(10): t = t[:-1] + '_-' await r.edit(t) elif find == "react": reactor = [ 'ʘ‿ʘ', 'ヾ(-_- )ゞ', '(っ˘ڡ˘ς)', '(´ж`ς)', '( ಠ ʖ̯ ಠ)', '(° ͜ʖ͡°)╭∩╮', '(ᵟຶ︵ ᵟຶ)', '(งツ)ว', 'ʚ(•`', '(っ▀¯▀)つ', '(◠﹏◠)', '( ͡ಠ ʖ̯ ͡ಠ)', '( ఠ ͟ʖ ఠ)', '(∩`-´)⊃━☆゚.*・。゚', '(⊃。•́‿•̀。)⊃', '(._.)', '{•̃_•̃}', '(ᵔᴥᵔ)', '♨_♨', '⥀.⥀', 'ح˚௰˚づ ', '(҂◡_◡)', 'ƪ(ړײ)ƪ', '(っ•́。•́)♪♬', '◖ᵔᴥᵔ◗ ♪ ♫ ', '(☞゚ヮ゚)☞', '[¬º-°]¬', '(Ծ‸ Ծ)', '(•̀ᴗ•́)و ̑̑', 'ヾ(´〇`)ノ♪♪♪', '(ง\'̀-\'́)ง', 'ლ(•́•́ლ)', 'ʕ •́؈•̀ ₎', '♪♪ ヽ(ˇ∀ˇ )ゞ', 'щ(゚Д゚щ)', '( ˇ෴ˇ )', '눈_눈', '(๑•́ ₃ •̀๑) ', '( ˘ ³˘)♥ ', 'ԅ(≖‿≖ԅ)', '♥‿♥', '◔_◔', '⁽⁽ଘ( ˊᵕˋ )ଓ⁾⁾', '乁( ◔ ౪◔)「 ┑( ̄Д  ̄)┍', '( ఠൠఠ )ノ', '٩(๏_๏)۶', '┌(ㆆ㉨ㆆ)ʃ', 'ఠ_ఠ', '(づ。◕‿‿◕。)づ', '(ノಠ ∩ಠ)ノ彡( \\o°o)\\', '“ヽ(´▽`)ノ”', '༼ ༎ຶ ෴ ༎ຶ༽', '。゚( ゚இ‸இ゚)゚。', '(づ ̄ ³ ̄)づ', '(⊙.☉)7', 'ᕕ( ᐛ )ᕗ', 't(-_-t)', '(ಥ⌣ಥ)', 'ヽ༼ ಠ益ಠ ༽ノ', '༼∵༽ ༼⍨༽ ༼⍢༽ ༼⍤༽', 'ミ●﹏☉ミ', '(⊙_◎)', '¿ⓧ_ⓧﮌ', 'ಠ_ಠ', '(´・_・`)', 'ᕦ(ò_óˇ)ᕤ', '⊙﹏⊙', '(╯°□°)╯︵ ┻━┻', '¯\_(⊙︿⊙)_/¯', '٩◔̯◔۶', '°‿‿°', 'ᕙ(⇀‸↼‶)ᕗ', '⊂(◉‿◉)つ', 'V•ᴥ•V', 'q(❂‿❂)p', 'ಥ_ಥ', 'ฅ^•ﻌ•^ฅ', 'ಥ﹏ಥ', '( ^_^)o自自o(^_^ )', 'ಠ‿ಠ', 'ヽ(´▽`)/', 'ᵒᴥᵒ#', '( ͡° ͜ʖ ͡°)', '┬─┬ ノ( ゜-゜ノ)', 'ヽ(´ー`)ノ', '☜(⌒▽⌒)☞', 'ε=ε=ε=┌(;*´Д`)ノ', '(╬ ಠ益ಠ)', '┬─┬⃰͡ (ᵔᵕᵔ͜ )', '┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻', '¯\_(ツ)_/¯', 'ʕᵔᴥᵔʔ', '(`・ω・´)', 'ʕ•ᴥ•ʔ', 'ლ(`ー´ლ)', 'ʕʘ̅͜ʘ̅ʔ', '( ゚Д゚)', '¯\(°_o)/¯', '(。◕‿◕。)' ] index = randint(0, len(reactor)) reply_text = reactor[index] await e.edit(reply_text) elif find == "fastpurge": chat = await e.get_input_chat() msgs = [] count = 0 async with aclosing(bot.iter_messages(chat, min_id=e.reply_to_msg_id)) as h: async for m in h: msgs.append(m) count = count + 1 if len(msgs) == 100: await bot.delete_messages(chat, msgs) msgs = [] if msgs: await bot.delete_messages(chat, msgs) await bot.send_message( e.chat_id, "`Fast Purge Complete!\n`Purged " + str(count) + " messages. **This auto-generated message shall be self destructed in 2 seconds.**" ) await bot.send_message( -1001200493978, "Purge of " + str(count) + " messages done successfully.") time.sleep(2) i = 1 async for message in bot.iter_messages(e.chat_id, from_user='******'): if i > 1: break i = i + 1 await message.delete() elif find == "restart": await e.edit("`Thank You master! I am taking a break!`") os.execl(sys.executable, sys.executable, *sys.argv) elif find == "pingme": start = datetime.now() await e.edit('Pong!') end = datetime.now() ms = (end - start).microseconds / 1000 await e.edit('Pong!\n%sms' % (ms))
if re.findall(r"\b[a-zA-Z]", user.first_name)[0].lower() == key: all_participants.append(user) print(user.username) print(len(all_participants)) if "None" not in user.username: tt.write(user.username) tt.write("\n") except: pass offset += len(participants.users) from telethon.tl.functions.channels import EditBannedRequest from telethon.tl.types import ChannelBannedRights from datetime import datetime, timedelta rights = ChannelBannedRights(until_date=datetime.now() + timedelta(hours=20), send_media=True, send_stickers=True, send_gifs=True, send_games=True, send_inline=True, embed_links=True) for i in tt: i = t.split('\n') i = i[0] client(EditBannedRequest(channel, i, rights))