async def _(event): if not event.is_private: return tata = event.pattern_match.group(1) data = tata.decode() meta = data.split("-", 1)[1] # print(meta) if "|" in meta: sender, chatid, msgid = meta.split("|") sender = int(sender.strip()) if not event.sender_id == sender: await event.answer("You haven't send that command !") return num = 0 chatid = int(chatid.strip()) msgid = int(msgid.strip()) to_check = get_email(event.sender_id) email = to_check["email"] hash = to_check["hash"] mails = tm.get_mailbox(email=email, email_hash=hash) if type(mails) is dict: for key, value in mails.items(): if value == "There are no emails yet": await tbot.edit_message(chatid, msgid, "There are no emails yet.") return vector = len(mails) if num > vector - 1: num = 0 # print(vector) # print(num) header = f"**#{num} **" from_mail = mails[int(num)]["mail_from"] subject = mails[int(num)]["mail_subject"] msg = mails[int(num)]["mail_text"] ttime = mails[int(num)]["mail_timestamp"] mail_id = mails[int(num)]["mail_id"] attch = int(mails[int(num)]["mail_attachments_count"]) timestamp = ttime dt_object = datetime.fromtimestamp(timestamp) ttime = str(dt_object) header = f"**#{num} **" telegraph = Telegraph() telegraph.create_account(short_name="MissJuliaRobot") if subject == "": subject = "No Subject" headers = f"**FROM**: {from_mail}\n**TO**: {email}\n**DATE**: {ttime}\n**MAIL BODY**:\n\n{msg}" nheaders = headers.replace("\n", "<br />") final = markdown.markdown(nheaders) response = telegraph.create_page(subject, html_content=final) tlink = "https://telegra.ph/{}".format(response["path"]) if not attch > 0: lastisthis = ( f"{header}MAIL FROM: {from_mail}" + "\n" + f"TO: {email}" + "\n" + f"DATE: `{ttime}`" ) else: lastisthis = ( f"{header}MAIL FROM: {from_mail}" + "\n" + f"TO: {email}" + "\n" + f"DATE: `{ttime}`" + "\n\n" + "**The attachments will be send to you shortly !**" ) await tbot.edit_message( chatid, msgid, lastisthis, link_preview=False, buttons=[ [ Button.url( "Click here to read this mail", url=f"{tlink}", ), ], [ Button.inline( "◀️", data=f"checkinboxprev-{sender}|{num}|{chatid}|{msgid}", ), Button.inline("❌", data=f"stopcheckinbox-{sender}|{chatid}|{msgid}"), Button.inline( "▶️", data=f"checkinboxnext-{sender}|{num}|{chatid}|{msgid}", ), ], [ Button.inline( "Refresh 🔁", data=f"refreshinbox-{sender}|{chatid}|{msgid}", ) ], ], ) if attch > 0: gg = get_attachments(mail_id) for i in gg: fname = i["name"] with open(fname, "w+b") as f: f.write(base64.b64decode((i["content"]).encode())) await tbot.send_file(chatid, file=fname) os.remove(fname)
exit(1) finally: cur.close() conn.close() #Generate User String LOGGER.info("Generating USER_SESSION_STRING") app = Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN) #Generate Telegraph Token sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8)) LOGGER.info("Generating Telegraph Token using '" + sname + "' name") TELEGRAPH = Telegraph() TELEGRAPH.create_account(short_name=sname) TELEGRAPH_TOKEN = TELEGRAPH.get_access_token() LOGGER.info("Telegraph Token Generated: '" + TELEGRAPH_TOKEN + "'") try: HEROKU_API_KEY = getConfig('HEROKU_API_KEY') except KeyError: logging.warning('HEROKU API KEY not provided!') HEROKU_API_KEY = None try: HEROKU_APP_NAME = getConfig('HEROKU_APP_NAME') except KeyError: logging.warning('HEROKU APP NAME not provided!') HEROKU_APP_NAME = None try:
from telegraph import Telegraph, exceptions import requests import os # telegraph = Telegraph(access_token='8efd824783cea0f0dcf74b885b2c643f56dcb037a71ee09914698d1e1e80') telegraph = Telegraph( access_token='67dd3e7b5a5a3ddc057542ab173b1ed31305323e84521a03b8eb9562698e' ) # telegraph.create_account(short_name='Ivan', # author_name='Ivan Garmashev', # author_url='https://t.me/PUTEEEN', # # replace_token='08a09f327cd39c4b23ea76f904c27a9ca223ad0ad641259baaf1164507e4', # ) directory = 'C:/tg_channel/media/' # directory of photo def create_site(name, text=''): list_files = os.listdir(directory) photo_html = '<p></p>' + text list_files = sorted(list_files, key=lambda v: int(v.split('@')[0])) for i in list_files: print(i) with open(directory + i, 'rb') as f: # upload photo to server file_name = i.rpartition('.jpg')[0] if file_name.partition('@')[2] != '': caption = '@' + file_name.partition('@')[2] else: caption = '' # if len(file_name) > 1:
<br><br> <b>/{BotCommands.SetThumbCommand}</b>: Reply photo to set it as Thumbnail <br><br> <b>/{BotCommands.CancelMirror}</b>: Reply to the message by which the download was initiated and that download will be cancelled <br><br> <b>/{BotCommands.CancelAllCommand}</b>: Cancel all running tasks <br><br> <b>/{BotCommands.ListCommand}</b> [search term]: Searches the search term in the Google Drive, If found replies with the link <br><br> <b>/{BotCommands.StatusCommand}</b>: Shows a status of all the downloads <br><br> <b>/{BotCommands.StatsCommand}</b>: Show Stats of the machine the bot is hosted on ''' help = Telegraph(access_token=telegraph_token).create_page( title='Slam Mirrorbot Help', author_name='Slam Mirrorbot', author_url='https://github.com/SlamDevs/slam-mirrorbot', html_content=help_string_telegraph, )["path"] help_string = f''' /{BotCommands.PingCommand}: Check how long it takes to Ping the Bot /{BotCommands.AuthorizeCommand}: Authorize a chat or a user to use the bot (Can only be invoked by Owner & Sudo of the bot) /{BotCommands.UnAuthorizeCommand}: Unauthorize a chat or a user to use the bot (Can only be invoked by Owner & Sudo of the bot) /{BotCommands.AuthorizedUsersCommand}: Show authorized users (Only Owner & Sudo) /{BotCommands.AddSudoCommand}: Add sudo user (Only Owner) /{BotCommands.RmSudoCommand}: Remove sudo users (Only Owner)
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list(supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='name asc').execute() content_count = 0 if response["files"]: msg += f'<h4>{len(response["files"])} Results: {fileName}</h4><br><br>' for file in response.get('files', []): if file.get('mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"⁍<code>{file.get('name')}<br>(folder)📁</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>🔰𝙳𝚛𝚒𝚟𝚎 𝙻𝚒𝚗𝚔🔰</a></b>" else: msg += f"<b><a href={furl}>🔰𝙳𝚛𝚒𝚟𝚎 𝙻𝚒𝚗𝚔🔰</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">🏓𝙸𝚗𝚍𝚎𝚡 𝙻𝚒𝚗𝚔🏓</a></b>' else: msg += f' <b>| <a href="{url}">🏓𝙸𝚗𝚍𝚎𝚡 𝙻𝚒𝚗𝚔🏓</a></b>' elif file.get('mimeType') == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>🔰𝙳𝚛𝚒𝚟𝚎 𝙻𝚒𝚗𝚔🔰</a></b>" else: msg += f"<b><a href={furl}>🔰𝙳𝚛𝚒𝚟𝚎 𝙻𝚒𝚗𝚔🔰</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">🏓𝙸𝚗𝚍𝚎𝚡 𝙻𝚒𝚗𝚔🏓</a></b>' else: msg += f' <b>| <a href="{url}">🏓𝙸𝚗𝚍𝚎𝚡 𝙻𝚒𝚗𝚔🏓</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT : self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "❌ 𝙽𝚘 𝚁𝚎𝚜𝚞𝚕𝚝 𝙵𝚘𝚞𝚗𝚍 ❌", None for content in self.telegraph_content : self.path.append(Telegraph(access_token=telegraph_token).create_page( title = '𝔻𝕍𝔻𝕎𝕆ℝ𝕃𝔻 𝙼𝚒𝚛𝚛𝚘𝚛 𝙱𝚘𝚝 𝚂𝚎𝚊𝚛𝚌𝚑', author_name='𝔸ℕ𝕠𝕟𝕐𝕞𝕠𝕌𝕊𝔽𝕣𝕚𝔼ℕ𝔻 𝙼𝚒𝚛𝚛𝚘𝚛 𝙱𝚘𝚝', author_url='https://t.me/ANonYmoUS_FriEND', html_content=content )['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>🔎 𝙵𝚘𝚞𝚗𝚍 📚{len(response['files'])} results for <i>{fileName}</i></b>" buttons = button_build.ButtonMaker() buttons.buildbutton("🏓 𝙲𝙻𝙸𝙲𝙺 𝙷𝙴𝚁𝙴 🏓", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else : return '', ''
""" Check Current Beta firmwares of Samsung Devices Syntax: .check androidVersion modelNumber By :- Jaskaran ^_^ Telegram :- @Zero_cool7870 """ from asyncio import wait import time import gc from telegraph import Telegraph from bs4 import BeautifulSoup as bs import requests from telethon import events telegraph = Telegraph() telegraph.create_account(short_name='zeroc') chat_ids = [596701090, 517742107] csclist = [ 'ACG', 'ATT', 'BST', 'CCT', 'GCF', 'LRA', 'SPR', 'TFN', 'TMB', 'USC', 'VMU', 'VZW', 'XAA', 'XAS', 'AFG', 'TMC', 'TTR', 'DRE', 'MOB', 'MAX', 'TRG', 'SEB', 'PRO', 'TEB', 'BHT', 'GBL', 'BGL', 'MTL', 'VVT', 'CAM', 'CAU', 'DHR', 'CRO', 'TWO', 'VIP', 'CYV', 'CYO', 'ETL', 'O2C', 'TMZ', 'VDC', 'EGY', 'XEF', 'BOG', 'FTM', 'SFR', 'DBT', 'XEG', 'DDE', 'VIA', 'DTM', 'VD2', 'EUR', 'COS', 'VGR', 'XEH', 'TMH', 'PAN', 'VDH', 'XSE', 'XID', 'THR', 'MID', 'TSI', 'MET', '3IE', 'VDI', 'ILO', 'CEL', 'PTR', 'PCL', 'ITV', 'HUI', 'TIM', 'OMN', 'WIN', 'SKZ', 'AFR', 'KEN', 'BTC', 'LUX', 'VIM', 'MBM', 'XME', 'MRU', 'TMT', 'MAT', 'MWD', 'PHN', 'DNL', 'TNL', 'VDF', 'ECT', 'NEE', 'TEN', 'ATO', 'PAK', 'GLB', 'XTC', 'SMA', 'XTE', 'XEO', 'DPL', 'IDE', 'PLS', 'PRT', 'TPL', 'MEO', 'OPT', 'TPH', 'TCL', 'ROM', 'COA', 'ORO', 'CNX', 'SER', 'ACR', 'WTL', 'XFU', 'TSR',
async def cria_site_telegraph(msg): conexao_sqlite = sqlite3.connect('bot_database.db') conexao_sqlite.row_factory = sqlite3.Row cursor_sqlite = conexao_sqlite.cursor() try: if msg['chat']['type'] == 'supergroup': try: grupo = f"https://t.me/{msg['chat']['username']}" except: grupo = f"Secreto: {msg['chat']['title']}" pass try: usuario = msg['from']['username'] except: usuario = f"@{msg['from']['id']}({msg['from']['first_name']})" pass data = datetime.now().strftime('%d/%m/%Y %H:%M') chat_type = msg['chat']['type'] chat_id = msg['chat']['id'] texto = msg['text'] if texto == 'links': cursor_sqlite.execute("""SELECT * FROM telegraph_sites""") resultados = cursor_sqlite.fetchall() a = await bot.sendMessage( chat_id, f"🤖 {msg['from']['first_name']} tenho {str(len(resultados))} páginas criadas, vou exibir elas em ordem com uma pausa de 3 segundos...", reply_to_message_id=msg['message_id']) for resultado in resultados: link = resultado['link'] await bot.editMessageText( (msg['chat']['id'], a['message_id']), link) time.sleep(3) if 'photo' in msg.get( 'reply_to_message') and 'web' in texto.split()[0]: titulo = texto.split()[1] separador = ' \n' conte = texto.split()[2:] conteudo = separador.join(map(str, conte)) id_foto = msg.get('reply_to_message')['photo'][0]['file_id'] await bot.download_file(id_foto, 'arquivos/criar_site.jpg') CLIENT_ID = "ebfc2558bda96e5" PATH = 'arquivos/criar_site.jpg' im = pyimgur.Imgur(CLIENT_ID) uploaded_image = im.upload_image(PATH, title=titulo) link_imagem = uploaded_image.link conteudo_html = f'<img src="{link_imagem}"><p>{conteudo}</p><br><br><br><br><a href="https://t.me/{bot_username}?start=start">Telegram: @{bot_username}</a>' telegraph = Telegraph() a = telegraph.create_account(short_name='manicomio') response = telegraph.create_page(titulo, html_content=conteudo_html) link_final = 'https://telegra.ph/{}'.format(response['path']) print(f"Usuário criou um site no telegra.ph: {link_final}") await bot.sendMessage( chat_id, f"🤖 {msg['from']['first_name']} acabei seu site:{link_final}", reply_to_message_id=msg['message_id']) os.remove('arquivos/criar_site.jpg') # tabela do armazenamento dos sites telegraph cursor_sqlite.execute( f"""INSERT INTO telegraph_sites (int_id, grupo, tipo_grupo, id_grupo, usuario, id_usuario, data,titulo,texto,imagem,link)VALUES(null,'{grupo}','{chat_type}','{chat_id}','@{usuario}','{msg['from']['id']}','{data}','{titulo}','{conteudo}','{link_imagem}','{link_final}')""" ) conexao_sqlite.commit() conexao_sqlite.close() except Exception as e: pass
def __init__(self): self.tgph = Telegraph(TGPH_TOKEN)
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list(supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='modifiedTime desc').execute() content_count = 0 if response["files"]: msg += f'<h4>Results : {fileName}</h4><br><br>' for file in response.get('files', []): if file.get('mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"⁍<code>{file.get('name')}<br>(folder📁)</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={furl}&format=text').text msg += f"<b><a href={sfurl}>🗂 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤 🗂</a></b>" else: msg += f"<b><a href={furl}>🗂 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤 🗂</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={url}&format=text').text msg += f' <b>| <a href="{siurl}">🚀 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤 🚀</a></b>' else: msg += f' <b>| <a href="{url}">🚀 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤 🚀</a></b>' elif file.get('mimeType') == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={furl}&format=text').text msg += f"<b><a href={sfurl}>🗂 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤 🗂</a></b>" else: msg += f"<b><a href={furl}>🗂 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤 🗂</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={url}&format=text').text msg += f' <b>| <a href="{siurl}">🚀 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤 🚀</a></b>' else: msg += f' <b>| <a href="{url}">🚀 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤 🚀</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT : self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found :(", None for content in self.telegraph_content : self.path.append(Telegraph(access_token=TELEGRAPH_TOKEN).create_page( title='𝗣𝗥𝗜𝗜𝗜𝗜𝗬𝗢 𝗠𝗜𝗥𝗥𝗢𝗥 𝗭𝗢𝗡𝗘', author_name='👲 𝗨𝗽𝗹𝗼𝗮𝗱 𝗕𝘆', author_url='https://t.me/PriiiiyoBOTs', html_content=content )['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>🔎 Search Results For <i>{fileName}</i></b> \n<b>📚 Found {len(response['files'])} results</b>" buttons = button_build.ButtonMaker() buttons.buildbutton("🔎 Click HERE 🔎", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else : return '', ''
INVISIBLE_CHAR = 'Рађ' TELEGRAPH_TOKEN = '' # Insert your Telegraph API Token API_KEY = '' # Insert your Genius API Key DB_HOST = 'postgres' DB_NAME = 'lyrics' DB_USER = '******' DB_PASSW = '' DB_CON = { 'provider': 'postgres', 'user': DB_USER, 'password': DB_PASSW, 'host': DB_HOST, 'database': DB_NAME } PACKAGE_DIR = 'bot/' PLUGINS_FOLDER = PACKAGE_DIR + 'plugin' MAX_CACHE_TIME = timedelta(days=1) TELEGRAPH = Telegraph(access_token=TELEGRAPH_TOKEN) BACK = 'Back РєЕ№ИЈ' MENU = 'Menu ЪЈў' LYRICS_NOT_FOUND = 'Lyrics not found.' LOADING = 'РЈ│ <b>Loading...</b>'
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = (self.__service.files().list( supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces="drive", pageSize=200, fields="files(id, name, mimeType, size)", orderBy="modifiedTime desc", ).execute()) content_count = 0 if not response["files"]: return "", "" msg += f"<h4>Results : {fileName}</h4><br><br>" for file in response.get("files", []): if (file.get("mimeType") == "application/vnd.google-apps.folder" ): # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"⁍<code>{file.get('name')}<br>(folder)</code><br>" if SHORTENER is None or SHORTENER_API is None: msg += f"<b><a href={furl}>Drive Link</a></b>" else: sfurl = requests.get( f"https://{SHORTENER}/api?api={SHORTENER_API}&url={furl}&format=text" ).text msg += f"<b><a href={sfurl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f"{INDEX_URL}/{url_path}/" if SHORTENER is None or SHORTENER_API is None: msg += f' <b>| <a href="{url}">Index Link</a></b>' else: siurl = requests.get( f"https://{SHORTENER}/api?api={SHORTENER_API}&url={url}&format=text" ).text msg += f' <b>| <a href="{siurl}">Index Link</a></b>' # Excluded index link as indexes cant download or open these shortcuts elif file.get( "mimeType") == "application/vnd.google-apps.shortcut": msg += ( f"⁍ <a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" f"</a> (shortcut)") else: furl = ( f"https://drive.google.com/uc?id={file.get('id')}&export=download" ) msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})</code><br>" if SHORTENER is None or SHORTENER_API is None: msg += f"<b><a href={furl}>Drive Link</a></b>" else: sfurl = requests.get( f"https://{SHORTENER}/api?api={SHORTENER_API}&url={furl}&format=text" ).text msg += f"<b><a href={sfurl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f"{INDEX_URL}/{url_path}" if SHORTENER is None or SHORTENER_API is None: msg += f' <b>| <a href="{url}">Index Link</a></b>' else: siurl = requests.get( f"https://{SHORTENER}/api?api={SHORTENER_API}&url={url}&format=text" ).text msg += f' <b>| <a href="{siurl}">Index Link</a></b>' msg += "<br><br>" content_count += 1 if content_count == TELEGRAPHLIMIT: self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != "": self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found :(", None for content in self.telegraph_content: self.path.append( Telegraph(access_token=telegraph_token).create_page( title="Mirror Bot Search", author_name="Mirror Bot", author_url= "https://github.com/magneto261290/magneto-python-aria", html_content=content, )["path"]) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>Search Results For {fileName} </b>" buttons = button_build.ButtonMaker() buttons.buildbutton("HERE", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1))
#!/usr/bin/env python # -*- coding: utf-8 -*- # vim:fileencoding=utf-8 import pyrogram from telegraph import Telegraph import config app = pyrogram.Client(config.name, config.api_id, config.api_hash) tlgraph = Telegraph(config.tlgraph_token) def slice_to_first_char(s1, s2): for i, c in enumerate(s1): if c in s2: return s1[:i + 1] return s1 @app.on_raw_update() def draft_update(client, update, users, chats): try: try: txt = update.draft.message # check if update is draft except: return # check if draft is what we need if len(txt) < 50: return for txt_start in [ "pasta",
async def domux_f(client, message): status_message = await message.reply_text("Processing ...") reply_to_id = message.message_id if message.reply_to_message: reply_to_id = message.reply_to_message.message_id try: a, b, c = message.text.split("|") file = a.split(" ")[1] sub = b.split(" ")[1] output = c.split(" ")[1] mcover = "/app/Docover.jpg" en, on = await run_command([ "ffmpeg", "-i", file, "-i", sub, "-c", "copy", "-c:s", "srt", "-attach", mcover, "-metadata:s:t", "mimetype=image/jpeg", "-metadata:s:t", "filename=cover.jpg", "-metadata", "title=Upl'd By Team-D&O @dramaost TG Group", output ]) metadata = extractMetadata(createParser(u_output)) metadata = extractMetadata(createParser(u_output)) duration = 0 if metadata.has("duration"): duration = metadata.get('duration').seconds hours, rem = divmod(duration, 3600) minutes, seconds = divmod(rem, 60) Final_duration = "{:0>2} hrs {:0>2} min {:05.2f} sec".format( int(hours), int(minutes), seconds) telegraph = Telegraph() telegraph.create_account(short_name='1337') response = telegraph.create_page( u_output + ' Media Info', html_content="".join(line + "<br>" for line in metadata.exportPlaintext())) file_context = 'https://telegra.ph/{}'.format(response['path']) e = on if not e: e = "No Error" o = en if not o: o = "No Output" else: _o = o.split("\n") o = "\n".join(_o) OUTPUT = f"**QUERY:**\n__Command:__\n\n**stderr:** \n{e}`\n**Output:**\n{o}" if len(OUTPUT) > MAX_MESSAGE_LENGTH: with open("exec.text", "w+", encoding="utf8") as out_file: out_file.write(str(OUTPUT)) user_id = message.from_user.id mention_req_user = f"<a href='tg://user?id={user_id}'>{output}</a>" await message.reply_document( document="exec.text", caption=mention_req_user + "\n\n" + "Duration : " + str(duration) + " seconds" + "\n" + "In Standard Time :" + "\n" + Final_duration, disable_notification=True, reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton('🌿 Media Info 🌿', url=file_context) ], ])) os.remove("exec.text") await status_message.delete() else: await status_message.edit(OUTPUT) except IndexError: pass await status_message.edit("please type output name with run command")
async def gdfile_f(client, message): status_message = await message.reply_text("Processing ...") try: if message.reply_to_message is not None: w = message.reply_to_message.message_id user_id = message.chat.id u_id = int(w) m = await client.get_messages(user_id, u_id) if m and m.text and m.text.lower().startswith(("https:", "http:")): link_text = m.text u_output = message.text.split(" ", 1)[1].rsplit(" ", 0)[0] await run_command(["chmod", "a+x", "./gdown.pl"]) en, on = await run_command(["./gdown.pl", link_text, u_output]) metadata = extractMetadata(createParser(u_output)) metadata = extractMetadata(createParser(u_output)) duration = 0 if metadata.has("duration"): duration = metadata.get('duration').seconds hours, rem = divmod(duration, 3600) minutes, seconds = divmod(rem, 60) Final_duration = "{:0>2} hrs {:0>2} min {:05.2f} sec".format( int(hours), int(minutes), seconds) telegraph = Telegraph() telegraph.create_account(short_name='1337') response = telegraph.create_page( u_output + ' Media Info', html_content="".join( line + "<br>" for line in metadata.exportPlaintext())) file_context = 'https://telegra.ph/{}'.format(response['path']) e = on if not e: e = "No Error" o = en if not o: o = "No Output" else: _o = o.split("\n") o = "\n".join(_o) OUTPUT = f"**QUERY:**\n__Command:__\n\n**stderr:** \n{e}`\n**Output:**\n{o}" if len(OUTPUT) > MAX_MESSAGE_LENGTH: with open("exec.text", "w+", encoding="utf8") as out_file: out_file.write(str(OUTPUT)) user_id = message.from_user.id mention_req_user = f"<a href='tg://user?id={user_id}'>{u_output}</a>" await message.reply_document( document="exec.text", caption=mention_req_user + "\n\n" + "Duration : " + str(duration) + " seconds" + "\n" + "In Standard Time :" + "\n" + Final_duration, disable_notification=True, reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton('🌿 Media Info 🌿', url=file_context) ], ])) os.remove("exec.text") await status_message.delete() else: await status_message.edit(OUTPUT) else: await status_message.edit("Replied message is not a link") else: await status_message.edit("Run as Replied message") except IndexError: pass await status_message.edit("please type output name with run command")
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list( supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='modifiedTime desc').execute() content_count = 0 if response["files"]: msg += f'<h4>Total {len(response["files"])} Results : {fileName}</h4><br><br>' for file in response.get('files', []): if file.get( 'mimeType' ) == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"⁍<code>{file.get('name')}<br>(folder📁)</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get( 'https://{}/api?api={}&url={}&format=text'.format( SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}/') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get( 'https://{}/api?api={}&url={}&format=text'. format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">Index Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get( 'https://{}/api?api={}&url={}&format=text'.format( SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get( 'https://{}/api?api={}&url={}&format=text'. format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">Index Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT: self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found :(", None for content in self.telegraph_content: self.path.append( Telegraph(access_token=telegraph_token).create_page( title='OnlyFans4uu Search', author_name='OnlyFans4uu', author_url='https://t.me/onlyfans4uu', html_content=content)['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>🔎 Search Results For <i>{fileName}</i></b> \n<b>📚 Found {len(response['files'])} results</b>" buttons = button_build.ButtonMaker() buttons.buildbutton("HERE", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else: return '', ''
def get_pages(self) -> dict: # get all our telegra.ph posts into a dict telegraph = Telegraph(access_token=access_token) return telegraph.get_page_list()
with open('authorized_chats.txt', 'r+') as f: lines = f.readlines() for line in lines: AUTHORIZED_CHATS.add(int(line.split()[0])) try: BOT_TOKEN = getConfig('BOT_TOKEN') OWNER_ID = int(getConfig('OWNER_ID')) except KeyError as e: LOGGER.error("One or more env variables missing! Exiting now") exit(1) #Generate Telegraph Token sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8)) LOGGER.info("Generating Telegraph Token using '" + sname + "' name") telegraph = Telegraph() telegraph.create_account(short_name=sname) telegraph_token = telegraph.get_access_token() LOGGER.info("Telegraph Token Generated: '" + telegraph_token + "'") DRIVE_NAME = [] DRIVE_ID = [] INDEX_URL = [] if os.path.exists('drive_folder'): with open('drive_folder', 'r+') as f: lines = f.readlines() for line in lines: temp = line.strip().split() DRIVE_NAME.append(temp[0].replace("_", " ")) DRIVE_ID.append(temp[1])
def get_count_pages() -> int: return Telegraph(access_token).get_page_list()["total_count"]
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list( supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='name asc').execute() content_count = 0 if not response["files"]: return '', '' msg += f'<h4>{len(response["files"])} Results: {fileName}</h4><br><br>' for file in response.get('files', []): if file.get( 'mimeType' ) == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"📁 <code>{file.get('name')}<br>(folder)</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' elif file.get( 'mimeType') == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"📄 <code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}' urls = f'{INDEX_URL}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' if VIEW_LINK: siurls = short_url(urls) msg += f' <b>| <a href="{siurls}">View Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' if VIEW_LINK: msg += f' <b>| <a href="{urls}">View Link</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT: self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found ❌", None for content in self.telegraph_content: self.path.append( Telegraph(access_token=telegraph_token).create_page( title='Slam Mirrorbot Search', author_name='Slam Mirrorbot', author_url='https://github.com/SlamDevs/slam-mirrorbot', html_content=content)['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>Found <code>{len(response['files'])}</code> results for <code>{fileName}</code></b>" buttons = button_build.ButtonMaker() buttons.buildbutton("🔎 VIEW", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1))
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list( supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='modifiedTime desc').execute() content_count = 0 if response["files"]: msg += f'<h4>Sᴇᴀʀᴄʜ Rᴇsᴜʟᴛs Fᴏʀ Yᴏᴜʀ Kᴇʏᴡᴏʀᴅ : {fileName}</h4><br>Tᴇʟᴇɢʀᴀᴍ @ANIMATED_CLOUDZONE<br><br>' for file in response.get('files', []): if file.get( 'mimeType' ) == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"➼<code>{file.get('name')}<br>[Fᴏʟᴅᴇʀ🗃️]</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get( 'https://{}/api?api={}&url={}&format=text'.format( SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>☄️G-Dʀɪᴠᴇ Lɪɴᴋ☄️</a></b>" else: msg += f"<b><a href={furl}>☄️G-Dʀɪᴠᴇ Lɪɴᴋ☄️</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}/') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get( 'https://{}/api?api={}&url={}&format=text'. format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>|| <a href="{siurl}">🌋Iɴᴅᴇx Lɪɴᴋ🌋</a></b>' else: msg += f' <b>|| <a href="{url}">🌋Iɴᴅᴇx Lɪɴᴋ🌋</a></b>' else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"➼<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})🌀</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = requests.get( 'https://{}/api?api={}&url={}&format=text'.format( SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>☄️G-Dʀɪᴠᴇ Lɪɴᴋ☄️</a></b>" else: msg += f"<b><a href={furl}>☄️G-Dʀɪᴠᴇ Lɪɴᴋ☄️</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get( 'https://{}/api?api={}&url={}&format=text'. format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>|| <a href="{siurl}">🌋Iɴᴅᴇx Lɪɴᴋ🌋</a></b>' else: msg += f' <b>|| <a href="{url}">🌋Iɴᴅᴇx Lɪɴᴋ🌋</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT: self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found :(", None for content in self.telegraph_content: self.path.append( Telegraph(access_token=telegraph_token).create_page( title='Aɴɪᴍᴀᴛᴇᴅ Sᴇᴀʀᴄʜ Iɴᴅᴇx', author_name='Aɴɪᴍᴀᴛᴇᴅ', author_url='https://t.me/ANIMATED_CLOUDZONE', html_content=content)['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>Sᴇᴀʀᴄʜ Rᴇsᴜʟᴛs Fᴏʀ Yᴏᴜʀ Kᴇʏᴡᴏʀᴅ : ➼ {fileName} 👇</b>" buttons = button_build.ButtonMaker() buttons.buildbutton("☘️ 𝐂𝐥𝐢𝐜𝐤 𝐇𝐞𝐫𝐞😋", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else: return '', ''