async def paste(_, message): if message.reply_to_message: app.set_parse_mode("markdown") if message.reply_to_message.text: m = await message.reply_text("```Pasting To Nekobin...```") message_get = message.reply_to_message.text message_as_str = str(message_get) paste_link = await nekobin.neko(message_as_str) final_link = f"[Nekobin]({paste_link})" await m.edit(final_link, disable_web_page_preview=True) elif message.reply_to_message.document: if message.reply_to_message.document.file_size > 300000: await message.reply_text( "You can only paste files smaller than 300KB.") return m = await message.reply_text("```Pasting To Nekobin...```") await message.reply_to_message.download(file_name='paste.txt') i = open("downloads/paste.txt", "r") paste_link = await nekobin.neko(i.read()) os.remove('downloads/paste.txt') final_link = f"[Nekobin]({paste_link})" await m.edit(final_link, disable_web_page_preview=True) else: await message.reply_text("Reply To A Message With /paste")
async def paste_func(_, message): if message.reply_to_message: app.set_parse_mode("markdown") if message.reply_to_message.text: m = await message.reply_text("Pasting...") content = str(message.reply_to_message.text) link = await paste(content) await m.delete() await app.send_photo(message.chat.id, photo=link + "/preview.png", caption=link) elif message.reply_to_message.document: if message.reply_to_message.document.file_size > 1048576: await message.reply_text( "You can only paste files smaller than 1MB.") return m = await message.reply_text("Pasting...") doc_file = await message.reply_to_message.download( file_name='paste.txt') i = open(doc_file, "r") link = await paste(i.read()) await m.delete() await app.send_photo(message.chat.id, photo=link + "/preview.png", caption=link) os.remove(doc_file) else: await message.reply_text("Reply To A Message With /paste")
async def repo(client, message): app.set_parse_mode("markdown") profile_url = [] username = [] # Get The List Of Usernames And Profile Url for item in requests.get(api).json(): profile_url.append(f"{item['author']['html_url']}") username.append(f"{item['author']['login']}") # Join Usernames And Profile Url For Markdown no_of_contributors = len(username) i = 0 n = 1 contributors = "" while i < no_of_contributors: contributors += f"[{n}. {username[i]}]({profile_url[i]})\n" n += 1 i += 1 await message.reply_text(f''' ```Devs and Contributors``` {contributors} ```Source Code```[Github](https://github.com/thehamkercat/WilliamButcherBot) ''', disable_web_page_preview=True)
async def ping(client, message): app.set_parse_mode("markdown") m = await message.reply_text("```Wait, Pinging all Datacenters```") result = "" for i in range(1, 6): dc = (f"https://cdn{i}.telesco.pe") ping1 = round(requests.head(dc).elapsed.total_seconds() * 1000) result += f'```DC{i} - {ping1}ms```' await m.edit(result)
async def speeeed(client, message): app.set_parse_mode("markdown") m = await message.reply_text("```Performing A Speedtest!```") speed = speedtest.Speedtest() x = speed.get_best_server() y = speed.download() z = speed.upload() await m.edit(f''' ```Download - {speed_convert(y)} Upload - {speed_convert(z)} Latency - {round((x["latency"]))} ms ```''')
async def reddit(_, message: Message): app.set_parse_mode("html") if len(message.command) != 2: await message.reply_text("/reddit needs an argument") subreddit = message.command[1] res = r.get(f"https://meme-api.herokuapp.com/gimme/{subreddit}") res = res.json() rpage = res.get(str("subreddit")) # Subreddit title = res.get(str("title")) # Post title memeu = res.get(str("url")) # meme pic url plink = res.get(str("postLink")) caps = f"<b>Title</b>: {title}\n" caps += f"<b>Subreddit: </b>r/{rpage}\n" caps += f"<b>PostLink:</b> {plink}" await message.reply_photo(photo=memeu, caption=(caps))
async def paste_func(_, message): if message.reply_to_message: app.set_parse_mode("markdown") if message.reply_to_message.text: m = await message.reply_text("Pasting...") content = str(message.reply_to_message.text) link = await paste(content) preview = link + "/preview.png" status_code = await get_http_status_code(preview) i = 0 while status_code != 200: if i == 5: break status_code = await get_http_status_code(preview) await asyncio.sleep(0.2) i += 1 await m.delete() await app.send_photo(message.chat.id, photo=preview, caption=link) elif message.reply_to_message.document: if message.reply_to_message.document.file_size > 1048576: await message.reply_text( "You can only paste files smaller than 1MB." ) return m = await message.reply_text("Pasting...") doc_file = await message.reply_to_message.download( file_name="paste.txt" ) i = open(doc_file, "r") link = await paste(i.read()) preview = link + "/preview.png" status_code = await get_http_status_code(preview) i = 0 while status_code != 200: if i == 5: break status_code = await get_http_status_code(preview) await asyncio.sleep(0.2) i += 1 await m.delete() await app.send_photo(message.chat.id, photo=preview, caption=link) os.remove(doc_file) else: await message.reply_text("Reply To A Message With /paste")
async def callback_query_forward_rice(_, callback_query): app.set_parse_mode("markdown") u_approver = callback_query.from_user c_group = callback_query.message.chat approver_status = (await c_group.get_member(u_approver.id)).status if not (approver_status in ("creator", "administrator")): await callback_query.answer("Only admin can approve this!") return await callback_query.answer("Successfully approved") m_op = callback_query.message.reply_to_message u_op = m_op.from_user arg_caption = f"{m_op.caption}\nOP: [{u_op.first_name}]({m_op.link})" if m_op.media_group_id: message_id = m_op.message_id media_group = await app.get_media_group(RICE_GROUP, message_id) arg_media = [] for m in media_group: if m.photo and m.caption: arg_media.append( InputMediaPhoto(m.photo.file_id, caption=arg_caption) ) elif m.photo: arg_media.append(InputMediaPhoto(m.photo.file_id)) elif m.video and m.caption: arg_media.append( InputMediaVideo(m.video.file_id, caption=arg_caption) ) elif m.video: arg_media.append(InputMediaVideo(m.video.file_id)) m_cp = await app.send_media_group(RICE_CHANNEL, arg_media) link = m_cp[0].link else: m_cp = await m_op.copy(RICE_CHANNEL, caption=arg_caption) link = m_cp.link await callback_query.message.delete() reply_text = ( f"**OP**: {u_op.mention()}\n" f"**Approver**: {u_approver.mention()}\n" f"**Forwarded**: [Rice Gallery]({link})" ) await m_op.reply_text(reply_text, disable_web_page_preview=True)
async def paste(_, message: Message): if bool(message.reply_to_message) is True: app.set_parse_mode("markdown") if bool(message.reply_to_message.text) is True: m = await message.reply_text("```Pasting To Nekobin...```") message_get = message.reply_to_message.text message_as_str = str(message_get) paste_link = await nekobin.neko(message_as_str) final_link = f"[Nekobin]({paste_link})" await m.edit(final_link, disable_web_page_preview=True) elif bool(message.reply_to_message.document) is True: m = await message.reply_text("```Pasting To Nekobin...```") await message.reply_to_message.download(file_name='paste.txt') i = open("downloads/paste.txt", "r") paste_link = await nekobin.neko(i.read()) os.remove('downloads/paste.txt') final_link = f"[Nekobin]({paste_link})" await m.edit(final_link, disable_web_page_preview=True) elif bool(message.reply_to_message) is False: await message.reply_text( "Reply To A Message With /paste, Just Hitting /paste " + "Won't Do Anything Other Than Proving Everyone That " + "You Are A Spammer Who Is Obsessed To 'BlueTextMustClickofobia")
async def purge(client, message): app.set_parse_mode("markdown") if message.chat.type not in (("supergroup", "channel")): return admin = await is_admin(message) if not admin: return message_ids = [] if message.reply_to_message: for a_s_message_id in range( message.reply_to_message.message_id, message.message_id ): message_ids.append(a_s_message_id) if len(message_ids) == 100: await client.delete_messages( chat_id=message.chat.id, message_ids=message_ids, revoke=True ) message_ids = [] if len(message_ids) > 0: await client.delete_messages( chat_id=message.chat.id, message_ids=message_ids, revoke=True ) m = await message.reply_text( "```Purged!```" ) await asyncio.sleep(2) await m.delete()