async def wizzard(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): rights = ChannelAdminRights( add_admins=False, invite_users=False, change_info=False, ban_users=False, delete_messages=False, pin_messages=False, invite_link=False, ) chat=await e.get_chat() rights = chat.admin_rights rights2 = chat.creator if not (await e.get_reply_message()): await e.edit("`Give a reply message`") return if not rights and not rights2: await e.edit("`You aren't an admin!`") return await e.edit("`Trying a demote.....`") time.sleep(3) await bot( EditAdminRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights) ) await e.edit("`Demoted Successfully!`")
async def wizzard(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): chats=await e.get_chat() rights = chats.admin_rights rights3 = chats.creator rights2 = ChannelAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True, invite_link=True, ) if not (await e.get_reply_message()): await e.edit("`Give a reply message`") return elif not rights and rights3: rights=rights2 elif not rights and not rights3: rights=None await e.edit("`Trying a promote.....`") time.sleep(3) try: await bot( EditAdminRequest(e.chat_id, (await e.get_reply_message()).sender_id, rights) ) except Exception as er: await e.edit("`You Don't have sufficient permissions to paramod`") return await e.edit("`Promoted Successfully!`")
def initialize_Channel(client=None, course_title=None, section_number=None, channel_name=None): results = {'status': False} title = '' if client == None: raise Exception( 'Client is invalid. Please connect to telegram client first.') if course_title != None and section_number != None: fin_year = getFinancialYear() title = (fin_year + ' ' + course_title + ' ' + section_number).strip() if channel_name != None: title = channel_name if title == '': raise Exception( 'Please specify a course tittle and section number OR a channel name.' ) # Create channel for specified user if dialogExists(client, title, Channel): results['status'] = True results['message'] = title + ' channel already exists within Telegram.' else: client( channels.CreateChannelRequest( title=title, about='This channel is for students in ' + title)) channel_entity = getEntity(client, title, Channel) admin_rights = ChannelAdminRights( change_info=True, post_messages=True, edit_messages=True, delete_messages=True, ban_users=True, invite_users=True, invite_link=True, pin_messages=True, add_admins=True, ) client( channels.EditAdminRequest(channel=channel_entity.id, user_id='@SMUCLEBot', admin_rights=admin_rights)) results['status'] = True results['message'] = title + ' channel create.' invite_link = client( channels.ExportInviteRequest(getEntity(client, title, Channel).id)) results['channel_name'] = title results['channel_link'] = invite_link.link return results
def set_admin(self, owner_client, sender, owner_channel): owner_client( EditAdminRequest(channel=owner_channel, user_id=InputUser(sender.id, sender.access_hash), admin_rights=ChannelAdminRights( change_info=True, post_messages=True, edit_messages=True, delete_messages=True, ban_users=True, invite_users=True, invite_link=True, pin_messages=True, add_admins=True, )))
async def wizzard(e): 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!")
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 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))