async def _(tosh): if tosh.fwd_from: return ice = await eor(tosh, "** ⪼ جاري المعالجه ༗...**") if not os.path.isdir(Config.TEMP_DIR): os.makedirs(Config.TEMP_DIR) # if BOTLOG: await tosh.client.send_message( BOTLOG_CHATID, "**⌔∮ تم إنشاء حساب Telegraph جديد {} للدورة الحالية** \n**⌔∮ لا تعطي عنوان url هذا لأي شخص**".format( auth_url ), ) optional_title = tosh.pattern_match.group(2) if tosh.reply_to_msg_id: start = datetime.now() r_message = await tosh.get_reply_message() input_str = tosh.pattern_match.group(1) if input_str in ["ميديا", "m"]: downloaded_file_name = await tosh.client.download_media( r_message, Config.TEMP_DIR ) end = datetime.now() ms = (end - start).seconds await ice.edit( f"** ⪼ تم تحميل {downloaded_file_name} في وقت {ms} ثانيه.**" ) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await ice.edit("**⌔∮ خطا : **" + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await ice.edit( "**⌔∮ الرابط : **[اضغط هنا](https://telegra.ph{})\ \n**⌔∮ الوقت : **`{} ثانيه.` \n**⌔∮ تم التحميل بواسطه :** {}".format( media_urls[0], (ms + ms_two), (mention) ), link_preview=True, ) elif input_str in ["نص", "t"]: user_object = await tosh.client.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await tosh.client.download_media( r_message, Config.TEMP_DIR ) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds kimo = f"https://telegra.ph/{response['path']}" await ice.edit( f"**الرابط : ** [اضغط هنا]({kimo})\ \n**الوقت : **`{ms} ثانيه.`", link_preview=True, ) else: await ice.edit( "قم بالرد على رسالة للحصول على رابط تللكراف دائم.", )
async def whatanime(event): "Reverse search of anime." reply = await event.get_reply_message() if not reply: return await edit_delete( event, "__reply to media to reverse search that anime__.") mediatype = media_type(reply) if mediatype not in ["Photo", "Video", "Gif", "Sticker"]: return await edit_delete( event, f"__Reply to proper media that is expecting photo/video/gif/sticker. not {mediatype}__.", ) output = await _cattools.media_to_pic(event, reply) if output[1] is None: return await edit_delete( output[0], "__Unable to extract image from the replied message.__") file = memory_file("anime.jpg", output[1]) try: response = upload_file(file) except exceptions.TelegraphException as exc: try: response = upload_file(output[1]) except exceptions.TelegraphException as exc: return await edit_delete(output[0], f"**Error :**\n__{str(exc)}__") cat = f"https://telegra.ph{response[0]}" await output[0].edit("`Searching for result..`") async with aiohttp.ClientSession() as session: async with session.post( f"https://api.trace.moe/search?anilistInfo&url={quote_plus(cat)}" ) as raw_resp0: resp0 = await raw_resp0.json() framecount = resp0["frameCount"] error = resp0["error"] if error != "": return await edit_delete(output[0], f"**Error:**\n__{error}__") js0 = resp0["result"] if not js0: return await output[0].edit("`No results found.`") js0 = js0[0] text = ( f'**Titile Romaji : **`{html.escape(js0["anilist"]["title"]["romaji"])}`\n' ) text += ( f'**Titile Native :** `{html.escape(js0["anilist"]["title"]["native"])}`\n' ) text += ( f'**Titile English :** `{html.escape(js0["anilist"]["title"]["english"])}`\n' if js0["anilist"]["title"]["english"] is not None else "") text += f'**Is Adult :** __{js0["anilist"]["isAdult"]}__\n' # text += f'**File name :** __{js0["filename"]}__\n' text += f'**Episode :** __{html.escape(str(js0["episode"]))}__\n' text += f'**From :** __{readable_time(js0["from"])}__\n' text += f'**To :** __{readable_time(js0["to"])}__\n' percent = round(js0["similarity"] * 100, 2) text += f"**Similarity :** __{percent}%__\n" result = ( f"**Searched {framecount} frames and found this as best result :**\n\n" + text) msg = await output[0].edit(result) try: await msg.reply( f'{readable_time(js0["from"])} - {readable_time(js0["to"])}', file=js0["video"], ) except Exception: await msg.reply( f'{readable_time(js0["from"])} - {readable_time(js0["to"])}', file=js0["image"], )
async def telegraphs(graph): """For telegraph command, upload media & text to telegraph site.""" xxnx = await edit_or_reply(graph, "`Processing...`") if not graph.text[0].isalpha() and graph.text[0] not in ("/", "#", "@", "!"): if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "m": downloaded_file_name = await graph.client.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await xxnx.edit( f"**Di Download Ke** `{downloaded_file_name}` **di** `{ms}` **detik.**" ) if downloaded_file_name.endswith(".webp"): resize_image(downloaded_file_name) try: media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await xxnx.edit("**ERROR:** " + str(exc)) os.remove(downloaded_file_name) else: os.remove(downloaded_file_name) await xxnx.edit( f"**Berhasil diupload ke** [telegra.ph](https://telegra.ph{media_urls[0]})", link_preview=True, ) elif input_str == "t": user_object = await graph.client.get_entity(r_message.sender_id ) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await graph.client.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) await xxnx.edit( f'**Berhasil diupload ke** [telegra.ph](https://telegra.ph/{response["path"]})', link_preview=True, ) else: await edit_delete( xxnx, "**Mohon Balas Ke Pesan, Untuk Mendapatkan Link Telegraph Permanen.**", )
async def _(event): if event.fwd_from: return if Config.PLUGIN_CHANNEL is None: await event.edit( "Please set the required environment variable `PLUGIN_CHANNEL` for this plugin to work" ) return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) await borg.send_message( Config.PLUGIN_CHANNEL, "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**" .format(auth_url), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "m": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await event.edit("Downloaded to {} in {} seconds.".format( downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await event.edit( "Your Telegraph Link by 𝐒𝐀𝐕𝐀𝐆𝐄 𝐁𝐎𝐓 https://telegra.ph{} ". format(media_urls[0], (ms + ms_two)), link_preview=True, ) elif input_str == "t": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.edit( "Pasted ser https://telegra.ph/{} in {} seconds.".format( response["path"], ms), link_preview=True, ) else: await event.edit( "Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)" )
async def _(event): if event.fwd_from: return catevent = await edit_or_reply(event, "`جاࢪي الـتحويـل ...`") if not os.path.isdir(Config.TEMP_DIR): os.makedirs(Config.TEMP_DIR) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "تـم صنع تيلجࢪاف الخـاص بڪ {} للࢪابط الحـالي.".format(auth_url), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str in ["media", "m"]: downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) end = datetime.now() ms = (end - start).seconds await catevent.edit( f"`تم التنࢪ࣪يل إلۍ {downloaded_file_name} فـي {ms} ثـۉانيہ.`") if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await catevent.edit("**Error : **" + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await catevent.edit( "**الـرابط : **[telegraph](https://telegra.ph{})\ \n**الوقت المستغرق : **`{} ثـانية.`".format( media_urls[0], (ms + ms_two)), link_preview=True, ) elif input_str in ["text", "t"]: user_object = await event.client.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds cat = f"https://telegra.ph/{response['path']}" await catevent.edit( f"**link : ** [telegraph]({cat})\ \n**الوقت المستغرق : **`{ms} ثـانية.`", link_preview=True, ) else: await catevent.edit( "`Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)`", )
async def telegraphs(graph): await graph.edit("`Sedang Memproses... Sabar ya bentar juga muncul😁`") if not graph.text[0].isalpha() and graph.text[0] not in ( "/", "#", "@", "!"): if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "m": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY ) end = datetime.now() ms = (end - start).seconds await graph.edit( "Di Download Ke {} Dalam {} Detik.".format(downloaded_file_name, ms) ) try: if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) except AttributeError: return await graph.edit("`Tidak Ada Media Yang Disediakan`") try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await graph.edit( "Berhasil Mengunggah Ke [Telegraph](https://telegra.ph{}).".format( media_urls[0], (ms + ms_two) ), link_preview=True, ) elif input_str == "t": user_object = await bot.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY ) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page( title_of_page, html_content=page_content ) end = datetime.now() ms = (end - start).seconds await graph.edit( "Berhasil Mengunggah Ke [Telegraph](https://telegra.ph/{}).".format( response["path"], ms ), link_preview=True, ) else: await graph.edit("`Mohon Balas Ke Pesan, Untuk Mendapatkan Link Telegraph Permanen.`")
async def _(event): "To get telegraph link." catevent = await edit_or_reply(event, "`processing........`") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, f"Created New Telegraph account {auth_url} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**", ) optional_title = event.pattern_match.group(5) if not event.reply_to_msg_id: return await catevent.edit( "`Reply to a message to get a permanent telegra.ph link.`", ) start = datetime.now() r_message = await event.get_reply_message() input_str = (event.pattern_match.group(4)).strip() if input_str in ["media", "m"]: downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) await catevent.edit(f"`Downloaded to {downloaded_file_name}`") if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await catevent.edit(f"**Error : **\n`{str(exc)}`") os.remove(downloaded_file_name) else: end = datetime.now() ms = (end - start).seconds os.remove(downloaded_file_name) await catevent.edit( f"**link : **[telegraph](https://telegra.ph{media_urls[0]})\ \n**Time Taken : **`{ms} seconds.`", link_preview=True, ) elif input_str in ["text", "t"]: user_object = await event.client.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds cat = f"https://telegra.ph/{response['path']}" await catevent.edit( f"**link : ** [telegraph]({cat})\ \n**Time Taken : **`{ms} seconds.`", link_preview=True, )
async def _(event): if event.fwd_from: return catevent = await edit_or_reply(event, "`processing........`") if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) if BOTLOG: await borg.send_message( BOTLOG_CHATID, "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**" .format(auth_url), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await catevent.edit( "Downloaded to {} in {} seconds.".format( downloaded_file_name, ms), ) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await catevent.edit("**Error : **" + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await catevent.edit( "**link : **[telegraph](https://telegra.ph{})\ \n**Time Taken : **`{} seconds.`".format( media_urls[0], (ms + ms_two)), link_preview=True, ) elif input_str == "text": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds cat = f"https://telegra.ph/{response['path']}" await catevent.edit( f"**link : ** [telegraph]({cat})\ \n**Time Taken : **`{ms} seconds.`", link_preview=True, ) else: await catevent.edit( "`Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)`", )
async def _(event): if event.fwd_from: return if Config.PRIVATE_GROUP_BOT_API_ID is None: await event.edit( "Please set the required environment variable `PRIVATE_GROUP_BOT_API_ID` for this plugin to work" ) return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) await borg.send_message( Config.PRIVATE_GROUP_BOT_API_ID, "Creato un nuovo Telegraph account {} per la seguente sessione. \n**Non dare questo URL a nessuno**" .format(auth_url)) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await event.edit("Scaricato come {} in {} secondi.".format( downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await event.edit( "Caricato su https://telegra.ph{} in {} secondi.".format( media_urls[0], (ms + ms_two)), link_preview=True) elif input_str == "text": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.edit( "Copiato su https://telegra.ph/{} in {} secondi.".format( response["path"], ms), link_preview=True) else: await event.edit( "Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)" )
async def telegraphs(graph): await graph.edit("`Hazırlanır...`") if not graph.text[0].isalpha() and graph.text[0] not in ("/", "#", "@", "!"): if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "m": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await graph.edit("{} saniyə içində {} yükləndi.".format( downloaded_file_name, ms)) try: if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) except AttributeError: return await graph.edit("`Media təmin edilmir`") try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await graph.edit( "Uğurla yükləndi! Link: [telegra.ph](https://telegra.ph{})." .format(media_urls[0], (ms + ms_two)), link_preview=True, ) elif input_str == "t": user_object = await bot.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # göründüyü kimi, bütün istifadəçilərin soyadı adı yoxdur page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await graph.edit( "Uğurla yükləndi! Link: [telegra.ph](https://telegra.ph/{})." .format(response["path"], ms), link_preview=True, ) else: await graph.edit( "`Qalıcı bir telegra.ph bağlantısı almaq üçün mesaja cavab verin.`" )
async def _(event): if event.fwd_from: return if Config.PLUGIN_CHANNEL is None: await event.edit( "Please set the required environment variable `PLUGIN_CHANNEL` for this plugin to work" ) return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await event.edit("Downloaded to {} in {} seconds.".format( downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await event.edit( "Successfully Uploaded to This [Telegraph Page](https://telegra.ph{})" .format(media_urls[0], (ms + ms_two)), link_preview=False) elif input_str == "text": user_object = await borg.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.edit( "Pasted successfully https://telegra.ph/{} in {} seconds.". format(response["path"], ms), link_preview=False) else: await event.edit( "Reply to a message to get a permanent telegra.ph link.")
async def _(event): if event.fwd_from: return catevent = await edit_or_reply(event, "`procesando........`") if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) if BOTLOG: await borg.send_message( BOTLOG_CHATID, "Se creó una nueva cuenta de Telegraph {} para la sesión actual. \n**No le dé esta URL a nadie, ¡incluso si dice que es de Telegram!**".format( auth_url ), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY ) end = datetime.now() ms = (end - start).seconds await catevent.edit( "Descargado a {} en {} segundos.".format(downloaded_file_name, ms), ) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await catevent.edit("**Error : **" + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds media_urls = upload_file(downloaded_file_name) jisan = "https://telegra.ph{}".format(media_urls[0]) os.remove(downloaded_file_name) await catevent.edit( f"**__➥ Subido a :-__ [Telegraph]**({jisan})\ \n__**➥ Subido en {ms + ms_two} segundos .**__\n__**➥ Subido por :-**__ [{DEFAULTUSER}]({USERNAME})", link_preview=True, ) elif input_str == "text": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY ) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds cat = f"https://telegra.ph/{response['path']}" await catevent.edit( f"**__➥ Pegado a :-__ [Telegraph]**({cat})\ \n__**➥ Pegado en {ms} segundos .**__", link_preview=True, ) else: await catevent.edit( "`Responde a un mensaje para obtener un enlace telegra.ph permanente. (Inspired by @DKzippO)`", )
async def shinchanbot(shinchanmemes): input_str = shinchanmemes.pattern_match.group(1) input_str = deEmojify(input_str) if "-" in input_str: username, text = input_str.split("-") else: await edit_or_reply( shinchanmemes, "**Command :** reply to image or sticker with `.phc (username)-(text in comment)`", ) return replied = await shinchanmemes.get_reply_message() if not os.path.isdir("./temp/"): os.makedirs("./temp/") if not replied: await edit_or_reply( shinchanmemes, "Media file not supported. Reply to a suported media") return if replied.media: shinchanmemmes = await edit_or_reply(shinchanmemes, "`Making A Comment`.") else: await edit_or_reply( shinchanmemes, "Media file not supported. Reply to a suported media") return try: shinchan = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") shinchan = Get(shinchan) await shinchanmemes.client(shinchan) except BaseException: pass download_location = await shinchanmemes.client.download_media( replied, "./temp/") if download_location.endswith((".webp")): download_location = convert_toimage(download_location) size = os.stat(download_location).st_size if download_location.endswith((".jpg", ".jpeg", ".png", ".bmp", ".ico")): if size > 5242880: await shinchanmemmes.edit( "the replied file size is not supported it must me below 5 mb") os.remove(download_location) return await shinchanmemmes.edit("Commented....") else: await shinchanmemmes.edit( "Media file not supported. Reply to a suported media") os.remove(download_location) return try: response = upload_file(download_location) os.remove(download_location) except exceptions.TelegraphException as exc: await shinchanmemmes.edit("ERROR: " + str(exc)) os.remove(download_location) return shinchan = f"https://telegra.ph{response[0]}" shinchan = await phcomment(shinchan, text, username) await shinchanmemmes.delete() await shinchanmemes.client.send_file(shinchanmemes.chat_id, shinchan, reply_to=replied)
async def getmedia(bot, update): if Config.UPDATE_CHANNEL: try: user = await bot.get_chat_member(Config.UPDATE_CHANNEL, update.chat.id) if user.status == "kicked": await update.reply_text(text=Translation.BANNED_USER_TEXT) return except UserNotParticipant: await update.reply_text( text=Translation.FORCE_SUBSCRIBE_TEXT, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="😎 Join Channel 😎", url=f"https://telegram.me/{Config.UPDATE_CHANNEL}") ]])) return except Exception: await update.reply_text(text=Translation.SOMETHING_WRONG, disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "❔ More Help ❔", callback_data="help") ]])) return if update.from_user.id not in Config.AUTH_USERS: if str(update.from_user.id) in Config.ADL_BOT_RQ: current_time = time.time() previous_time = Config.ADL_BOT_RQ[str(update.from_user.id)] process_max_timeout = round(Config.PROCESS_MAX_TIMEOUT / 60) present_time = round(Config.PROCESS_MAX_TIMEOUT - (current_time - previous_time)) Config.ADL_BOT_RQ[str(update.from_user.id)] = time.time() if round(current_time - previous_time) < Config.PROCESS_MAX_TIMEOUT: await bot.send_message( text=Translation.FREE_USER_LIMIT_Q_SZE.format( process_max_timeout, present_time), quote=True) return else: Config.ADL_BOT_RQ[str(update.from_user.id)] = time.time() media = update.document or update.video or update.video_note medianame = "./DOWNLOADS/" + "cybersecurityhacker/CyTelegraphBot" dwn = await bot.send_message(chat_id=update.chat.id, text=Translation.DOWNLOAD_TEXT, parse_mode="html", disable_web_page_preview=True, reply_to_message_id=update.message_id) await bot.download_media(message=update, file_name=medianame) await dwn.edit_text(text=Translation.UPLOADING_TEXT) try: response = upload_file(medianame) except Exception as error: await dwn.edit_text(text=Translation.SOMETHING_WRONG, disable_web_page_preview=True) return await dwn.edit_text( text= f"<b>Link :-</b> <code>https://telegra.ph{response[0]}</code>\n\n<b>Join :-</b> @cybersecurityhacker", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton(text="Open Link", url=f"https://telegra.ph{response[0]}"), InlineKeyboardButton( text="Share Link", url= f"https://telegram.me/share/url?url=https://telegra.ph{response[0]}" ), ], [ InlineKeyboardButton( text="⚙ Join Updates Channel ⚙", url="https://telegram.me/cybersecurityhacker") ]])) try: os.remove(medianame) except: pass
async def telegraphs(graph): """For .telegraph command, upload media & text to telegraph site.""" await graph.edit("**Processando...**") if not graph.text[0].isalpha() and graph.text[0] not in ("/", "#", "@", "!"): if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "media": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await graph.edit( f"**Baixado para** `{downloaded_file_name}` **em** `{ms}` **segundos.**" ) if downloaded_file_name.endswith(".webp"): resize_image(downloaded_file_name) try: media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("**Erro:** " + str(exc)) os.remove(downloaded_file_name) else: os.remove(downloaded_file_name) await graph.edit( f"**Enviado com sucesso para** [telegra.ph](https://telegra.ph{media_urls[0]})**.**", link_preview=True, ) elif input_str == "text": user_object = await bot.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) await graph.edit( f'**Enviado com sucesso para** [telegra.ph](https://telegra.ph/{response["path"]})**.**', link_preview=True, ) else: await graph.edit( "**Responda a uma mensagem para obter um link telegra.ph permanente.**" )
async def telegraphs(graph): """For .telegraph command, upload media & text to telegraph site.""" await graph.edit("`Prosess...`") if not graph.text[0].isalpha() and graph.text[0] not in ("/", "#", "@", "!"): if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "m": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await graph.edit("Diunduh ke {} dalam {} detik.".format( downloaded_file_name, ms)) try: if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) except AttributeError: return await graph.edit("`Tidak ada media yang tersedia`") try: media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: os.remove(downloaded_file_name) await graph.edit( "Suckses mengUpload ke [telegra.ph](https://telegra.ph{})." .format(media_urls[0]), link_preview=True, ) elif input_str == "t": user_object = await bot.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) await graph.edit( "Sukses diupload ke [telegra.ph](https://telegra.ph/{}).". format(response["path"]), link_preview=True, ) else: await graph.edit( "`Balas pesan untuk mendapatkan tautan telegra.ph permanen.`")
async def bad(event): # sourcery no-metrics "To manage vars in database" cmd = event.pattern_match.group(1).lower() vname = event.pattern_match.group(2) vnlist = "".join(f"{i}. `{each}`\n" for i, each in enumerate(vlist, start=1)) if not vname: return await edit_delete( event, f"**📑 Give correct var name from the list :\n\n**{vnlist}", time=60) vinfo = None if " " in vname: vname, vinfo = vname.split(" ", 1) reply = await event.get_reply_message() if not vinfo and reply: vinfo = reply.text if vname in vlist: if vname in oldvars: vname = oldvars[vname] if cmd == "set": if vname == "DEFAULT_USER": if not vinfo or vinfo != "Me": return await edit_delete( event, "**To save your Current Profile info Set the value:**\\n `.setdv DEFAULT_USER Me`", ) USERINFO = await catub.get_entity(catub.uid) FULL_USERINFO = (await catub(GetFullUserRequest(catub.uid) )).full_user addgvar("FIRST_NAME", USERINFO.first_name) addgvar("DEFAULT_NAME", USERINFO.first_name) if USERINFO.last_name: addgvar( "DEFAULT_NAME", f"{USERINFO.first_name} {USERINFO.first_name}", ) addgvar("LAST_NAME", USERINFO.last_name) elif gvarstatus("LAST_NAME"): delgvar("LAST_NAME") if FULL_USERINFO.about: addgvar("DEFAULT_BIO", FULL_USERINFO.about) elif gvarstatus("DEFAULT_BIO"): delgvar("DEFAULT_BIO") try: photos = await catub.get_profile_photos(catub.uid) myphoto = await catub.download_media(photos[0]) myphoto_urls = upload_file(myphoto) addgvar("DEFAULT_PIC", f"https://telegra.ph{myphoto_urls[0]}") except IndexError: if gvarstatus("DEFAULT_PIC"): delgvar("DEFAULT_PIC") usrln = gvarstatus("LAST_NAME") or None usrbio = gvarstatus("DEFAULT_BIO") or None usrphoto = gvarstatus("DEFAULT_PIC") or None vinfo = f'**Name:** `{gvarstatus("DEFAULT_NAME")}`\n**First Name:** `{gvarstatus("FIRST_NAME")}`\n**Last Name:** `{usrln}`\n**Bio:** `{usrbio}`\n**Photo:** `{usrphoto}`' else: if not vinfo and vname in ["ALIVE_TEMPLATE", "PING_TEMPLATE"]: return await edit_delete(event, "Check @cat_alive") if not vinfo: return await edit_delete( event, f"Give some values which you want to save for **{vname}**", ) check = vinfo.split(" ") for i in check: if vname == "DEFAULT_PIC" and not url(i): return await edit_delete( event, "**Give me a correct link...**") elif vname == "DIGITAL_PIC" and not url(i): return await edit_delete( event, "**Give me a correct link...**") elif (("PIC" in vname) or ("pic" in vname)) and not url(i): return await edit_delete( event, "**Give me a correct link...**") elif (vname == "DIGITAL_PIC" or vname == "DEFAULT_PIC" or vname == "BOT_START_PIC") and url(i): vinfo = i break elif not "PIC" in vname: break if vname == "DEFAULT_BIO" and len(vinfo) > 70: return await edit_or_reply( event, f"No of characters in your bio must not exceed 70 so compress it and set again\n`{vinfo}`", ) addgvar(vname, vinfo) if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SET_DATAVAR\ \n**{vname}** is updated newly in database as below", ) await event.client.send_message(BOTLOG_CHATID, vinfo, silent=True) await edit_delete( event, f"📑 Value of **{vname}** is changed to :- `{vinfo}`", time=20) if cmd == "get": var_data = gvarstatus(vname) await edit_delete( event, f"📑 Value of **{vname}** is ```{var_data}```", time=20) elif cmd == "del": if vname == "DEFAULT_USER": delgvar("FIRST_NAME") delgvar("DEFAULT_NAME") if gvarstatus("LAST_NAME"): delgvar("LAST_NAME") if gvarstatus("DEFAULT_BIO"): delgvar("DEFAULT_BIO") if gvarstatus("DEFAULT_PIC"): delgvar("DEFAULT_PIC") delgvar(vname) if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#DEL_DATAVAR\ \n**{vname}** is deleted from database", ) await edit_delete( event, f"📑 Value of **{vname}** is now deleted & set to default.", time=20, ) else: await edit_delete( event, f"**📑 Give correct var name from the list :\n\n**{vnlist}", time=60)
async def _(event): if event.fwd_from: return if Config.LOGGER_ID is None: await eod(event, "You need to setup `LOGGER_ID` to use telegraph...", 7) return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "m": downloaded_file_name = await bot.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.datetime.now() ms = (end - start).seconds await edit_or_reply( event, "Downloaded to `{}` in `{}` seconds. \nMaking Telegraph Link....." .format(downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await eod(event, "ERROR: " + str(exc), 8) os.remove(downloaded_file_name) else: end = datetime.datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await eor( event, "✓ **File uploaded to [telegraph](https://telegra.ph{})** \n✓ **Time Taken :-** `{}` secs \n✓ **By :- {}**" .format( media_urls[0], (ms + ms_two), hell_mention, ), link_preview=True, ) elif input_str == "t": user_object = await borg.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.datetime.now() ms = (end - start).seconds hellboy = f"https://telegra.ph/{response['path']}" await edit_or_reply( event, f"✓ **Pasted to** [telegraph]({hellboy}) \n✓ **Time Taken :-** `{ms}` secs\n✓** By :** {hell_mention}", link_preview=True) else: await eod(event, "Reply to a message to get a permanent telegra.ph link.")
async def _(event): if event.fwd_from: return catevent = await edit_or_reply(event, "** ⪼ جاري المعالجه ༗...**") if not os.path.isdir(Config.TEMP_DIR): os.makedirs(Config.TEMP_DIR) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**" .format(auth_url), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str in ["ميديا", "m"]: downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) end = datetime.now() ms = (end - start).seconds await catevent.edit( f"** ⪼ تم تحميل {downloaded_file_name} في وقت {ms} ثانيه.**") if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await catevent.edit("**Error : **" + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await catevent.edit( "**الرابط : **[اضغط هنا](https://telegra.ph{})\ \n**الوقت : **`{} ثانيه.`".format(media_urls[0], (ms + ms_two)), link_preview=True, ) elif input_str in ["نص", "t"]: user_object = await event.client.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await event.client.download_media( r_message, Config.TEMP_DIR) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds cat = f"https://telegra.ph/{response['path']}" await catevent.edit( f"**الرابط : ** [اضغط هنا]({cat})\ \n**الوقت : **`{ms} ثانيه.`", link_preview=True, ) else: await catevent.edit( "قم بالرد على رسالة للحصول على رابط تللكراف دائم.", )
async def _(event): if event.fwd_from: return if Config.PLUGIN_CHANNEL is None: await edit_or_reply( event, "Please set the required environment variable `PLUGIN_CHANNEL` for this plugin to work\n\nGo to [AuraXBot Chat Group](t.me/AuraXSupport) for assistance" ) return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) await event.client.send_message( Config.PLUGIN_CHANNEL, "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**" .format(auth_url), ) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "m": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await edit_or_reply( event, "Downloaded to {} in {} seconds. \nMaking Telegraph Link.....". format(downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await edit_or_reply(event, "ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await edit_or_reply( event, "✓ **YOUR FILE :-** https://telegra.ph{} \n✓ **Time Taken :-** `{}` secs \n✓ **By :- [{}](tg://user?id={})**" .format(media_urls[0], (ms + ms_two), AuraX_NAME, aura), link_preview=True, ) elif input_str == "t": user_object = await borg.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds IisGaurav = f"https://telegra.ph/{response['path']}" await edit_or_reply( event, f"✓ **Pasted to** [telegraph]({IisGaurav}) \n✓ **Time Taken :-** `{ms}` secs\n✓** By :- **[{AuraX_NAME}](tg://user?id={aura})", link_preview=True) else: await edit_or_reply( event, "Reply to a message to get a permanent telegra.ph link.")
async def telegraph_(message: Message): replied = message.reply_to_message if not replied: await message.err("reply to media or text") return if not ((replied.photo and replied.photo.file_size <= _T_LIMIT) or (replied.animation and replied.animation.file_size <= _T_LIMIT) or (replied.video and replied.video.file_name.endswith('.mp4') and replied.video.file_size <= _T_LIMIT) or (replied.sticker and replied.sticker.file_name.endswith('.webp')) or replied.text or (replied.document and replied.document.file_name.endswith( ('.jpg', '.jpeg', '.png', '.gif', '.mp4', '.html', '.txt', '.py')) and replied.document.file_size <= _T_LIMIT)): await message.err("not supported!") return await message.edit("`processing...`") if (replied.text or (replied.document and replied.document.file_name.endswith( ('.html', '.txt', '.py')))): if replied.document: dl_loc = await message.client.download_media( message=message.reply_to_message, file_name=Config.DOWN_PATH, progress=progress, progress_args=(message, "trying to download")) async with aiofiles.open(dl_loc, "r") as jv: text = await jv.read() header = message.input_str if not header: header = "Pasted content by @theuserge" os.remove(dl_loc) else: content = message.reply_to_message.text.html if "|" in content and not content.startswith("<"): content = content.split("|", maxsplit=1) header = content[0] text = content[1] else: text = content header = "Pasted content by @theuserge" t_url = await pool.run_in_thread(post_to_telegraph)(header, text.replace( "\n", "<br>")) jv_text = f"**[Here Your Telegra.ph Link!]({t_url})**" await message.edit(text=jv_text, disable_web_page_preview=True) return dl_loc = await message.client.download_media( message=message.reply_to_message, file_name=Config.DOWN_PATH, progress=progress, progress_args=(message, "trying to download")) if replied.sticker: img = Image.open(dl_loc).convert('RGB') img.save(f'{Config.DOWN_PATH}/userge.png', 'png') os.remove(dl_loc) dl_loc = f'{Config.DOWN_PATH}/userge.png' await message.edit("`uploading to telegraph...`") try: response = upload_file(dl_loc) except Exception as t_e: await message.err(t_e) else: await message.edit( f"**[Here Your Telegra.ph Link!](https://telegra.ph{response[0]})**" ) finally: os.remove(dl_loc)
async def _(event): if event.fwd_from: return optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "gm": downloaded_file_name = await telethn.download_media( r_message, TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds h = await event.reply("Downloaded to {} in {} seconds.".format( downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await h.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await h.edit( "Uploaded to [Telegraph](https://telegra.ph{}) in {} seconds." .format(media_urls[0], (ms + ms_two)), link_preview=True) elif input_str == "gt": user_object = await telethn.get_entity(r_message.sender_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await telethn.download_media( r_message, TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.reply( "Pasted to [Telegraph](https://telegra.ph/{}) in {} seconds.". format(response["path"], ms), link_preview=True) else: await event.reply( "Reply to a message to get a permanent telegra.ph link.")
async def telegraphs(graph): await graph.edit("`🔄 Hazırlanıyor...`") if not graph.text[0].isalpha() and graph.text[0] not in ("/", "#", "@", "!"): if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "m": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await graph.edit( "✨ ```{}``` __saniye içinde__ ```{}``` __noktasına yüklendi.__" .format(ms, downloaded_file_name)) try: if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) except AttributeError: return await graph.edit("`🥺 Medya sağlanamadı`") try: media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("Hata: " + str(exc)) os.remove(downloaded_file_name) else: os.remove(downloaded_file_name) await graph.edit( "➤ ```https://telegra.ph{}``` **'a yüklendi.**".format( media_urls[0]), link_preview=True, ) elif input_str == "t": user_object = await bot.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) await graph.edit( "➤```https://telegra.ph/{}``` **'a yüklendi!**".format( response["path"]), link_preview=True, ) else: await graph.edit( "`❎ Kalıcı bir telegra.ph bağlantısı elde etmek için mesajı yanıtlayın.`" )
async def telegraphs(graph): """ For .telegraph command, upload media & text to telegraph site. """ if graph.text[0].isalpha() or graph.text[0] in ("/", "#", "@", "!"): return if graph.fwd_from: return if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if graph.reply_to_msg_id: start = datetime.now() r_message = await graph.get_reply_message() input_str = graph.pattern_match.group(1) if input_str == "media": downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY ) end = datetime.now() ms = (end - start).seconds await graph.edit("Downloaded to {} in {} seconds.".format(downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await graph.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await graph.edit("Uploaded to https://telegra.ph{} in {} seconds.".format(media_urls[0], (ms + ms_two)), link_preview=True) elif input_str == "text": user_object = await bot.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await bot.download_media( r_message, TEMP_DOWNLOAD_DIRECTORY ) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page( title_of_page, html_content=page_content ) end = datetime.now() ms = (end - start).seconds await graph.edit("Pasted to https://telegra.ph/{} in {} seconds.".format(response["path"], ms), link_preview=True) else: await graph.edit("Reply to a message to get a permanent telegra.ph link.")
async def _(event): if event.fwd_from: return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) await borg.send_message( Config.PRIVATE_GROUP_BOT_API_ID, "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**" .format(auth_url)) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await event.edit("Downloaded to {} in {} seconds.".format( downloaded_file_name, ms)) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await event.edit( "Uploaded to https://telegra.ph/{} in {} seconds.".format( media_urls[0], (ms + ms_two)), link_preview=True) elif input_str == "text": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.edit( "[www.pornhub.com/milf](https://telegra.ph/{})".format( response["path"], ms), link_preview=True) else: await event.edit( "Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)" )
async def _(event): if event.fwd_from: return global USER_AFK global afk_time global last_afk_message global afk_start global afk_end global reason global tele USER_AFK = {} afk_time = None last_afk_message = {} afk_end = {} tele = "False" start_1 = datetime.now() afk_start = start_1.replace(microsecond=0) if not USER_AFK: if event.reply_to_msg_id: reply_message = await event.get_reply_message() media = await telebot.download_media(reply_message, "AFK_media") try: url = upload_file(media) os.remove(media) except BaseException: pass input_str = event.pattern_match.group(1) if url: if input_str is not None: tele = "True" reason = f"`{input_str}`[ ](https://telegra.ph/{url[0]})" else: tele = "False" reason = f"[ ](https://telegra.ph/{url[0]})" else: if input_str is not None: reason = f"`{input_str}`" else: input_str = event.pattern_match.group(1) reason = f"`{input_str}`" last_seen_status = await event.client( functions.account.GetPrivacyRequest( types.InputPrivacyKeyStatusTimestamp())) if isinstance(last_seen_status.rules, types.PrivacyValueAllowAll): afk_time = datetime.now() USER_AFK = f"on: {reason}" if reason: await event.edit( f"`Your status has been set to AFK.`\n**Reason** - {reason}") await asyncio.sleep(5) await event.delete() else: await event.edit("`Your status has been set to AFK.`") await asyncio.sleep(5) await event.delete() if BOTLOG: if reason: await event.client.send_message( Var.PRIVATE_GROUP_ID, f"#AFK \nAFK - Active\nReason - {reason}", ) else: await event.client.send_message( Var.PRIVATE_GROUP_ID, f"#AFK \nAFK - Active\nReason - None Specified.", )
async def _(event): if event.fwd_from: return if Config.PRIVATE_GROUP_BOT_API_ID is None: await event.edit("يرجى تعين متغير فار PRIVATE_GROUP_BOT") return if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) await borg.send_message( Config.PRIVATE_GROUP_BOT_API_ID, "انشاء حساب تليغراف جديد {} حاليا. \n**لاتعطي هذا الرابط لاي شخص!**". format(auth_url)) optional_title = event.pattern_match.group(2) if event.reply_to_msg_id: start = datetime.now() r_message = await event.get_reply_message() input_str = event.pattern_match.group(1) if input_str == "media": downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) end = datetime.now() ms = (end - start).seconds await event.edit("يحمل {} هنا {} ثواني.".format( downloaded_file_name, ms)) if downloaded_file_name.endswith((".webp")): resize_image(downloaded_file_name) try: start = datetime.now() media_urls = upload_file(downloaded_file_name) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(downloaded_file_name) else: end = datetime.now() ms_two = (end - start).seconds os.remove(downloaded_file_name) await event.edit( "رفع في https://telegra.ph{} هنا {} ثواني.".format( media_urls[0], (ms + ms_two)), link_preview=True) elif input_str == "text": user_object = await borg.get_entity(r_message.from_id) title_of_page = user_object.first_name # + " " + user_object.last_name # apparently, all Users do not have last_name field if optional_title: title_of_page = optional_title page_content = r_message.message if r_message.media: if page_content != "": title_of_page = page_content downloaded_file_name = await borg.download_media( r_message, Config.TMP_DOWNLOAD_DIRECTORY) m_list = None with open(downloaded_file_name, "rb") as fd: m_list = fd.readlines() for m in m_list: page_content += m.decode("UTF-8") + "\n" os.remove(downloaded_file_name) page_content = page_content.replace("\n", "<br>") response = telegraph.create_page(title_of_page, html_content=page_content) end = datetime.now() ms = (end - start).seconds await event.edit( "تم لصق في https://telegra.ph/{} هنا {} ثواني.".format( response["path"], ms), link_preview=True) else: await event.edit( "قم برد على المنشور للحصول على رابط تليجراف (Inspired by @iqthon)")