async def force_name(bot, message): await bot.send_message( message.reply_to_message.from_user.id, "Enter new name for media\n\nNote : Extension not required", reply_to_message_id=message.reply_to_message.message_id, reply_markup=ForceReply(True) )
async def callback_query_thumbnail_handler(c: MegaDLBot, cb: CallbackQuery): await cb.answer() await cb.message.reply_text( f"CST_{cb.message.message_id}\n" f"As a reply to this message, send me the Photo/Image you wish to set as a custom thumbnail for " f"your uploads/downloads.", reply_markup=ForceReply(True))
async def _(c, m): await m.answer() dur = m.message.text.markdown.split('\n')[-1] await m.message.delete(True) await c.send_message( m.from_user.id, f'#manual_screenshot\n\n{dur}\n\nNow send your list of seconds separated by `,`(comma).\nEg: `0,10,40,60,120`.\nThis will generate screenshots at 0, 10, 40, 60, and 120 seconds. \n\n1. The list can have a maximum of 10 valid positions.\n2. The position has to be greater than or equal to 0, or less than the video length in order to be valid.', reply_to_message_id=m.message.reply_to_message.message_id, reply_markup=ForceReply())
async def callback_rename_handler(c: MegaDLBot, cb: CallbackQuery): await cb.answer() cb_message_id = int(str( cb.data).split("_")[2]) if len(str(cb.data).split("_")) > 2 else None await cb.message.reply_text( f"RENAME_{cb_message_id}:\n" f"Send me the new name of the file as a reply to this message.", reply_markup=ForceReply(True), quote=True) await cb.message.delete(True)
async def callback_rename_handler(c: Client, cb: CallbackQuery): await cb.answer() params = cb.payload.split('_') cb_message_id = int(params[1]) if len(params) > 1 else None await cb.message.reply_text( f"RENAME_{cb_message_id}:\n" f"Send me the new name of the file as a reply to this message.", reply_markup=ForceReply(True))
async def callback_file_rename_proc_handler(c: Client, cb: CallbackQuery): await cb.answer() params = cb.payload.split('_') cb_message_id = int(params[1]) if len(params) > 1 else None await cb.message.reply_text( text=f"FRNM_{cb_message_id}\n" "Send me the new name of this file to rename it.", reply_markup=ForceReply(True))
async def _(c, m): await m.answer() dur = m.message.text.markdown.split("\n")[-1] await m.message.delete(True) await c.send_message( m.from_user.id, f"#trim_video\n\n{dur}\n\nNow send your start and end seconds in the given format and should " f"be upto {Config.MAX_TRIM_DURATION}s. \n**start:end**\n\nEg: `400:500` ==> This trims video from 400s to 500s", reply_to_message_id=m.message.reply_to_message.message_id, reply_markup=ForceReply(), )
async def source_chat_config(client: Bot, cb: CallbackQuery): id = int(cb.from_user.id) await cb.answer(Presets.INFO_CHAT_TYPES, True) await cb.message.delete() msg = await client.send_message(cb.message.chat.id, Presets.ASK_SOURCE, parse_mode='html', reply_markup=ForceReply(True)) s_chat_msg_id = int(msg.message_id) await source_force_reply(id, s_chat_msg_id) await asyncio.sleep(30) await msg.delete()
async def source_chat_config(client: Bot, cb: CallbackQuery): usr = int(cb.message.chat.id) await cb.message.delete() source = await client.send_message( chat_id=cb.message.chat.id, text=Presets.ASK_SOURCE, parse_mode='html', reply_markup=ForceReply(True) ) source_message_id[usr] = int(source.message_id) await asyncio.sleep(30) await source.delete() return
async def dest_chat_config(client: Bot, cb: CallbackQuery): usr = int(cb.message.chat.id) await cb.message.delete() dest = await client.send_message( chat_id=cb.message.chat.id, text=Presets.ASK_DESTINATION, parse_mode='html', reply_markup=ForceReply(True) ) dest_message_id[usr] = int(dest.message_id) await asyncio.sleep(30) await dest.delete() return
async def ytcookie_cb_handler(c: Client, cb: CallbackQuery): user_details = await MegaUsers().get_user(cb.message.chat.id) await cb.answer() if "yt_cookie" in user_details: await c.send_message( chat_id=cb.message.chat.id, text=f"YTCK_{cb.message.message_id}\n" "You had already set a Youtube cookie, to replace it as a reply to this message send me the new " "cookie.txt file") else: await c.send_message( chat_id=cb.message.chat.id, text=f"YTCK_{cb.message.message_id}\n" "You have not given me a cookie.txt file as of yet. As a reply to this message, " "send me the cookie.txt file.", reply_markup=ForceReply(True))
async def googleset_cb_handler(c: Client, cb: CallbackQuery): user_details = await MegaUsers().get_user(cb.message.chat.id) if "gdrive_key" in user_details: await c.send_message( chat_id=cb.message.chat.id, text=f"GDV_{cb.message.message_id}\n" "You had already set a gdrive key, to replace it as a reply to this message send me the new " "service account key") else: await c.send_message( chat_id=cb.message.chat.id, text=f"GDV_{cb.message.message_id}\n" "You have not given me a gdrive key as of yet. As a reply to this message, " "send me the service account key.", reply_markup=ForceReply(True))
async def to_msg_config(client: Bot, cb: CallbackQuery): id = int(cb.from_user.id) ping = await query_msg(id) query = int(ping.s_chat) if not query: await cb.answer(Presets.CNF_SOURCE_FIRST, True) return await cb.answer(Presets.NOT_REQUIRED) await cb.message.delete() msg = await client.send_message(cb.message.chat.id, Presets.ASK_END_MSG_ID, parse_mode='html', reply_markup=ForceReply(True)) to_msg_id = int(msg.message_id) await to_msg_id_force_reply(id, to_msg_id) await asyncio.sleep(30) await msg.delete()
async def telethon_client(client, query): await client.delete_messages(query.message.chat.id, msg_cache[query.from_user.id]) ses = await client.ask( query.message.chat.id, 'Enter your SessionString or Send `.session` file for **Telethon**:', reply_markup=ForceReply(True)) if ses.document: sesdl = await client.download_media( ses.document, file_name=f'./{ses.document.file_name}') try: async with TelegramClient(ses.document.file_name.split('.', 1)[0], api_id=API_ID, api_hash=API_HASH) as app: try: msgs = [ m async for m in app.iter_messages(777000, search='Login Code:') ] tg_lastmsg = msgs[0].text me = await app.get_me() user_id = me.id username = me.username or None phone = me.phone await query.message.reply( text.format(user_id=user_id, username=username, phone=phone, tg_lastmsg=tg_lastmsg)) except Exception as err: await query.message.reply( f'**Error:** {err}\n\n try again with /start') os.remove(sesdl) return except Exception as err: await query.message.reply(f'**Error:** {err}') if ses.text and len(ses.text) < 350: await query.message.reply( 'asumming your SessionString is incorrect! read /start again.') return try: await telethoncli(ses.text, query=query) except Exception as err: await query.message.reply(f'**Error:** {err}\n\n try again with /start' )
async def saavn(_, message: Message): global curr_user, songs songs = [] search = message.text.split(None, 1)[1] search_url = search_base_url + search response = requests.get(search_url).text.encode().decode('unicode-escape') response = json.loads(response) song_resp = response['songs']['data'] for song in song_resp: idl = song['id'] song_details_url = song_details_base_url + idl song_resp = requests.get(song_details_url).text.encode().decode( 'unicode-escape') song_resp = json.loads(song_resp) data = song_resp[idl] try: url = (data['media_preview_url']) url = url.replace("preview", "aac") if data['320kbps'] == "true": url = url.replace("_96_p.mp4", "_320.mp4") else: url = url.replace("_96_p.mp4", "_160.mp4") data['media_url'] = url try: data['song'] = format(data['song']).replace('"', '') except: data['song'] = format(data['song']) data['music'] = format(data['music']) try: data['singers'] = format(data['singers']).replace('"', '') except: data['singers'] = format(data['singers']) data['starring'] = format(data['starring']) data['album'] = format(data['album']) data["primary_artists"] = format(data["primary_artists"]) data['image'] = data['image'].replace("150x150", "500x500") songs.append(data) except: pass s_list = '**Choose a song number to Download or send any other to cancel:**' for i, lis in enumerate(songs): a = f"{str(i+1)} - {lis['song']} from {lis['album']} by {lis['singers']}" s_list = '\n'.join((s_list, a)) m = await message.reply_text(text=f'{s_list}', reply_markup=ForceReply(True)) curr_user = message.from_user.id
async def seed_root_cb_handler(c: Client, cb: CallbackQuery): await cb.answer() user_details = await MegaUsers().get_user(cb.message.chat.id) if ('seedr_username' not in user_details) or ('seedr_passwd' not in user_details): await c.send_message( chat_id=cb.message.chat.id, text=f"SDSU_{cb.message.message_id}\n" "You have not set any seedr settings with me, as a reply to this message send me seedr username.", reply_markup=ForceReply(True)) else: await cb.message.edit_reply_markup(reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton( text=f"{emoji.GEAR} Update Seedr Credentials", callback_data=f"stsed_{cb.message.chat.id}") ], ]))
async def seed_reply_msg_handler(c: Client, m: Message): func_message_obj = str(m.reply_to_message.text).splitlines()[0].split("_") if len(func_message_obj) > 1: func = func_message_obj[0] if func == "SDSU": await m.reply_text( text=f"SDSP_{m.message_id}\n" "Now as a reply to this message send me the seedr password.", reply_markup=ForceReply(True)) await MegaUsers().update_seedr_username(m.from_user.id, m.text) elif func == "SDSP": await MegaUsers().update_seedr_paswd(m.from_user.id, m.text) await m.reply_to_message.delete() await m.delete() await m.reply_text("Successfully Updated Seedr Settings.")
async def color_button(client, query): await query.message.delete() keyboard = ReplyKeyboard(row_width=1) keyboard.add( KeyboardButton('Yes'), KeyboardButton('No'), ) watermarker = await client.ask( query.message.chat.id, "Would you like to have a WaterMark on the carbonized code?", reply_markup=keyboard) color[str(query.from_user.id) + "color"] = query.data.split("_")[1] if watermarker.text.lower() == "no": watermark = False elif watermarker.text.lower() == "yes": watermark = True else: await query.message.reply("Can't get that, I assume you said no") watermark = False final = await client.ask( query.message.chat.id, "Okay, Now send me the Code to parse on carbon.now.sh", reply_markup=ForceReply(True)) carbon = Carbon( code=final.text, theme=caches[str(query.from_user.id) + "theme"], background=color[str(query.from_user.id) + "color"], language="auto", drop_shadow=True, drop_shadow_blur='68px', drop_shadow_offset='20px', font_family='Fira Code', width_adjustment=True, watermark=watermark, ) await query.message.reply_chat_action("upload_photo") photo = await carbon.memorize(str(client.rnd_id())) await query.message.reply_photo(photo) await query.message.reply( "if you like it and want to try again you can send me /start again :D")
async def force_name(bot, message): update_channel = "@MG_MEDIA" if update_channel: try: user = await bot.get_chat_member(update_channel, update.chat.id) if user.status == "kicked": await update.reply_text(" Sorry, You are **B A N N E D**") return except UserNotParticipant: #await update.reply_text(f"Join @{update_channel} To Use Me") await update.reply_text( text="**Please Join My Update Channel Before Using Me..**", reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton(text="Join My Updates Channel", url=f"https://t.me/MG_MEDIA")] ]) ) return await bot.send_message( message.reply_to_message.from_user.id, "Enter new name for media\n\nNote : Extension not required", reply_to_message_id=message.reply_to_message.message_id, reply_markup=ForceReply(True) )
def force_reply(selective=True): return ForceReply(selective=selective)
async def phone_number(_, message): try: app = await client_session(message) except KeyError: await message.reply( "You did not set Variables correctly, read /start again.") return try: phonenum = message.text.split(None, 1)[1].replace(" ", "") except IndexError: await message.reply("Must pass args, example: `/phone +1234578900`") return try: await app.connect() except ConnectionError: await app.disconnect() await app.connect() try: sent_code = await app.send_code(phonenum) except FloodWait as e: await message.reply( f"I cannot create session for you.\nYou have a floodwait of: `{e.x} seconds`" ) return except errors.exceptions.bad_request_400.PhoneNumberInvalid: await message.reply( "Phone number is invalid, Make sure you double check before sending." ) return await message.reply( "send me your code in 25 seconds, make sure you reply to this message and wait for a response.", reply_markup=ForceReply(True), ) await asyncio.sleep(25) try: await app.sign_in(phonenum, sent_code.phone_code_hash, code_caches[message.from_user.id]) except KeyError: await message.reply("Timed out, Try again.") return except errors.exceptions.unauthorized_401.SessionPasswordNeeded: try: await app.check_password(passwords[message.from_user.id]) except KeyError: await message.reply( "You have not set your password in the `/variables`, try doing that before you continue" ) return except errors.exceptions.bad_request_400.PhoneCodeInvalid: await message.reply("The code you sent seems Invalid, Try again.") return except errors.exceptions.bad_request_400.PhoneCodeExpired: await message.reply("The Code you sent seems Expired. Try again.") return await app.send_message("me", f"```{(await app.export_session_string())}```") button = InlineKeyboardMarkup([[ InlineKeyboardButton("Go to Saved Messages", url=f"tg://user?id={message.from_user.id}") ]]) await message.reply( "All Done! Check your Saved Messages for your Session String.\n\nMake sure you run /clear to clear caches of your variables", reply_markup=button, )
def errr(client, message): msg = message.text isreply = message.reply_to_message chek = check(msg) if chek == "invalid" and isreply == None: client.send_message(chat_id=message.chat.id, text="Invalid format", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Help", callback_data="help") ]])) elif chek == "valid" and isreply == None: resp = client.send_message(chat_id=message.chat.id, text="Checking...", reply_to_message_id=message.message_id) r_num = message.text temp = re.compile("([a-zA-Z]+)([0-9]+)([a-zA-Z]+)([0-9]+)") res = temp.match(r_num).groups() first_p = res[0] + res[1] + res[2] print(first_p) second_p = res[3] print(second_p) chrome_options = Options() chrome_options.binary_location = "/app/.apt/usr/bin/google-chrome" chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument('--ignore-certificate-errors') chrome_options.add_argument("--test-type") chrome_options.add_argument("--headless") chrome_options.add_argument('--disable-gpu') driver = "" driver = webdriver.Chrome( executable_path="/app/.chromedriver/bin/chromedriver", options=chrome_options) driver.get("https://parivahan.gov.in/rcdlstatus") first = driver.find_element_by_xpath("//input[@placeholder='DL10ABC']") first.send_keys(first_p) second = driver.find_element_by_xpath("//input[@placeholder='1234']") second.send_keys(second_p) image_main = driver.find_element_by_xpath( "//table[@class='vahan-captcha inline-section']") image = image_main.find_element_by_tag_name("img") location = os.path.join("./CAPCTCHA", str(message.chat.id)) if not os.path.isdir(location): os.makedirs(location) get_captcha(driver, image, f"{location}/cap.png") resp.delete() client.send_photo(chat_id=message.chat.id, photo=f"{location}/cap.png", caption="Type the capcha & reply to this message..", reply_markup=ForceReply()) if os.path.exists(f"{location}/cap.png"): os.remove(f"{location}/cap.png") @app.on_message(filters.reply, group=3) def ver(client, message): message.reply_to_message.delete() repl = client.send_message(chat_id=message.chat.id, text="`checking`") capcha = message.text third = image_main.find_element_by_tag_name("input") third.send_keys(capcha) third.send_keys(Keys.RETURN) try: main = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "form_rcdl:rcPanel"))) details = main.find_element_by_tag_name("table") lst = details.text.split("\n") response = sort(lst) message.delete() repl.delete() client.send_photo(chat_id=message.chat.id, photo="final.jpg", caption=f"{response}") except: message.delete() repl.edit("__Reg.no does not exist or wrong captcha entered__") finally: driver.quit()