async def glitch(client, message): cmd = message.command amount = "" if len(cmd) > 1: amount = " ".join(cmd[1:]) elif len(cmd) == 1: amount = "2" profile_photo = "nana/downloads/pfp.jpg" glitched_gif = "nana/downloads/glitched_pfp.gif" replied = message.reply_to_message if not replied: await message.delete() return user = await client.get_users(replied.from_user.id) await client.download_media(user.photo.big_file_id, file_name=profile_photo) subprocess.run( ["glitch_this", profile_photo, f"{amount}", "--gif"], capture_output=True, text=True, ) await client.send_animation(message.chat.id, glitched_gif, reply_to_message_id=ReplyCheck(message)) await message.delete() os.remove(profile_photo) os.remove(glitched_gif)
async def spam_stick(client, message): if not message.reply_to_message: await edit_or_reply( message, text='**Reply to a sticker with the amount.**', ) return if not message.reply_to_message.sticker: await edit_or_reply( message, text='**Reply to a sticker with the amount.**', ) return else: times = message.command[1] if message.chat.type in ['supergroup', 'group']: for _ in range(int(times)): await client.send_sticker( message.chat.id, sticker=message.reply_to_message.sticker.file_id, reply_to_message_id=ReplyCheck(message), ) await asyncio.sleep(0.20) if message.chat.type == 'private': for _ in range(int(times)): await client.send_message( message.chat.id, sticker=message.reply_to_message.sticker.file_id, ) await asyncio.sleep(0.20)
async def spam_stick(client, message): if not message.reply_to_message: await edit_or_reply( message, text="**reply to a sticker with amount you want to spam**") return if not message.reply_to_message.sticker: await edit_or_reply( message, text="**reply to a sticker with amount you want to spam**") return else: times = message.command[1] if message.chat.type in ["supergroup", "group"]: for _ in range(int(times)): await client.send_sticker( message.chat.id, sticker=message.reply_to_message.sticker.file_id, reply_to_message_id=ReplyCheck(message), ) await asyncio.sleep(0.20) if message.chat.type == "private": for _ in range(int(times)): await client.send_message( message.chat.id, sticker=message.reply_to_message.sticker.file_id) await asyncio.sleep(0.20)
async def senpai_sticker(client, message): cmd = message.command senpai = '' if len(cmd) > 1: senpai = ' '.join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: senpai = message.reply_to_message.text elif len(cmd) == 1: await edit_or_reply( message, text='`No text Given hence the senpai Ran Away.`', ) await asyncio.sleep(2) await message.delete() return x = await client.get_inline_bot_results( 'Stickerizerbot', f'#{random.choice(senpais)}{senpai}', ) await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def github(client, message): if len(message.text.split()) == 1: await edit_or_reply(message, text='Usage: `git (username)`') return username = message.text.split(None, 1)[1] URL = f'https://api.github.com/users/{username}' async with aiohttp.ClientSession() as session: async with session.get(URL) as request: if request.status == 404: return await edit_or_reply( message, text='`' + username + ' not found`', ) result = await request.json() url = result.get('html_url', None) name = result.get('name', None) company = result.get('company', None) bio = result.get('bio', None) created_at = result.get('created_at', 'Not Found') repo_url = f'https://github.com/{username}?tab=repositories' REPLY = ( '**Info Of {}**' '\n**Username:** `{}`\n**Bio:** `{}`\n**Profile:** [Link]({})' '\n**Company:** `{}`\n**Created at:** `{}`' '\n**Repository:** [Link]({})').format( name, username, bio, url, company, created_at, repo_url, ) url = f'https://ghchart.rshah.org/{username}' file_name = f'{randint(1, 999)}{username}' resp = await AioHttp.get_raw(url) f = await aiofiles.open(f'{file_name}.svg', mode='wb') await f.write(resp) await f.close() try: drawing = svg2rlg(f'{file_name}.svg') renderPM.drawToFile(drawing, f'{file_name}.png') except UnboundLocalError: await edit_or_reply(message, text='`User does not exist!`') await sleep(2) await message.delete() return await asyncio.gather( client.send_photo( chat_id=message.chat.id, photo=f'{file_name}.png', caption=REPLY, reply_to_message_id=ReplyCheck(message), ), ) for file in iglob(f'{file_name}.*'): os.remove(file)
async def lastfm(client, message): x = await client.get_inline_bot_results("lastfmrobot", "") await message.delete() await message.reply_inline_bot_result( x.query_id, x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def alive_msg(client, message): x = await client.get_inline_bot_results(f'{BotUsername}', 'alive') await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def favourite_animelist(client, message): x = await client.get_inline_bot_results(f"{BotUsername}", "favourite") await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def speed_test_inline(client, message): x = await client.get_inline_bot_results(f"{BotUsername}", "speedtest") await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def pat(client, message): async with aiohttp.ClientSession() as session: URL = "https://some-random-api.ml/animu/pat" async with session.get(URL) as request: if request.status == 404: return await edit_or_reply(message, text="**no Pats for u :c**") result = await request.json() url = result.get("link", None) await message.delete() await client.send_video(message.chat.id, url, reply_to_message_id=ReplyCheck(message))
async def github(client, message): if len(message.text.split()) == 1: await edit_or_reply(message, text="Usage: `git (username)`") return username = message.text.split(None, 1)[1] URL = f"https://api.github.com/users/{username}" async with aiohttp.ClientSession() as session: async with session.get(URL) as request: if request.status == 404: return await edit_or_reply(message, text="`" + username + " not found`") result = await request.json() url = result.get("html_url", None) name = result.get("name", None) company = result.get("company", None) bio = result.get("bio", None) created_at = result.get("created_at", "Not Found") repo_url = f"https://github.com/{username}?tab=repositories" REPLY = ( "**GitHub Info for {}**" "\n**Username:** `{}`\n**Bio:** `{}`\n**Profile:** [Link]({})" "\n**Company:** `{}`\n**Created at:** `{}`" "\n**Repository:** [Link]({})").format(name, username, bio, url, company, created_at, repo_url) url = f"https://ghchart.rshah.org/{username}" file_name = f"{randint(1, 999)}{username}" resp = await AioHttp.get_raw(url) f = await aiofiles.open(f"{file_name}.svg", mode="wb") await f.write(resp) await f.close() try: drawing = svg2rlg(f"{file_name}.svg") renderPM.drawToFile(drawing, f"{file_name}.png") except UnboundLocalError: await edit_or_reply(message, text="Username does not exist!") await sleep(2) await message.delete() return await asyncio.gather( client.send_photo( chat_id=message.chat.id, photo=f"{file_name}.png", caption=REPLY, reply_to_message_id=ReplyCheck(message), )) for file in iglob(f"{file_name}.*"): os.remove(file)
async def spam(client, message): await message.delete() times = message.command[1] to_spam = " ".join(message.command[2:]) if message.chat.type in ["supergroup", "group"]: for _ in range(int(times)): await client.send_message(message.chat.id, to_spam, reply_to_message_id=ReplyCheck(message)) await asyncio.sleep(0.20) if message.chat.type == "private": for _ in range(int(times)): await client.send_message(message.chat.id, to_spam) await asyncio.sleep(0.20)
async def anime_search(client, message): cmd = message.command mock = "" if len(cmd) > 1: mock = " ".join(cmd[1:]) elif len(cmd) == 1: await edit_or_reply(message, text="`Format: anime <anime name>`") await asyncio.sleep(2) await message.delete() return x = await client.get_inline_bot_results(f"{BotUsername}", f"anime {mock}") await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def mock_spongebob(client, message): cmd = message.command mock = '' if len(cmd) > 1: mock = ' '.join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: mock = message.reply_to_message.text elif len(cmd) == 1: await edit_or_reply(message, text="`Can't mock the void.`") await asyncio.sleep(2) await message.delete() return x = await client.get_inline_bot_results('Stickerizerbot', f'#7{mock}') await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def google_search(client, message): cmd = message.command googles = "" if len(cmd) > 1: googles = " ".join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: googles = message.reply_to_message.text elif len(cmd) == 1: await edit_or_reply( message, text="`No text Given hence can not google the void.`") await asyncio.sleep(2) await message.delete() return x = await client.get_inline_bot_results("Stickerizerbot", f"#12{googles}") await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def remove_bg(client, message): if not REMOVE_BG_API: await edit_or_reply( message, text='Invalid API', disable_web_page_preview=True, parse_mode='html', ) replied = message.reply_to_message if (replied and replied.media and (replied.photo or (replied.document and 'image' in replied.document.mime_type))): if os.path.exists(IMG_PATH): os.remove(IMG_PATH) await client.download_media(message=replied, file_name=IMG_PATH) try: rmbg = RemoveBg(REMOVE_BG_API, 'rm_bg_error.txt') rmbg.remove_background_from_img_file(IMG_PATH) remove_img = IMG_PATH + '_no_bg.png' await client.send_document( chat_id=message.chat.id, document=remove_img, reply_to_message_id=ReplyCheck(message), disable_notification=True, ) await message.delete() os.remove(remove_img) os.remove(IMG_PATH) except Exception as e: print(e) await edit_or_reply(message, text='`Something went wrong!`') await sleep(3) await message.delete() else: await edit_or_reply( message, text='Usage: reply to a photo to remove background!', )
async def waifu_sticker(client, message): cmd = message.command waifu = "" if len(cmd) > 1: waifu = " ".join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: waifu = message.reply_to_message.text elif len(cmd) == 1: await edit_or_reply(message, text="`No text Given hence the waifu Ran Away.`") await asyncio.sleep(2) await message.delete() return x = await client.get_inline_bot_results( "Stickerizerbot", f"#{random.choice(waifus)}{waifu}") await message.delete() await client.send_inline_bot_result( chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=True, )
async def get_note(client, message): if not DB_AVAILABLE: await message.edit("Your database is not avaiable!") return if len(message.text.split()) >= 2: note = message.text.split()[1] else: await message.edit("Give me a note tag!") getnotes = db.get_selfnote(message.from_user.id, note) if not getnotes: await message.edit("This note does not exist!") return if getnotes["type"] == Types.TEXT: teks, button = parse_button(getnotes.get("value")) button = build_keyboard(button) button = InlineKeyboardMarkup(button) if button else None if button: try: inlineresult = await app.get_inline_bot_results( f"@{BotUsername}", f"note {note}" ) except errors.exceptions.bad_request_400.BotInlineDisabled: await message.edit( "Your bot inline isn't available!" "Check your bot for more information!" ) await setbot.send_message( Owner, "Hello, your notes is look like include button," "but i can't do that " "because **inline mode** is not enabled.", ) return try: await message.delete() await client.send_inline_bot_result( message.chat.id, inlineresult.query_id, inlineresult.results[0].id, reply_to_message_id=ReplyCheck(message), ) except IndexError: await message.edit( "An error has accured!" "Check your assistant for more information!" ) return else: await message.edit(teks) elif getnotes["type"] in ( Types.STICKER, Types.VOICE, Types.VIDEO_NOTE, Types.CONTACT, Types.ANIMATED_STICKER, ): await GET_FORMAT[getnotes["type"]]( message.chat.id, getnotes["file"], reply_to_message_id=ReplyCheck(message) ) else: if getnotes.get("value"): teks, button = parse_button(getnotes.get("value")) button = build_keyboard(button) button = InlineKeyboardMarkup(button) if button else None else: teks = None button = None if button: try: inlineresult = await app.get_inline_bot_results( f"@{BotUsername}", f"note {note}" ) except errors.exceptions.bad_request_400.BotInlineDisabled: await message.edit( "Your bot inline isn't available!\n" "Check your bot for more information!" ) await setbot.send_message( Owner, "Hello, your notes is look like include button," "but i can't do that because " "**inline mode** is not enabled." ) return try: await message.delete() await client.send_inline_bot_result( message.chat.id, inlineresult.query_id, inlineresult.results[0].id, reply_to_message_id=ReplyCheck(message), ) except IndexError: message.edit( "An error has accured!" ) return else: await GET_FORMAT[getnotes["type"]]( message.chat.id, getnotes["file"], caption=teks, reply_to_message_id=ReplyCheck(message), )
async def tracemoe_rs(client, message): dis_loc = "" if message.reply_to_message: message_ = message.reply_to_message if message_.sticker and message_.sticker.file_name.endswith(".tgs"): await message.delete() return if ( message_.photo or message_.animation or message_.sticker ): dis = await client.download_media( message=message_, file_name=screen_shot ) dis_loc = os.path.join(screen_shot, os.path.basename(dis)) if message_.animation: await edit_or_reply(message, text="`Converting this Gif`") img_file = os.path.join(screen_shot, "grs.jpg") await take_screen_shot(dis_loc, 0, img_file) if not os.path.lexists(img_file): await edit_or_reply( message, text="`Something went wrong in Conversion`" ) await asyncio.sleep(5) await message.delete() return dis_loc = img_file if message_.video: nama = "video_{}-{}.mp4".format( message.reply_to_message.video.date, message.reply_to_message.video.file_size, ) await client.download_media( message.reply_to_message.video, file_name="nana/downloads/" + nama ) dis_loc = "nana/downloads/" + nama img_file = os.path.join(screen_shot, "grs.jpg") await take_screen_shot(dis_loc, 0, img_file) if not os.path.lexists(img_file): await edit_or_reply( message, text="`Something went wrong in Conversion`" ) await asyncio.sleep(5) await message.delete() return if dis_loc: tracemoe = tracemoepy.async_trace.Async_Trace() if message_.video: search = await tracemoe.search(img_file, upload_file=True) os.remove(img_file) else: search = await tracemoe.search(dis_loc, upload_file=True) os.remove(dis_loc) result = search["docs"][0] ms_g = ( f"**Title**: {result['title_english']}" f"\n**Similarity**: {result['similarity']*100}" f"\n**Episode**: {result['episode']}" ) preview = await tracemoe.natural_preview(search) with open("preview.mp4", "wb") as f: f.write(preview) await message.delete() await client.send_video( message.chat.id, "preview.mp4", caption=ms_g, reply_to_message_id=ReplyCheck(message), ) await asyncio.sleep(5) await message.delete() os.remove("preview.mp4") else: await message.delete() return else: await edit_or_reply(message, text="`Reply to a message to proceed`") await asyncio.sleep(5) await message.delete() return
async def tracemoe_rs(client, message): dis_loc = '' if message.reply_to_message: message_ = message.reply_to_message if message_.sticker and message_.sticker.file_name.endswith('.tgs'): await message.delete() return if (message_.photo or message_.animation or message_.sticker): dis = await client.download_media( message=message_, file_name=screen_shot, ) dis_loc = os.path.join(screen_shot, os.path.basename(dis)) if message_.animation: await edit_or_reply(message, text='`Converting this Gif`') img_file = os.path.join(screen_shot, 'grs.jpg') await take_screen_shot(dis_loc, 0, img_file) if not os.path.lexists(img_file): await edit_or_reply( message, text='`Something went wrong in Conversion`', ) await asyncio.sleep(5) await message.delete() return dis_loc = img_file if message_.video: nama = 'video_{}-{}.mp4'.format( message.reply_to_message.video.date, message.reply_to_message.video.file_size, ) await client.download_media( message.reply_to_message.video, file_name='nana/downloads/' + nama, ) dis_loc = 'nana/downloads/' + nama img_file = os.path.join(screen_shot, 'grs.jpg') await take_screen_shot(dis_loc, 0, img_file) if not os.path.lexists(img_file): await edit_or_reply( message, text='`Something went wrong in Conversion`', ) await asyncio.sleep(5) await message.delete() return session = aiohttp.ClientSession() tracemoe = tracemoepy.AsyncTrace(session=session) if message_.video: search = await tracemoe.search(img_file, upload_file=True) os.remove(img_file) else: search = await tracemoe.search(dis_loc, upload_file=True) os.remove(dis_loc) result = search['docs'][0] ms_g = (f"**Title**: {result['title_english']}" f"\n**Similarity**: {result['similarity']*100}" f"\n**Episode**: {result['episode']}") preview = await tracemoe.natural_preview(search) with open('preview.mp4', 'wb') as f: f.write(preview) await message.delete() await client.send_video( message.chat.id, 'preview.mp4', caption=ms_g, reply_to_message_id=ReplyCheck(message), ) await asyncio.gather( tracemoe.aio_session.close(), asyncio.sleep(5), message.delete(), ) os.remove('preview.mp4') else: await edit_or_reply(message, text='`Reply to a message to proceed`') await asyncio.sleep(5) await message.delete() return
async def get_note(client, message): if not DB_AVAILABLE: await message.edit("You haven't set up a database!") return if len(message.text.split()) >= 2: note = message.text.split()[1] else: await message.edit('Give me a note tag!') getnotes = db.get_selfnote(message.from_user.id, note) if not getnotes: await message.edit('This note does not exist!') return if getnotes['type'] == Types.TEXT: teks, button = parse_button(getnotes.get('value')) button = build_keyboard(button) button = InlineKeyboardMarkup(button) if button else None if button: try: inlineresult = await app.get_inline_bot_results( f'@{BotUsername}', f'note {note}', ) except errors.exceptions.bad_request_400.BotInlineDisabled: await message.edit( "Your haven't enabled inline for yout bot!", ) await setbot.send_message( Owner, 'Hello, looks like a note of yours include a button,' "but I can't display it " 'because **inline mode** is not enabled in @BotFather.', ) return try: await message.delete() await client.send_inline_bot_result( message.chat.id, inlineresult.query_id, inlineresult.results[0].id, reply_to_message_id=ReplyCheck(message), ) except IndexError: await message.edit( 'An error occured!' 'Check your assistant for more information!', ) return else: await message.edit(teks) elif getnotes['type'] in ( Types.STICKER, Types.VOICE, Types.VIDEO_NOTE, Types.CONTACT, Types.ANIMATED_STICKER, ): await message.delete() await GET_FORMAT[getnotes['type']]( message.chat.id, getnotes['file'], reply_to_message_id=ReplyCheck(message), ) else: if getnotes.get('value'): teks, button = parse_button(getnotes.get('value')) button = build_keyboard(button) button = InlineKeyboardMarkup(button) if button else None else: teks = None button = None if button: try: inlineresult = await app.get_inline_bot_results( f'@{BotUsername}', f'note {note}', ) except errors.exceptions.bad_request_400.BotInlineDisabled: await message.edit( "Your haven't enabled inline for yout bot!", ) await setbot.send_message( Owner, 'Hello, looks like a note of yours include a button,' "but I can't display it " 'because **inline mode** is not enabled in @BotFather.', ) return try: await message.delete() await client.send_inline_bot_result( message.chat.id, inlineresult.query_id, inlineresult.results[0].id, reply_to_message_id=ReplyCheck(message), ) except IndexError: message.edit('An error occured!', ) return else: await GET_FORMAT[getnotes['type']]( message.chat.id, getnotes['file'], caption=teks, reply_to_message_id=ReplyCheck(message), )