async def webss(url): start_time = time() if "." not in url: return screenshot = await fetch(f"https://patheticprogrammers.cf/ss?site={url}") end_time = time() a = [] pic = InlineQueryResultPhoto( photo_url=screenshot['url'], caption=(f"`{url}`\n__Took {round(end_time - start_time)} Seconds.__")) a.append(pic) return a
async def wall_func(answers, text): results = await arq.wall(text) if not results.ok: answers.append( InlineQueryResultArticle( title="Error", description=results.result, input_message_content=InputTextMessageContent(results.result), ) ) return answers limit = 0 results = results.result for i in results: if limit > 48: break limit += 1 answers.append( InlineQueryResultPhoto( photo_url=i.url_image, thumb_url=i.url_thumb, caption=f"[Source]({i.url_image})", ) ) return answers
async def image_func(answers, query): results = await arq.image(query) if not results.ok: answers.append( InlineQueryResultArticle( title="Error", description=results.result, input_message_content=InputTextMessageContent(results.result), ) ) return answers results = results.result[0:48] buttons = InlineKeyboard(row_width=2) buttons.add( InlineKeyboardButton( text="Search again", switch_inline_query_current_chat="image" ), ) for i in results: answers.append( InlineQueryResultPhoto( title=i.title, photo_url=i.url, thumb_url=i.url, reply_markup=buttons, ) ) return answers
async def github_user_func(answers, text): URL = f"https://api.github.com/users/{text}" result = await fetch(URL) buttons = InlineKeyboard(row_width=1) buttons.add( InlineKeyboardButton( text="Open On Github", url=f"https://github.com/{text}" ) ) caption = f""" **Info Of {result['name']}** **Username:** `{text}` **Bio:** `{result['bio']}` **Profile Link:** [Here]({result['html_url']}) **Company:** `{result['company']}` **Created On:** `{result['created_at']}` **Repositories:** `{result['public_repos']}` **Blog:** `{result['blog']}` **Location:** `{result['location']}` **Followers:** `{result['followers']}` **Following:** `{result['following']}`""" answers.append( InlineQueryResultPhoto( photo_url=result["avatar_url"], caption=caption, reply_markup=buttons, ) ) return answers
async def pokedexinfo(answers, pokemon): Pokemon = f"https://some-random-api.ml/pokedex?pokemon={pokemon}" result = await fetch(Pokemon) buttons = InlineKeyboard(row_width=1) buttons.add( InlineKeyboardButton("Pokedex", switch_inline_query_current_chat="pokedex")) caption = f""" **Pokemon:** `{result['name']}` **Pokedex:** `{result['id']}` **Type:** `{result['type']}` **Abilities:** `{result['abilities']}` **Height:** `{result['height']}` **Weight:** `{result['weight']}` **Gender:** `{result['gender']}` **Stats:** `{result['stats']}` **Description:** `{result['description']}`""" answers.append( InlineQueryResultPhoto( photo_url=f"https://img.pokemondb.net/artwork/large/{pokemon}.jpg", title=result["name"], description=result["description"], caption=caption, reply_markup=buttons, )) return answers
async def nhentai_inline(bot: Amime, inline_query: InlineQuery): query = inline_query.matches[0]["query"].strip() lang = inline_query._lang results: List[InlineQueryResultPhoto] = [] if query.isdecimal(): search_results = [await get_data(int(query))] else: search_results = [ *filter(lambda manga: query.lower() in manga.title.lower(), await nHentai.all()) ] for manga in search_results: if manga is None: continue if len(results) >= 15: break text = f"<b>{manga.title}</b>" text += f"\n\n<b>ID</b>: <code>{manga.id}</code> (<b>NHENTAI</b>)" text += f"\n<b>{lang.artist}</b>: <a href=\"https://nhentai.net/artist/{manga.artist.replace(' ', '-')}/\">{manga.artist}</a>" tags = [ f"<a href=\"https://nhentai.net/tag/{tag.replace(' ', '-')}/\">{tag}</a>" for tag in manga.tags.split(", ") ] text += f"\n<b>{lang.tags}</b>: {', '.join(tags)}" text += f"\n<b>{lang.page}s</b>: <code>{manga.pages}</code>" results.append( InlineQueryResultPhoto( photo_url=manga.photo, title=manga.title, description=manga.tags, caption=text, reply_markup=ikb([[ ( "👠nHentai", f"https://nhentai.net/g/{manga.id}", "url", ), (lang.read_button, manga.url, "url"), ]]), )) if len(results) > 0: try: await inline_query.answer( results=results, is_gallery=False, cache_time=3, ) except QueryIdInvalid: pass
async def anilist_query(client, inline_query): if inline_query.from_user.id not in app_user_ids: await inline_query.answer([ InlineQueryResultArticle('...no', InputTextMessageContent('...no')) ], cache_time=3600, is_personal=True) return character = bool(inline_query.matches[0].group(1)) query = inline_query.matches[0].group(2).strip().lower() async with anilists_lock: if (character, query) not in all_anilists: async with session.post( 'https://graphql.anilist.co', data=json.dumps({ 'query': CHARACTER_QUERY if character else MEDIA_QUERY, 'variables': { 'search': query } }), headers={ 'Content-Type': 'application/json', 'Accept': 'application/json' }) as resp: all_anilists[(character, query)] = (await resp.json( ))['data']['Page']['characters' if character else 'media'] anilists = all_anilists[(character, query)] answers = [] parser = pyrogram_html.HTML(client) for a, anilist in enumerate(anilists): text, image = await (generate_character if character else generate_media)(anilist) buttons = [ InlineKeyboardButton('Back', 'anilist_back'), InlineKeyboardButton(f'{a + 1}/{len(anilists)}', 'anilist_nop'), InlineKeyboardButton('Next', 'anilist_next') ] if not a: buttons.pop(0) if len(anilists) == a + 1: buttons.pop() split = text.split('\n', 1) title = (await parser.parse(split[0]))['message'] try: description = (await parser.parse(split[1]))['message'] except IndexError: description = None answers.append( InlineQueryResultPhoto(image, title=title, description=description, caption=text, reply_markup=InlineKeyboardMarkup([buttons ]), id=f'anilist{a}-{time.time()}')) await inline_query.answer(answers, is_personal=True, is_gallery=False)
async def wall_func(answers, text): results = await arq.wall(text) for i in results: try: answers.append( InlineQueryResultPhoto( photo_url=results[i].url_image, thumb_url=results[i].url_thumb, caption=f"[Source]({results[i].url_image})")) except KeyError: pass return answers
async def webss(url): start_time = time() if "." not in url: return screenshot = await fetch(f"https://patheticprogrammers.cf/ss?site={url}") end_time = time() # m = await app.send_photo(LOG_GROUP_ID, photo=screenshot["url"]) await m.delete() a = [] pic = InlineQueryResultPhoto( photo_url=screenshot["url"], caption=(f"`{url}`\n__Took {round(end_time - start_time)} Seconds.__"), ) a.append(pic) return a
async def lyciachatbot(answers, text): URL = f"https://api.affiliateplus.xyz/api/chatbot?message={text}&botname=@Lyciachatbot&ownername=@madepranav" result = await fetch(URL) buttons = InlineKeyboard(row_width=1) buttons.add( InlineKeyboardButton("Lycia", switch_inline_query_current_chat="lycia")) caption = f""" **You:** `{text}` **Lycia:** `{result['message']}`""" answers.append( InlineQueryResultPhoto( photo_url="https://telegra.ph/file/4fd47f6ab742a28b5e57c.jpg", caption=caption, reply_markup=buttons)) return answers
async def pastebin_func(answers, link): link = link.split("/") if link[3] == "c": chat, message_id = int("-100" + link[4]), int(link[5]) else: chat, message_id = link[3], link[4] m = await app.get_messages(chat, message_ids=int(message_id)) if not m.text and not m.document: m = await app2.get_messages(chat, message_ids=int(message_id)) if m.text: content = m.text else: if m.document.file_size > 1048576: answers.append( InlineQueryResultArticle( title="DOCUMENT TOO BIG", description="Maximum supported size is 1MB", input_message_content=InputTextMessageContent( "DOCUMENT TOO BIG") ) ) return answers doc = await m.download() async with aiofiles.open(doc, mode="r") as f: content = await f.read() os.remove(doc) link = await paste(content) preview = link + "/preview.png" status_code = await get_http_status_code(preview) i = 0 while status_code != 200: if i == 5: break status_code = await get_http_status_code(preview) await asyncio.sleep(0.2) i += 1 await app.send_photo(MESSAGE_DUMP_CHAT, preview) # To Pre-cache the media buttons = InlineKeyboard(row_width=1) buttons.add(InlineKeyboardButton(text="Paste Link", url=link)) answers.append( InlineQueryResultPhoto( photo_url=preview, reply_markup=buttons ) ) return answers
async def inline(client, query): results = [] string = query.query.lower() if string == "": await query.answer( results=DEFAULT_RESULTS, cache_time=CACHE_TIME, switch_pm_text="How do I work", switch_pm_parameter="start", ) return else: image = Image(config.get('api', 'key')) image.search() ims = image.search(q=string.split()[1], lang='en', image_type='photo', orientation='horizontal', category=string.split()[0], safesearch='true', order='latest', page='backgrounds', per_page=50) for item in ims['hits']: picture_url = item["largeImageURL"] text = await text_parser(item) buttons = [[ InlineKeyboardButton('Link', url=f'{item["pageURL"]}'), InlineKeyboardButton( 'Author', url= f'https://pixabay.com/users/{item["user"]}-{item["user_id"]}/' ) ]] results.append( InlineQueryResultPhoto( photo_url=picture_url, title=f'Result:{item["id"]}', caption=text, description=f"Nothing", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=results, is_gallery=True, cache_time=CACHE_TIME) return
async def tmdb_func(answers, query): response = await arq.tmdb(query) if not response.ok: answers.append( InlineQueryResultArticle( title="Error", description=response.result, input_message_content=InputTextMessageContent(response.result), ) ) return answers results = response.result[:49] for result in results: if not result.poster and not result.backdrop: continue if not result.genre: genre = None else: genre = " | ".join(result.genre) description = result.overview[0:900] if result.overview else "None" caption = f""" **{result.title}** **Type:** {result.type} **Rating:** {result.rating} **Genre:** {genre} **Release Date:** {result.releaseDate} **Description:** __{description}__ """ buttons = InlineKeyboard(row_width=1) buttons.add( InlineKeyboardButton( "Search Again", switch_inline_query_current_chat="tmdb", ) ) answers.append( InlineQueryResultPhoto( photo_url=result.backdrop if result.backdrop else result.poster, caption=caption, title=result.title, description=f"{genre} • {result.releaseDate} • {result.rating} • {description}", reply_markup=buttons, ) ) return answers
async def in_h_lp(_, inline_query): keboard = InlineKeyboardMarkup( [[InlineKeyboardButton("Group Commands", callback_data="_admin_h")], [ InlineKeyboardButton("Util Plugins", callback_data="_util_h"), InlineKeyboardButton("ASSISTANT Manager", callback_data="_ast_h") ], [InlineKeyboardButton("OWNER Tools", callback_data="_own_h")], [InlineKeyboardButton("Close the menu", callback_data="kloz")]]) await inline_query.answer(results=[ InlineQueryResultPhoto( photo_url="https://telegra.ph/file/040062841c541079a538c.jpg", title="Help", caption= f"You are accessing help for **King Userbot** \n __Everyone is a king. Until the real king arrives.__", reply_markup=keboard, ), ])
async def deezer_func(answers, text): results = await arq.deezer(text, 5) for i in results: caption = f""" **Title:** {results[i].title} **Duration:** {results[i].duration} Seconds **Artist:** {results[i].artist} **Link:** [Here]({results[i].url})""" try: answers.append( InlineQueryResultPhoto( photo_url=results[i].thumbnail, caption=caption, )) except KeyError: pass return answers
async def saavn_func(answers, text): results = await arq.saavn(text) for i in results: caption = f""" **Title:** {results[i].song} **Album:** {results[i].album} **Duration:** {results[i].duration} Seconds **Release:** {results[i].year} **Singers:** {results[i].singers} **Link:** [Here]({results[i].media_url})""" try: answers.append( InlineQueryResultPhoto( photo_url=results[i].image, caption=caption, )) except KeyError: pass return answers
async def inline_answer(_, inline_query: InlineQuery): results = [] i_q = inline_query.query string = i_q.lower() # All lower str_x = i_q.split(" ", 2) # trigger @username Text str_y = i_q.split(" ", 1) # trigger and Text string_split = string.split() # All lower and Split each word if (inline_query.from_user.id in Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS): if string == "syntax": owner = [[ InlineKeyboardButton(text="Contact", url="https://t.me/deleteduser420") ]] results.append( InlineQueryResultPhoto( photo_url= "https://coverfiles.alphacoders.com/123/123388.png", caption="Hey I solved **𝚂𝚢𝚗𝚝𝚊𝚡's ░ Σrr♢r**", reply_markup=InlineKeyboardMarkup(owner), )) if string == "age_verification_alert": buttons = [[ InlineKeyboardButton( text="Yes I'm 18+", callback_data="age_verification_true"), InlineKeyboardButton( text="No I'm Not", callback_data="age_verification_false"), ]] results.append( InlineQueryResultPhoto( photo_url="https://i.imgur.com/Zg58iXc.jpg", caption="**ARE YOU OLD ENOUGH FOR THIS ?**", reply_markup=InlineKeyboardMarkup(buttons), )) if str_y[0] == "reddit": reddit_api = "https://meme-api.herokuapp.com/gimme/" if len(str_y) == 2: subreddit_regex = r"^([a-zA-Z]+)\.$" match = re.search(subreddit_regex, str_y[1]) if match: subreddit_name = match.group(1) reddit_api += f"{subreddit_name}/30" else: return else: reddit_api += "30" try: r = await get_response.json(reddit_api) except ValueError: results.append( InlineQueryResultArticle( title="Reddit Api is Down !", input_message_content=InputTextMessageContent( "**Error Code: Status != 200**"), thumb_url="https://i.imgur.com/7a7aPVa.png", )) else: if "code" in r: bool_is_gallery = False code = r["code"] code_message = r["message"] results.append( InlineQueryResultArticle( title=str(code), input_message_content=InputTextMessageContent( f"**Error Code: {code}**\n`{code_message}`" ), description="Enter A Valid Subreddit Name !", thumb_url="https://i.imgur.com/7a7aPVa.png", )) else: bool_is_gallery = True for post in r["memes"]: if "url" in post: postlink = post["postLink"] subreddit = post["subreddit"] title = post["title"] media_url = post["url"] author = post["author"] upvote = post["ups"] captionx = f"<b>{title}</b>\n" captionx += f"`Posted by u/{author}`\n" captionx += f"↕️ <code>{upvote}</code>\n" thumbnail = reddit_thumb_link(post["preview"]) if post["spoiler"]: captionx += "⚠️ Post marked as SPOILER\n" if post["nsfw"]: captionx += "🔞 Post marked Adult \n" buttons = [[ InlineKeyboardButton( f"Source: r/{subreddit}", url=postlink) ]] if media_url.endswith(".gif"): results.append( InlineQueryResultAnimation( animation_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup( buttons), )) else: results.append( InlineQueryResultPhoto( photo_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup( buttons), )) await inline_query.answer( results=results, cache_time=1, is_gallery=bool_is_gallery, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return # if string == "rick": # rick = [[InlineKeyboardButton(text="🔍", callback_data="mm")]] # results.append( # InlineQueryResultArticle( # title="Not a Rick Roll", # input_message_content=InputTextMessageContent("Search Results"), # description="Definately Not a Rick Roll", # thumb_url="https://i.imgur.com/hRCaKAy.png", # reply_markup=InlineKeyboardMarkup(rick), # ) # ) if string == "alive": buttons = [[ InlineKeyboardButton("🔧 SETTINGS", callback_data="settings_btn"), InlineKeyboardButton(text="⚡️ REPO", url=Config.UPSTREAM_REPO), ]] alive_info = f""" **[USERGE-X](https://telegram.dog/x_xtests) is Up and Running** • 🐍 Python : `v{versions.__python_version__}` • 🔥 Pyrogram : `v{versions.__pyro_version__}` • 🧬 𝑿 : `v{get_version()}` {_get_mode()} | 🕔: {userge.uptime} """ if not MEDIA_URL and Config.ALIVE_MEDIA: await get_alive_() if MEDIA_URL: if MEDIA_TYPE == "url_gif": results.append( InlineQueryResultAnimation( animation_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) elif MEDIA_TYPE == "url_image": results.append( InlineQueryResultPhoto( photo_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) elif MEDIA_TYPE == "tg_image": results.append( InlineQueryResultCachedPhoto( file_id=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) else: results.append( InlineQueryResultCachedDocument( title="USERGE-X", file_id=MEDIA_URL, caption=alive_info, description="ALIVE", reply_markup=InlineKeyboardMarkup(buttons), )) else: # default random_alive = random.choice(ALIVE_IMGS) results.append( InlineQueryResultPhoto( photo_url=random_alive, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) if string == "geass": results.append( InlineQueryResultAnimation( animation_url="https://i.imgur.com/DeZHcRK.gif", caption="To defeat evil, I must become a greater evil", )) if string == "gapps": buttons = [ [ InlineKeyboardButton("Open GApps", callback_data="open_gapps"), InlineKeyboardButton("Flame GApps", callback_data="flame_gapps"), ], [ InlineKeyboardButton("Nik GApps", callback_data="nik_gapps") ], ] results.append( InlineQueryResultArticle( title="GApps", input_message_content=InputTextMessageContent( "[\u200c](https://i.imgur.com/BZBMrfn.jpg) **LATEST Android 10 arm64 GApps**" ), description= "Get Latest GApps Download Links Directly from SF", thumb_url="https://i.imgur.com/Npzw8Ph.png", reply_markup=InlineKeyboardMarkup(buttons), )) if len(string_split) == 2 and (string_split[0] == "ofox"): codename = string_split[1] t = TelegraphPoster(use_api=True) t.create_api_token("Userge-X") photo = "https://i.imgur.com/582uaSk.png" api_host = "https://api.orangefox.download/v2/device/" try: cn = requests.get(f"{api_host}{codename}") r = cn.json() except ValueError: return s = requests.get( f"{api_host}{codename}/releases/stable/last").json() info = f"📱 **Device**: {r['fullname']}\n" info += f"👤 **Maintainer**: {r['maintainer']['name']}\n\n" recovery = f"🦊 <code>{s['file_name']}</code>\n" recovery += f"📅 {s['date']}\n" recovery += f"ℹ️ **Version:** {s['version']}\n" recovery += f"📌 **Build Type:** {s['build_type']}\n" recovery += f"🔰 **Size:** {s['size_human']}\n\n" recovery += "📍 **Changelog:**\n" recovery += f"<code>{s['changelog']}</code>\n\n" msg = info msg += recovery notes_ = s.get("notes") if notes_: notes = t.post(title="READ Notes", author="", text=notes_) buttons = [[ InlineKeyboardButton("🗒️ NOTES", url=notes["url"]), InlineKeyboardButton("⬇️ DOWNLOAD", url=s["url"]), ]] else: buttons = [[ InlineKeyboardButton(text="⬇️ DOWNLOAD", url=s["url"]) ]] results.append( InlineQueryResultPhoto( photo_url=photo, thumb_url="https://i.imgur.com/o0onLYB.jpg", title="Latest OFOX RECOVERY", description=f"For device : {codename}", caption=msg, reply_markup=InlineKeyboardMarkup(buttons), )) if string == "repo": results.append(REPO_X) if len(str_y) == 2 and str_y[0] == "anime": for i in await Anime.search(str_y[1]): results.append( InlineQueryResultArticle( title=i.get("title"), input_message_content=InputTextMessageContent( f'[\u200c]({i.get("image")})**{i.get("title")}**\n{i.get("release")}' ), description=i.get("release"), thumb_url=i.get("image"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="⬇️ Download", callback_data=f'get_eps{i.get("key")}', ) ]]), )) if len(results) != 0: await inline_query.answer( results=results[:50], cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if str_y[0] == "spoiler": if not os.path.exists("./userge/xcache/spoiler_db.json"): results.append( InlineQueryResultArticle( title="No Spoiler Found", input_message_content=InputTextMessageContent( "No Spoiler Found !\nLet's Add Some 😈"), description="See .help spoiler for more info", )) else: bot_name = (await userge.bot.get_me()).username if len(str_y) == 2: link = f"https://t.me/{bot_name}?start=spoiler_{str_y[1]}" buttons = [[ InlineKeyboardButton(text="View Spoiler", url=link) ]] results.append( InlineQueryResultArticle( title="Spoiler", input_message_content=InputTextMessageContent( "<b>Click To View The Spoiler !</b>"), description="Click To Send", thumb_url= "https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup(buttons), )) else: fo = open("./userge/xcache/spoiler_db.json") view_db = ujson.load(fo) fo.close() if len(view_db) != 0: for numm, spoilerr in enumerate(view_db, start=1): buttons = [[ InlineKeyboardButton( text="View Spoiler", url= f"https://t.me/{bot_name}?start=spoiler_{spoilerr}", ) ]] saved_at = view_db.get(spoilerr, None) savetime = (saved_at.get("savetime", None) if saved_at else None) results.append( InlineQueryResultArticle( title=f"#{numm} Spoiler", input_message_content= InputTextMessageContent( "<b>Click To View The Spoiler !</b>" ), description=f"Created At: {savetime}", thumb_url= "https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup( buttons), )) if str_x[0].lower() == "op" and len(str_x) > 1: txt = i_q[3:] opinion = os.path.join(PATH, "emoji_data.txt") if os.path.exists(opinion): with open(opinion) as fo: view_data = ujson.load(fo) # Uniquely identifies an inline message new_id = {int(inline_query.id): [{}]} view_data.update(new_id) else: view_data = {int(inline_query.id): [{}]} with open(opinion, "w") as outfile: ujson.dump(view_data, outfile) buttons = [[ InlineKeyboardButton( "👍", callback_data=f"op_y_{inline_query.id}"), InlineKeyboardButton( "👎", callback_data=f"op_n_{inline_query.id}"), ]] results.append( InlineQueryResultArticle( title="Ask For Opinion", input_message_content=InputTextMessageContent(txt), description=f"Q. {txt}", thumb_url="https://i.imgur.com/Zlc98qS.jpg", reply_markup=InlineKeyboardMarkup(buttons), )) if "btn_" in str_y[0] or str_y[0] == "btn": inline_db_path = "./userge/xcache/inline_db.json" if os.path.exists(inline_db_path): with open(inline_db_path, "r") as data_file: view_db = ujson.load(data_file) data_count_n = 1 reverse_list = list(view_db) reverse_list.reverse() for butt_ons in reverse_list: if data_count_n > 15: view_db.pop(butt_ons, None) data_count_n += 1 with open(inline_db_path, "w") as data_file: ujson.dump(view_db, data_file) if str_y[0] == "btn": inline_storage = list(view_db) else: rnd_id = (str_y[0].split("_", 1))[1] inline_storage = [rnd_id] if len(inline_storage) == 0: return for inline_content in inline_storage: inline_db = view_db.get(inline_content) if inline_db: if (inline_db["media_valid"] and int(inline_db["media_id"]) != 0): saved_msg = await userge.bot.get_messages( Config.LOG_CHANNEL_ID, int(inline_db["media_id"])) media_data = get_file_id(saved_msg) textx, buttonsx = pb(inline_db["msg_content"]) if inline_db["media_valid"]: if saved_msg.photo: results.append( InlineQueryResultCachedPhoto( file_id=media_data, caption=textx, reply_markup=buttonsx, )) else: results.append( InlineQueryResultCachedDocument( title=textx, file_id=media_data, caption=textx, description="Inline Button", reply_markup=buttonsx, )) else: results.append( InlineQueryResultArticle( title=textx, input_message_content= InputTextMessageContent(textx), reply_markup=buttonsx, )) if str_y[0].lower() == "stylish": if len(str_y) == 2: results = [] input_text = str_y[1] font_names = [ "serif", "sans", "sans_i", "serif_i", "medi_b", "medi", "double", "cursive_b", "cursive", "bigsmall", "reverse", "circle", "circle_b", "mono", "square_b", "square", "smoth", "goth", "wide", "web", "weeb", "weeeb", ] for f_name in font_names: styled_str = await font_gen(f_name, input_text) results.append( InlineQueryResultArticle( title=f_name.upper(), input_message_content=InputTextMessageContent( styled_str), description=styled_str, )) await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if str_x[0].lower() == "secret" and len(str_x) == 3: user_name = str_x[1] msg = str_x[2] try: a = await userge.get_users(user_name) user_id = a.id except BaseException: return secret = os.path.join(PATH, "secret.txt") if os.path.exists(secret): with open(secret) as outfile: view_data = ujson.load(outfile) # Uniquely identifies an inline message new_id = { str(inline_query.id): { "user_id": user_id, "msg": msg } } view_data.update(new_id) else: view_data = { str(inline_query.id): { "user_id": user_id, "msg": msg } } # Save with open(secret, "w") as r: ujson.dump(view_data, r) buttons = [[ InlineKeyboardButton( "🔐 SHOW", callback_data=f"secret_{inline_query.id}") ]] results.append( InlineQueryResultArticle( title="Send A Secret Message", input_message_content=InputTextMessageContent( f"📩 <b>Secret Msg</b> for {user_name}. Only he/she can open it." ), description=f"Send Secret Message to: {user_name}", thumb_url="https://i.imgur.com/c5pZebC.png", reply_markup=InlineKeyboardMarkup(buttons), )) if str_y[0].lower() == "ytdl" and len(str_y) == 2: link = get_yt_video_id(str_y[1]) found_ = True if link is None: search = VideosSearch(str_y[1], limit=15) resp = (search.result()).get("result") if len(resp) == 0: found_ = False else: outdata = await result_formatter(resp) key_ = rand_key() ytsearch_data.store_(key_, outdata) buttons = InlineKeyboardMarkup([ [ InlineKeyboardButton( text=f"1 / {len(outdata)}", callback_data=f"ytdl_next_{key_}_1", ) ], [ InlineKeyboardButton( text="📜 List all", callback_data=f"ytdl_listall_{key_}_1", ), InlineKeyboardButton( text="⬇️ Download", callback_data= f'ytdl_download_{outdata[1]["video_id"]}_0', ), ], ]) caption = outdata[1]["message"] photo = outdata[1]["thumb"] else: caption, buttons = await download_button(link, body=True) photo = await get_ytthumb(link) if found_: results.append( InlineQueryResultPhoto( photo_url=photo, title=link, description="⬇️ Click to Download", caption=caption, reply_markup=buttons, )) else: results.append( InlineQueryResultArticle( title="not Found", input_message_content=InputTextMessageContent( f"No Results found for `{str_y[1]}`"), description="INVALID", )) MAIN_MENU = InlineQueryResultArticle( title="Main Menu", input_message_content=InputTextMessageContent( " 𝐔𝐒𝐄𝐑𝐆𝐄-𝐗 𝗠𝗔𝗜𝗡 𝗠𝗘𝗡𝗨 "), url="https://github.com/code-rgb/USERGE-X", description="Userge-X Main Menu", thumb_url="https://i.imgur.com/1xsOo9o.png", reply_markup=InlineKeyboardMarkup(main_menu_buttons()), ) results.append(MAIN_MENU) if len(results) != 0: await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) else: results.append(REPO_X) owner_name = (await userge.get_me()).first_name await inline_query.answer( results=results, cache_time=1, switch_pm_text=f"This bot is only for {owner_name}", switch_pm_parameter="start", )
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id not in AdminSettings: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown") return if string == "": await client.answer_inline_query( query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline") return # Notes if string.split()[0] == "note": if not DB_AVAILABLE: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Your database isn't avaiable!", switch_pm_parameter="help_inline") return if len(string.split()) == 1: allnotes = notes_db.get_all_selfnotes_inline(query.from_user.id) if not allnotes: await client.answer_inline_query( query.id, results=answers, switch_pm_text="You dont have any notes!", switch_pm_parameter="help_inline") return if len(list(allnotes)) >= 30: rng = 30 else: rng = len(list(allnotes)) for x in range(rng): note = allnotes[list(allnotes)[x]] noteval = note["value"] notetype = note["type"] # notefile = note["file"] if notetype != Types.TEXT: continue note, button = parse_button(noteval) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(list(allnotes)[x]), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Yourself notes", switch_pm_parameter="help_inline") return q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help_inline") return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(notetag), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query(query.id, results=answers, cache_time=5) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[ InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors") ]]) text = "An error has accured!\n\n```{}```\n".format( "".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return # Stylish converter elif string.split()[0] == "stylish": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Insert any text to convert it!", switch_pm_parameter="help_inline") return text = string.split(None, 1)[1] upside = upsidedown_text_inline(text) answers.append( InlineQueryResultArticle( title=upside, description="Upside-down Text", input_message_content=InputTextMessageContent(upside))) over = text_style_generator(text, CHAR_OVER) answers.append( InlineQueryResultArticle( title=over, description="Overline Text", input_message_content=InputTextMessageContent(over))) under = text_style_generator(text, CHAR_UNDER) answers.append( InlineQueryResultArticle( title=under, description="Underline Text", input_message_content=InputTextMessageContent(under))) strike = text_style_generator(text, CHAR_STRIKE) answers.append( InlineQueryResultArticle( title=strike, description="Strike Text", input_message_content=InputTextMessageContent(strike))) points = text_style_generator(text, CHAR_POINTS) answers.append( InlineQueryResultArticle( title=points, description="Points Text", input_message_content=InputTextMessageContent(points))) smallcaps_conv = formatting_text_inline(text, smallcaps) answers.append( InlineQueryResultArticle( title=smallcaps_conv, description="Smallcaps Text", input_message_content=InputTextMessageContent(smallcaps_conv))) super_script = formatting_text_inline(text, superscript) answers.append( InlineQueryResultArticle( title=super_script, description="Superscript Text", input_message_content=InputTextMessageContent(super_script))) sub_script = formatting_text_inline(text, subscript) answers.append( InlineQueryResultArticle( title=sub_script, description="Subscript Text", input_message_content=InputTextMessageContent(sub_script))) wide_text = formatting_text_inline(text, wide) answers.append( InlineQueryResultArticle( title=wide_text, description="Wide Text", input_message_content=InputTextMessageContent(wide_text))) bubbles_text = formatting_text_inline(text, bubbles) answers.append( InlineQueryResultArticle( title=bubbles_text, description="Bubbles Text", input_message_content=InputTextMessageContent(bubbles_text))) bubblesblack_text = formatting_text_inline(text, bubblesblack) answers.append( InlineQueryResultArticle( title=bubblesblack_text, description="Bubbles Black Text", input_message_content=InputTextMessageContent( bubblesblack_text))) smoth_text = formatting_text_inline(text, smothtext) answers.append( InlineQueryResultArticle( title=smoth_text, description="Smoth Text", input_message_content=InputTextMessageContent(smoth_text))) graffiti_text = formatting_text_inline(text, graffiti) answers.append( InlineQueryResultArticle( title=graffiti_text, description="Graffiti Text", input_message_content=InputTextMessageContent(graffiti_text))) graffitib_text = formatting_text_inline(text, graffitib) answers.append( InlineQueryResultArticle( title=graffitib_text, description="Graffiti Bold Text", input_message_content=InputTextMessageContent(graffitib_text))) handwriting_text = formatting_text_inline(text, handwriting) answers.append( InlineQueryResultArticle( title=handwriting_text, description="Handwriting Text", input_message_content=InputTextMessageContent( handwriting_text))) handwritingb_text = formatting_text_inline(text, handwritingb) answers.append( InlineQueryResultArticle( title=handwritingb_text, description="Handwriting Bold Text", input_message_content=InputTextMessageContent( handwritingb_text))) await client.answer_inline_query( query.id, results=answers, switch_pm_text="Converted to stylish text", switch_pm_parameter="help_inline") # PM_PERMIT elif string.split()[0] == "engine_pm": button = [[ InlineKeyboardButton("Ask for Money", callback_data="engine_pm_block"), InlineKeyboardButton("Contact me", callback_data="engine_pm_nope") ], [ InlineKeyboardButton("Report", callback_data="engine_pm_report"), InlineKeyboardButton("Passing by", callback_data="engine_pm_none") ]] random.shuffle(button) answers.append( InlineQueryResultArticle( title="Engine pm", description="Filter pm", input_message_content=InputTextMessageContent( welc_txt, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "speedtest": buttons = [[ InlineKeyboardButton("Image", callback_data="speedtest_image"), InlineKeyboardButton("Text", callback_data="speedtest_text") ]] answers.append( InlineQueryResultArticle( title="Speed Test", description="test your speed", input_message_content=InputTextMessageContent( "Select SpeedTest Mode", parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "alive": repo = git.Repo(os.getcwd()) master = repo.head.reference commit_id = master.commit.hexsha commit_link = f"[{commit_id[:7]}](https://github.com/pokurt/Nana-Remix/commit/{commit_id})" try: me = await app.get_me() except ConnectionError: me = None if not me: nana_stats = 'stopped' else: nana_stats = 'alive' buttons = [[ InlineKeyboardButton("stats", callback_data="alive_message") ]] answers.append( InlineQueryResultArticle( title="Alive", description="Nana Userbot", input_message_content=InputTextMessageContent( tld("alive_str").format(commit_link, nana_stats, USERBOT_VERSION, __version__, python_version(), DB_AVAILABLE), parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "anime": if len(string.split()) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Search an Anime", switch_pm_parameter="help_inline") return json = (await anime_sauce(string.split(None, 1)[1]))['data'].get('Media', None) if json: msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Type**: {json['format']}\n**Status**: {json['status']}\n**Episodes**: {json.get('episodes', 'N/A')}\n**Duration**: {json.get('duration', 'N/A')} Per Ep.\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' msg += "**Studios**: `" for x in json['studios']['nodes']: msg += f"{x['name']}, " msg = msg[:-2] + '`\n' info = json.get('siteUrl') trailer = json.get('trailer', None) if trailer: trailer_id = trailer.get('id', None) site = trailer.get('site', None) if site == "youtube": trailer = 'https://youtu.be/' + trailer_id description = json.get('description', 'N/A').replace('<i>', '').replace( '</i>', '').replace('<br>', '') msg += shorten(description, info) image = f'https://img.anili.st/media/{json["id"]}' if trailer: buttons = [ [ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton("Trailer 🎬", url=trailer) ], [ InlineKeyboardButton( 'Add to Watchlist', callback_data=f'addfav_{json["title"]["romaji"]}') ] ] else: buttons = [[ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton( 'Add to Watchlist', callback_data=f'addfav_{json["title"]["romaji"]}') ]] if image: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=image, parse_mode="markdown", title=f"{json['title']['romaji']}", description=f"{json['format']}", reply_markup=InlineKeyboardMarkup(buttons))) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description=f"{json['averageScore']}", input_message_content=InputTextMessageContent( msg, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "favourite": fav = sql.get_fav(Owner) if fav: text = "**My watchlist:**\n" for title in fav: text += f" - {title.data}\n" keyb = [[ InlineKeyboardButton(text="Watched ✅", callback_data=f"remfav_{Owner}") ]] answers.append( InlineQueryResultArticle( title="Favourites", description="Anime", input_message_content=InputTextMessageContent( text, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(keyb))) else: answers.append( InlineQueryResultArticle( title="Fabourites", description="Anime", input_message_content=InputTextMessageContent( "**No favourites yet!**", parse_mode="markdown"))) await client.answer_inline_query(query.id, results=answers, cache_time=0) return
async def inline_query_handler(client, query): string = query.query.lower() if string == "": await client.answer_inline_query( query.id, results=[ InlineQueryResultPhoto( caption= "Hey! I have an inline mode, click the buttons below to start your exploration! (.づ◡﹏◡)づ.", photo_url= "https://telegra.ph/file/5536473a204e5191b80f8.png", parse_mode="html", title="Need Help?", description="Click Here...", reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton( "Anime", switch_inline_query_current_chat="anime "), InlineKeyboardButton( "Manga", switch_inline_query_current_chat="manga "), InlineKeyboardButton( "nHentai", switch_inline_query_current_chat="nhentai ") ], [ InlineKeyboardButton( "Airing", switch_inline_query_current_chat="airing "), InlineKeyboardButton( "Character", switch_inline_query_current_chat="char ") ], [ InlineKeyboardButton( text="Help", url="https://t.me/LordHitsuki_BOT?start=help") ]])), ], switch_pm_text="Click here to PM", switch_pm_parameter="start", cache_time=300) answers = [] txt = string.split() if len(txt) != 0 and txt[0] == "nhentai": if len(txt) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Enter nHentai ID", switch_pm_parameter="start") return squery = string.split(None, 1)[1] n_title, tags, artist, total_pages, post_url, cover_image = nhentai_data( squery) reply_message = f"<code>{n_title}</code>\n\n<b>Tags:</b>\n{tags}\n<b>Artists:</b>\n{artist}\n<b>Pages:</b>\n{total_pages}" await client.answer_inline_query( query.id, results=[ InlineQueryResultArticle( title=n_title, input_message_content=InputTextMessageContent( reply_message), description=tags, thumb_url=cover_image, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("Read Here", url=post_url)]])) ], cache_time=1) elif len(txt) != 0 and txt[0] == "anime": if len(txt) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Search an Anime", switch_pm_parameter="start") return search = string.split(None, 1)[1] variables = {'search': search} async with aiohttp.ClientSession() as session: async with session.post(url, json={ 'query': anime_query, 'variables': variables }) as resp: r = await resp.json() json = r['data'].get('Media', None) if json: mal_id = int(json.get('idMal')) msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Type**: {json['format']}\n**Status**: {json['status']}\n**Episodes**: {json.get('episodes', 'N/A')}\n**Duration**: {json.get('duration', 'N/A')} Per Ep.\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' msg += "**Studios**: `" for x in json['studios']['nodes']: msg += f"{x['name']}, " msg = msg[:-2] + '`\n' info = json.get('siteUrl') mal_link = f"https://myanimelist.net/anime/{mal_id}" trailer = json.get('trailer', None) if trailer: trailer_id = trailer.get('id', None) site = trailer.get('site', None) if site == "youtube": trailer = 'https://youtu.be/' + trailer_id description = json.get('description', 'N/A').replace( '<i>', '').replace('</i>', '').replace('<br>', '') msg += shorten(description, info) image = info.replace('anilist.co/anime/', 'img.anili.st/media/') if trailer: buttons = [[ InlineKeyboardButton("Anilist", url=info), InlineKeyboardButton("MAL", url=mal_link) ], [InlineKeyboardButton("Trailer 🎬", url=trailer)]] else: buttons = [[ InlineKeyboardButton("Anilist", url=info), InlineKeyboardButton("MAL", url=mal_link) ]] if image: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=image, parse_mode="markdown", title=f"{json['title']['romaji']}", description= f"{json['format']} | {json.get('episodes', 'N/A')} Episode{'s' if len(str(json.get('episodes'))) > 1 else ''}", reply_markup=InlineKeyboardMarkup(buttons))) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description= f"{json['format']} | {json.get('episodes', 'N/A')} Episode{'s' if len(str(json.get('episodes'))) > 1 else ''}", input_message_content=InputTextMessageContent( msg, parse_mode="md", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0, is_gallery=False) elif len(txt) != 0 and txt[0] == "manga": if len(txt) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Search a Manga", switch_pm_parameter="start") return search = string.split(None, 1)[1] variables = {'search': search} async with aiohttp.ClientSession() as session: async with session.post(url, json={ 'query': manga_query, 'variables': variables }) as resp: r = await resp.json() json = r['data'].get('Media', None) if json: msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Status**: {json['status']}\n**Year**: {json['startDate']['year']}\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' description = json.get('description', 'N/A').replace( '<i>', '').replace('</i>', '').replace('<br>', '') info = json.get('siteUrl') if info: buttons = InlineKeyboardMarkup( [[InlineKeyboardButton("More Info", url=info)]]) else: buttons = None msg += shorten(description, info) banner_url = json.get('bannerImage') if banner_url: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=banner_url, parse_mode="markdown", title=f"{json['title']['romaji']}", description=f"{json['startDate']['year']}", reply_markup=buttons)) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description=f"{json['averageScore']}", input_message_content=InputTextMessageContent( msg, parse_mode="markdown", disable_web_page_preview=True), reply_markup=buttons)) await client.answer_inline_query(query.id, results=answers, cache_time=0, is_gallery=False) elif len(txt) != 0 and txt[0] == "airing": if len(txt) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Get the Airing Status", switch_pm_parameter="start") return search = string.split(None, 1)[1] variables = {'search': search} response = requests.post(url, json={ 'query': airing_query, 'variables': variables }).json()['data']['Media'] info = response['siteUrl'] if info: buttons = InlineKeyboardMarkup( [[InlineKeyboardButton("More Info", url=info)]]) else: buttons = None image = info.replace('anilist.co/anime/', 'img.anili.st/media/') if image: thumb = image else: thumb = None ms_g = f"**Name**: **{response['title']['romaji']}**(`{response['title']['native']}`)\n**ID**: `{response['id']}`" if response['nextAiringEpisode']: airing_time = response['nextAiringEpisode'][ 'timeUntilAiring'] * 1000 airing_time_final = t(airing_time) in_des = f"Episode {response['nextAiringEpisode']['episode']} Airing in {airing_time_final}" ms_g += f"\n**Episode**: `{response['nextAiringEpisode']['episode']}`\n**Airing In**: `{airing_time_final}`" else: in_des = "N/A" ms_g += f"\n**Episode**: `{response['episodes']}`\n**Status**: `N/A`" answers.append( InlineQueryResultArticle( title=f"{response['title']['romaji']}", description=f"{in_des}", input_message_content=InputTextMessageContent( f"{ms_g}[ ]({image})", parse_mode="markdown", disable_web_page_preview=False), reply_markup=buttons, thumb_url=thumb)) await client.answer_inline_query(query.id, results=answers, cache_time=0, is_gallery=False) elif len(txt) != 0 and txt[0] == "char": if len(txt) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Get Character Info", switch_pm_parameter="start") return search = string.split(None, 1)[1] variables = {'query': search} json = requests.post(url, json={ 'query': character_query, 'variables': variables }).json()['data']['Character'] if json: ms_g = f"**{json.get('name').get('full')}**\nFavourites: {json['favourites']}\n" description = f"{json['description']}" site_url = json.get('siteUrl') ms_g += shorten(description, site_url) image = json.get('image', None) if image: image = image.get('large') answers.append( InlineQueryResultPhoto( caption=ms_g, photo_url=image, parse_mode="markdown", title=f"{json.get('name').get('full')}", description=f"❤️ {json['favourites']}", reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("More Info", url=site_url)]]))) else: answers.append( InlineQueryResultArticle( title=f"{json.get('name').get('full')}", description=f"{json['favourites']}", input_message_content=InputTextMessageContent( ms_g, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("More Info", url=site_url)]]))) await client.answer_inline_query(query.id, results=answers, cache_time=0, is_gallery=False)
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if string.split()[0] == "nhentai": query = string.split(None, 1)[1] n_title, tags, artist, total_pages, post_url, cover_image = nhentai_data( query) reply_message = f"<code>{n_title}</code>\n\n<b>Tags:</b>\n{tags}\n<b>Artists:</b>\n{artist}\n<b>Pages:</b>\n{total_pages}" await inline_query.answer(results=[ InlineQueryResultArticle( title=n_title, input_message_content=InputTextMessageContent(reply_message), description=tags, thumb_url=cover_image, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("Read Here", url=post_url)]])) ], cache_time=1) elif string.split()[0] == "anime": if len(string.split()) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Search an Anime") return search = string.split(None, 1)[1] variables = {'search': search} async with aiohttp.ClientSession() as session: async with session.post(url, json={ 'query': anime_query, 'variables': variables }) as resp: r = await resp.json() json = r['data'].get('Media', None) if json: msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Type**: {json['format']}\n**Status**: {json['status']}\n**Episodes**: {json.get('episodes', 'N/A')}\n**Duration**: {json.get('duration', 'N/A')} Per Ep.\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' msg += "**Studios**: `" for x in json['studios']['nodes']: msg += f"{x['name']}, " msg = msg[:-2] + '`\n' info = json.get('siteUrl') trailer = json.get('trailer', None) if trailer: trailer_id = trailer.get('id', None) site = trailer.get('site', None) if site == "youtube": trailer = 'https://youtu.be/' + trailer_id description = json.get('description', 'N/A').replace( '<i>', '').replace('</i>', '').replace('<br>', '') msg += shorten(description, info) image = info.replace('anilist.co/anime/', 'img.anili.st/media/') if trailer: buttons = [[ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton("Trailer 🎬", url=trailer) ]] else: buttons = [[ InlineKeyboardButton("More Info", url=info), ]] if image: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=image, parse_mode="markdown", title=f"{json['title']['romaji']}", description=f"{json['format']}", reply_markup=InlineKeyboardMarkup(buttons))) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description=f"{json['averageScore']}", input_message_content=InputTextMessageContent( msg, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0)
async def inline_query_handler(client, query): try: text = query.query.lower() answers = [] if text.strip() == "": answerss = await inline_help_func(__HELP__) await client.answer_inline_query(query.id, results=answerss, cache_time=10) return elif text.split()[0] == "alive": answerss = await alive_function(answers) await client.answer_inline_query(query.id, results=answerss, cache_time=10) elif text.split()[0] == "tr": lang = text.split()[1] tex = text.split(None, 2)[2] answerss = await translate_func(answers, lang, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=10) elif text.split()[0] == "ud": tex = text.split(None, 1)[1] answerss = await urban_func(answers, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=10) elif text.split()[0] == "google": tex = text.split(None, 1)[1] answerss = await google_search_func(answers, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=10) elif text.split()[0] == "webss": tex = text.split(None, 1)[1] answerss = await webss(tex) await client.answer_inline_query(query.id, results=answerss, cache_time=2) elif text.split()[0] == "bitly": tex = text.split(None, 1)[1] answerss = await shortify(tex) await client.answer_inline_query(query.id, results=answerss, cache_time=2) elif text.split()[0] == "wiki": if len(text.split()) < 2: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Wikipedia | wiki [QUERY]", switch_pm_parameter="inline", ) return tex = text.split(None, 1)[1].strip() answerss = await wiki_func(answers, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=2) elif text.split()[0] == "ping": answerss = await ping_func(answers) await client.answer_inline_query(query.id, results=answerss, cache_time=2) return elif text.split()[0] == "yt": answers = [] search_query = text.split(None, 1)[1] search_query = query.query.lower().strip().rstrip() if search_query == "": await client.answer_inline_query( query.id, results=answers, switch_pm_text="Type a YouTube video name...", switch_pm_parameter="help", cache_time=0, ) else: search = VideosSearch(search_query, limit=50) for result in search.result()["result"]: answers.append( InlineQueryResultArticle( title=result["title"], description="{}, {} views.".format( result["duration"], result["viewCount"]["short"] ), input_message_content=InputTextMessageContent( "https://www.youtube.com/watch?v={}".format( result["id"] ) ), thumb_url=result["thumbnails"][0]["url"], ) ) try: await query.answer(results=answers, cache_time=0) except errors.QueryIdInvalid: await query.answer( results=answers, cache_time=0, switch_pm_text="Error: Search timed out", switch_pm_parameter="", ) elif text.split()[0] == "wall": tex = text.split(None, 1)[1] answerss = await wall_func(answers, tex) await client.answer_inline_query(query.id, results=answerss) elif text.split()[0] == "pic": tex = text.split(None, 1)[1] answerss = await wall_func(answers, tex) await client.answer_inline_query(query.id, results=answerss) elif text.split()[0] == "saavn": tex = text.split(None, 1)[1] answerss = await saavn_func(answers, tex) await client.answer_inline_query(query.id, results=answerss) elif text.split()[0] == "deezer": tex = text.split(None, 1)[1] answerss = await deezer_func(answers, tex) await client.answer_inline_query(query.id, results=answerss) elif text.split()[0] == "torrent": tex = text.split(None, 1)[1] answerss = await torrent_func(answers, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=10) elif text.split()[0] == "modapk": sgname = text.split(None, 1)[1] PabloEscobar = ( f"https://an1.com/tags/MOD/?story={sgname}&do=search&subaction=search" ) r = requests.get(PabloEscobar) results = [] soup = BeautifulSoup(r.content, "html5lib") mydivs = soup.find_all("div", {"class": "search-results"}) Pop = soup.find_all("div", {"class": "title"}) cnte = len(mydivs) for cnt in range(cnte): sucker = mydivs[cnt] pH9 = sucker.find("a").contents[0] file_name = pH9 pH = sucker.findAll("img") imme = pH[0]["src"] Pablo = Pop[0].a["href"] ro = requests.get(Pablo) soupe = BeautifulSoup(ro.content, "html5lib") myopo = soupe.find_all("div", {"class": "item"}) capt = f"**{file_name}** \n** {myopo[0].text}**\n**{myopo[1].text}**\n**{myopo[2].text}**\n**{myopo[3].text}**" mydis0 = soupe.find_all("a", {"class": "get-product"}) Lol9 = mydis0[0] lemk = "https://an1.com" + Lol9["href"] rr = requests.get(lemk) soup = BeautifulSoup(rr.content, "html5lib") script = soup.find("script", type="text/javascript") leek = re.search(r'href=[\'"]?([^\'" >]+)', script.text).group() dl_link = leek[5:] results.append( InlineQueryResultPhoto( photo_url=imme, title=file_name, caption=capt, reply_markup=InlineKeyboardMarkup( [ [InlineKeyboardButton("Download Link", url=lemk)], [ InlineKeyboardButton( "Direct Download Link", url=dl_link ) ], ] ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "reddit": subreddit = text.split(None, 1)[1] results = [] reddit = await arq.reddit(subreddit) sreddit = reddit.subreddit title = reddit.title image = reddit.url link = reddit.postLink caption = f"""**Title:** `{title}` Subreddit: `{sreddit}`""" results.append( InlineQueryResultPhoto( photo_url=image, title="Meme Search", caption=caption, reply_markup=InlineKeyboardMarkup( [ [InlineKeyboardButton("PostLink", url=link)], ] ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "imdb": movie_name = text.split(None, 1)[1] results = [] remove_space = movie_name.split(" ") final_name = "+".join(remove_space) page = requests.get( "https://www.imdb.com/find?ref_=nv_sr_fn&q=" + final_name + "&s=all" ) str(page.status_code) soup = BeautifulSoup(page.content, "lxml") odds = soup.findAll("tr", "odd") mov_title = odds[0].findNext("td").findNext("td").text mov_link = ( "http://www.imdb.com/" + odds[0].findNext("td").findNext("td").a["href"] ) page1 = requests.get(mov_link) soup = BeautifulSoup(page1.content, "lxml") if soup.find("div", "poster"): poster = soup.find("div", "poster").img["src"] else: poster = "" if soup.find("div", "title_wrapper"): pg = soup.find("div", "title_wrapper").findNext("div").text mov_details = re.sub(r"\s+", " ", pg) else: mov_details = "" credits = soup.findAll("div", "credit_summary_item") if len(credits) == 1: director = credits[0].a.text writer = "Not available" stars = "Not available" elif len(credits) > 2: director = credits[0].a.text writer = credits[1].a.text actors = [] for x in credits[2].findAll("a"): actors.append(x.text) actors.pop() stars = actors[0] + "," + actors[1] + "," + actors[2] else: director = credits[0].a.text writer = "Not available" actors = [] for x in credits[1].findAll("a"): actors.append(x.text) actors.pop() stars = actors[0] + "," + actors[1] + "," + actors[2] if soup.find("div", "inline canwrap"): story_line = soup.find("div", "inline canwrap").findAll("p")[0].text else: story_line = "Not available" info = soup.findAll("div", "txt-block") if info: mov_country = [] mov_language = [] for node in info: a = node.findAll("a") for i in a: if "country_of_origin" in i["href"]: mov_country.append(i.text) elif "primary_language" in i["href"]: mov_language.append(i.text) if soup.findAll("div", "ratingValue"): for r in soup.findAll("div", "ratingValue"): mov_rating = r.strong["title"] else: mov_rating = "Not available" lol = f"Movie - {mov_title}\n Click to see more" msg = ( "<a href=" + poster + ">​</a>" "<b>Title : </b><code>" + mov_title + "</code>\n<code>" + mov_details + "</code>\n<b>Rating : </b><code>" + mov_rating + "</code>\n<b>Country : </b><code>" + mov_country[0] + "</code>\n<b>Language : </b><code>" + mov_language[0] + "</code>\n<b>Director : </b><code>" + director + "</code>\n<b>Writer : </b><code>" + writer + "</code>\n<b>Stars : </b><code>" + stars + "</code>\n<b>IMDB Url : </b>" + mov_link + "\n<b>Story Line : </b>" + story_line ) results.append( InlineQueryResultArticle( title="Imdb Search", description=lol, input_message_content=InputTextMessageContent( msg, disable_web_page_preview=False, parse_mode="HTML" ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "spaminfo": cmd = text.split(None, 1)[1] results = [] url = f"https://api.intellivoid.net/spamprotection/v1/lookup?query={cmd}" a = await AioHttp().get_json(url) response = a["success"] if response is True: date = a["results"]["last_updated"] stats = f"**◢ Intellivoid• SpamProtection Info**:\n" stats += f' • **Updated on**: `{datetime.fromtimestamp(date).strftime("%Y-%m-%d %I:%M:%S %p")}`\n' stats += f" • **Chat Info**: [Link](t.me/SpamProtectionBot/?start=00_{cmd})\n" if a["results"]["attributes"]["is_potential_spammer"] is True: stats += f" • **User**: `USERxSPAM`\n" elif a["results"]["attributes"]["is_operator"] is True: stats += f" • **User**: `USERxOPERATOR`\n" elif a["results"]["attributes"]["is_agent"] is True: stats += f" • **User**: `USERxAGENT`\n" elif a["results"]["attributes"]["is_whitelisted"] is True: stats += f" • **User**: `USERxWHITELISTED`\n" stats += f' • **Type**: `{a["results"]["entity_type"]}`\n' stats += f' • **Language**: `{a["results"]["language_prediction"]["language"]}`\n' stats += f' • **Language Probability**: `{a["results"]["language_prediction"]["probability"]}`\n' stats += f"**Spam Prediction**:\n" stats += f' • **Ham Prediction**: `{a["results"]["spam_prediction"]["ham_prediction"]}`\n' stats += f' • **Spam Prediction**: `{a["results"]["spam_prediction"]["spam_prediction"]}`\n' stats += f'**Blacklisted**: `{a["results"]["attributes"]["is_blacklisted"]}`\n' if a["results"]["attributes"]["is_blacklisted"] is True: stats += f' • **Reason**: `{a["results"]["attributes"]["blacklist_reason"]}`\n' stats += f' • **Flag**: `{a["results"]["attributes"]["blacklist_flag"]}`\n' stats += f'**PTID**:\n`{a["results"]["private_telegram_id"]}`\n' results.append( InlineQueryResultArticle( title="Spam Info", description="Search Users spam info", input_message_content=InputTextMessageContent( stats, disable_web_page_preview=True ), ) ) await client.answer_inline_query( query.id, cache_time=0, results=results ) elif text.split()[0] == "lyrics": cmd = text.split(None, 1)[1] results = [] song = "" song = Song.find_song(cmd) if song: if song.lyrics: reply = song.format() else: reply = "Couldn't find any lyrics for that song! try with artist name along with song if still doesnt work try `.glyrics`" else: reply = "lyrics not found! try with artist name along with song if still doesnt work try `.glyrics`" if len(reply) > 4095: reply = "lyrics too big, Try using /lyrics" results.append( InlineQueryResultArticle( title="Song Lyrics", description="Click here to see lyrics", input_message_content=InputTextMessageContent( reply, disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "pokedex": if len(text.split()) < 2: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Pokemon [text]", switch_pm_parameter="pokedex", ) return pokedex = text.split(None, 1)[1].strip() Pokedex = await pokedexinfo(answers, pokedex) await client.answer_inline_query(query.id, results=Pokedex, cache_time=2) elif text.split()[0] == "paste": tex = text.split(None, 1)[1] answerss = await paste_func(answers, tex) await client.answer_inline_query(query.id, results=answerss, cache_time=2) elif text.split()[0] == "covid": lel = text.split(None, 1)[1] results = [] country = lel.replace(" ", "") data = await fetch(f"https://corona.lmao.ninja/v2/countries/{country}") data = await json_prettify(data) results.append( InlineQueryResultArticle( title="Covid Info Gathered succesfully", description=data, input_message_content=InputTextMessageContent( data, disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, results=results, cache_time=2) elif text.split()[0] == "country": lel = text.split(None, 1)[1] results = [] country = CountryInfo(lel) try: a = country.info() except: a = "Country Not Avaiable Currently" name = a.get("name") bb = a.get("altSpellings") hu = "" for p in bb: hu += p + ", " area = a.get("area") borders = "" hell = a.get("borders") for fk in hell: borders += fk + ", " call = "" WhAt = a.get("callingCodes") for what in WhAt: call += what + " " capital = a.get("capital") currencies = "" fker = a.get("currencies") for FKer in fker: currencies += FKer + ", " HmM = a.get("demonym") geo = a.get("geoJSON") pablo = geo.get("features") Pablo = pablo[0] PAblo = Pablo.get("geometry") EsCoBaR = PAblo.get("type") iso = "" iSo = a.get("ISO") for hitler in iSo: po = iSo.get(hitler) iso += po + ", " fla = iSo.get("alpha2") fla.upper() languages = a.get("languages") lMAO = "" for lmao in languages: lMAO += lmao + ", " nonive = a.get("nativeName") waste = a.get("population") reg = a.get("region") sub = a.get("subregion") tik = a.get("timezones") tom = "" for jerry in tik: tom += jerry + ", " GOT = a.get("tld") lanester = "" for targaryen in GOT: lanester += targaryen + ", " wiki = a.get("wiki") caption = f"""<b><u>Information Gathered Successfully</b></u> <b> Country Name:- {name} Alternative Spellings:- {hu} Country Area:- {area} square kilometers Borders:- {borders} Calling Codes:- {call} Country's Capital:- {capital} Country's currency:- {currencies} Demonym:- {HmM} Country Type:- {EsCoBaR} ISO Names:- {iso} Languages:- {lMAO} Native Name:- {nonive} population:- {waste} Region:- {reg} Sub Region:- {sub} Time Zones:- {tom} Top Level Domain:- {lanester} wikipedia:- {wiki}</b> Gathered By Daisy X.</b> """ results.append( InlineQueryResultArticle( title=f"Infomation of {name}", description=f""" Country Name:- {name} Alternative Spellings:- {hu} Country Area:- {area} square kilometers Borders:- {borders} Calling Codes:- {call} Country's Capital:- {capital} Touch for more info """, input_message_content=InputTextMessageContent( caption, parse_mode="HTML", disable_web_page_preview=True ), ) ) await client.answer_inline_query(query.id, results=results, cache_time=2) elif text.split()[0] == "fakegen": results = [] fake = Faker() name = str(fake.name()) fake.add_provider(internet) address = str(fake.address()) ip = fake.ipv4_private() cc = fake.credit_card_full() email = fake.ascii_free_email() job = fake.job() android = fake.android_platform_token() pc = fake.chrome() res = f"<b><u> Fake Information Generated</b></u>\n<b>Name :-</b><code>{name}</code>\n\n<b>Address:-</b><code>{address}</code>\n\n<b>IP ADDRESS:-</b><code>{ip}</code>\n\n<b>credit card:-</b><code>{cc}</code>\n\n<b>Email Id:-</b><code>{email}</code>\n\n<b>Job:-</b><code>{job}</code>\n\n<b>android user agent:-</b><code>{android}</code>\n\n<b>Pc user agent:-</b><code>{pc}</code>" results.append( InlineQueryResultArticle( title="Fake infomation gathered", description="Click here to see them", input_message_content=InputTextMessageContent( res, parse_mode="HTML", disable_web_page_preview=True ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "cs": results = [] score_page = "http://static.cricinfo.com/rss/livescores.xml" page = urllib.request.urlopen(score_page) soup = BeautifulSoup(page, "html.parser") result = soup.find_all("description") Sed = "" for match in result: Sed += match.get_text() + "\n\n" res = f"<b><u>Match information gathered successful</b></u>\n\n\n<code>{Sed}</code>" results.append( InlineQueryResultArticle( title="Match information gathered", description="Click here to see them", input_message_content=InputTextMessageContent( res, parse_mode="HTML", disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "antonyms": results = [] lel = text.split(None, 1)[1] word = f"{lel}" let = dictionary.antonym(word) set = str(let) jet = set.replace("{", "") net = jet.replace("}", "") got = net.replace("'", "") results.append( InlineQueryResultArticle( title=f"antonyms for {lel}", description=got, input_message_content=InputTextMessageContent( got, disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "synonyms": results = [] lel = text.split(None, 1)[1] word = f"{lel}" let = dictionary.synonym(word) set = str(let) jet = set.replace("{", "") net = jet.replace("}", "") got = net.replace("'", "") results.append( InlineQueryResultArticle( title=f"antonyms for {lel}", description=got, input_message_content=InputTextMessageContent( got, disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "define": results = [] lel = text.split(None, 1)[1] word = f"{lel}" let = dictionary.meaning(word) set = str(let) jet = set.replace("{", "") net = jet.replace("}", "") got = net.replace("'", "") results.append( InlineQueryResultArticle( title=f"Definition for {lel}", description=got, input_message_content=InputTextMessageContent( got, disable_web_page_preview=False ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "weather": results = [] sample_url = "https://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units=metric" input_str = text.split(None, 1)[1] async with aiohttp.ClientSession() as session: response_api_zero = await session.get( sample_url.format(input_str, OPENWEATHERMAP_ID) ) response_api = await response_api_zero.json() if response_api["cod"] == 200: country_code = response_api["sys"]["country"] country_time_zone = int(response_api["timezone"]) sun_rise_time = int(response_api["sys"]["sunrise"]) + country_time_zone sun_set_time = int(response_api["sys"]["sunset"]) + country_time_zone lol = """ WEATHER INFO GATHERED Location: {} Temperature ☀️: {}°С minimium: {}°С maximum : {}°С Humidity 🌤**: {}% Wind 💨: {}m/s Clouds ☁️: {}hpa Sunrise 🌤: {} {} Sunset 🌝: {} {}""".format( input_str, response_api["main"]["temp"], response_api["main"]["temp_min"], response_api["main"]["temp_max"], response_api["main"]["humidity"], response_api["wind"]["speed"], response_api["clouds"]["all"], # response_api["main"]["pressure"], time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(sun_rise_time)), country_code, time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(sun_set_time)), country_code, ) results.append( InlineQueryResultArticle( title=f"Weather Information", description=lol, input_message_content=InputTextMessageContent( lol, disable_web_page_preview=True ), ) ) await client.answer_inline_query( query.id, cache_time=0, results=results ) elif text.split()[0] == "datetime": results = [] gay = text.split(None, 1)[1] lel = gay query_timezone = lel.lower() if len(query_timezone) == 2: result = generate_time(query_timezone, ["countryCode"]) else: result = generate_time(query_timezone, ["zoneName", "countryName"]) if not result: result = f"Timezone info not available for <b>{lel}</b>" results.append( InlineQueryResultArticle( title=f"Date & Time info of {lel}", description=result, input_message_content=InputTextMessageContent( result, disable_web_page_preview=False, parse_mode="html" ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "app": rip = [] app_name = text.split(None, 1)[1] remove_space = app_name.split(" ") final_name = "+".join(remove_space) page = requests.get( "https://play.google.com/store/search?q=" + final_name + "&c=apps" ) str(page.status_code) soup = BeautifulSoup(page.content, "lxml", from_encoding="utf-8") results = soup.findAll("div", "ZmHEEd") app_name = ( results[0] .findNext("div", "Vpfmgd") .findNext("div", "WsMG1c nnK0zc") .text ) app_dev = ( results[0].findNext("div", "Vpfmgd").findNext("div", "KoLSrc").text ) app_dev_link = ( "https://play.google.com" + results[0].findNext("div", "Vpfmgd").findNext("a", "mnKHRc")["href"] ) app_rating = ( results[0] .findNext("div", "Vpfmgd") .findNext("div", "pf5lIe") .find("div")["aria-label"] ) app_link = ( "https://play.google.com" + results[0] .findNext("div", "Vpfmgd") .findNext("div", "vU6FJ p63iDd") .a["href"] ) app_icon = ( results[0] .findNext("div", "Vpfmgd") .findNext("div", "uzcko") .img["data-src"] ) app_details = "<a href='" + app_icon + "'>📲​</a>" app_details += " <b>" + app_name + "</b>" app_details += ( "\n\n<code>Developer :</code> <a href='" + app_dev_link + "'>" + app_dev + "</a>" ) app_details += "\n<code>Rating :</code> " + app_rating.replace( "Rated ", "⭐ " ).replace(" out of ", "/").replace(" stars", "", 1).replace( " stars", "⭐ " ).replace( "five", "5" ) app_details += ( "\n<code>Features :</code> <a href='" + app_link + "'>View in Play Store</a>" ) app_details += "\n\n===> @DaisySupport_Official <===" rip.append( InlineQueryResultArticle( title=f"Datails of {app_name}", description=app_details, input_message_content=InputTextMessageContent( app_details, disable_web_page_preview=True, parse_mode="html" ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=rip) elif text.split()[0] == "gh": results = [] gett = text.split(None, 1)[1] text = gett + ' "site:github.com"' gresults = await GoogleSearch().async_search(text, 1) result = "" for i in range(4): try: title = gresults["titles"][i].replace("\n", " ") source = gresults["links"][i] description = gresults["descriptions"][i] result += f"[{title}]({source})\n" result += f"`{description}`\n\n" except IndexError: pass results.append( InlineQueryResultArticle( title=f"Results for {gett}", description=f" Github info of {title}\n Touch to read", input_message_content=InputTextMessageContent( result, disable_web_page_preview=True ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) elif text.split()[0] == "so": results = [] gett = text.split(None, 1)[1] text = gett + ' "site:stackoverflow.com"' gresults = await GoogleSearch().async_search(text, 1) result = "" for i in range(4): try: title = gresults["titles"][i].replace("\n", " ") source = gresults["links"][i] description = gresults["descriptions"][i] result += f"[{title}]({source})\n" result += f"`{description}`\n\n" except IndexError: pass results.append( InlineQueryResultArticle( title=f"Stack overflow saerch - {title}", description=f" Touch to view search results on {title}", input_message_content=InputTextMessageContent( result, disable_web_page_preview=True ), ) ) await client.answer_inline_query(query.id, cache_time=0, results=results) except (IndexError, TypeError, KeyError, ValueError): return
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id not in AdminSettings: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown") return if string == "": await client.answer_inline_query( query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline") return # Notes if string.split()[0] == "note": if not DB_AVAILABLE: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Your database isn't avaiable!", switch_pm_parameter="help_inline") return if len(string.split()) == 1: allnotes = notes_db.get_all_selfnotes_inline(query.from_user.id) if not allnotes: await client.answer_inline_query( query.id, results=answers, switch_pm_text="You dont have any notes!", switch_pm_parameter="help_inline") return if len(list(allnotes)) >= 30: rng = 30 else: rng = len(list(allnotes)) for x in range(rng): note = allnotes[list(allnotes)[x]] noteval = note["value"] notetype = note["type"] # notefile = note["file"] if notetype != Types.TEXT: continue note, button = parse_button(noteval) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(list(allnotes)[x]), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Yourself notes", switch_pm_parameter="help_inline") return q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help_inline") return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(notetag), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query(query.id, results=answers, cache_time=5) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[ InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors") ]]) text = "An error has accured!\n\n```{}```\n".format( "".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return # Stylish converter elif string.split()[0] == "stylish": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Insert any text to convert it!", switch_pm_parameter="help_inline") return text = string.split(None, 1)[1] upside = upsidedown_text_inline(text) answers.append( InlineQueryResultArticle( title=upside, description="Upside-down Text", input_message_content=InputTextMessageContent(upside))) over = text_style_generator(text, CHAR_OVER) answers.append( InlineQueryResultArticle( title=over, description="Overline Text", input_message_content=InputTextMessageContent(over))) under = text_style_generator(text, CHAR_UNDER) answers.append( InlineQueryResultArticle( title=under, description="Underline Text", input_message_content=InputTextMessageContent(under))) strike = text_style_generator(text, CHAR_STRIKE) answers.append( InlineQueryResultArticle( title=strike, description="Strike Text", input_message_content=InputTextMessageContent(strike))) points = text_style_generator(text, CHAR_POINTS) answers.append( InlineQueryResultArticle( title=points, description="Points Text", input_message_content=InputTextMessageContent(points))) smallcaps_conv = formatting_text_inline(text, smallcaps) answers.append( InlineQueryResultArticle( title=smallcaps_conv, description="Smallcaps Text", input_message_content=InputTextMessageContent(smallcaps_conv))) super_script = formatting_text_inline(text, superscript) answers.append( InlineQueryResultArticle( title=super_script, description="Superscript Text", input_message_content=InputTextMessageContent(super_script))) sub_script = formatting_text_inline(text, subscript) answers.append( InlineQueryResultArticle( title=sub_script, description="Subscript Text", input_message_content=InputTextMessageContent(sub_script))) wide_text = formatting_text_inline(text, wide) answers.append( InlineQueryResultArticle( title=wide_text, description="Wide Text", input_message_content=InputTextMessageContent(wide_text))) bubbles_text = formatting_text_inline(text, bubbles) answers.append( InlineQueryResultArticle( title=bubbles_text, description="Bubbles Text", input_message_content=InputTextMessageContent(bubbles_text))) bubblesblack_text = formatting_text_inline(text, bubblesblack) answers.append( InlineQueryResultArticle( title=bubblesblack_text, description="Bubbles Black Text", input_message_content=InputTextMessageContent( bubblesblack_text))) smoth_text = formatting_text_inline(text, smothtext) answers.append( InlineQueryResultArticle( title=smoth_text, description="Smoth Text", input_message_content=InputTextMessageContent(smoth_text))) graffiti_text = formatting_text_inline(text, graffiti) answers.append( InlineQueryResultArticle( title=graffiti_text, description="Graffiti Text", input_message_content=InputTextMessageContent(graffiti_text))) graffitib_text = formatting_text_inline(text, graffitib) answers.append( InlineQueryResultArticle( title=graffitib_text, description="Graffiti Bold Text", input_message_content=InputTextMessageContent(graffitib_text))) handwriting_text = formatting_text_inline(text, handwriting) answers.append( InlineQueryResultArticle( title=handwriting_text, description="Handwriting Text", input_message_content=InputTextMessageContent( handwriting_text))) handwritingb_text = formatting_text_inline(text, handwritingb) answers.append( InlineQueryResultArticle( title=handwritingb_text, description="Handwriting Bold Text", input_message_content=InputTextMessageContent( handwritingb_text))) await client.answer_inline_query( query.id, results=answers, switch_pm_text="Converted to stylish text", switch_pm_parameter="help_inline") # PM_PERMIT elif string.split()[0] == "engine_pm": button = [[ InlineKeyboardButton("Ask for Money", callback_data="engine_pm_block"), InlineKeyboardButton("Contact me", callback_data="engine_pm_nope") ], [ InlineKeyboardButton("Report", callback_data="engine_pm_report"), InlineKeyboardButton("Passing by", callback_data="engine_pm_none") ]] random.shuffle(button) answers.append( InlineQueryResultArticle( title="Engine pm", description="Filter pm", input_message_content=InputTextMessageContent( welc_txt, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "speedtest": buttons = [[ InlineKeyboardButton("Image", callback_data="speedtest_image"), InlineKeyboardButton("Text", callback_data="speedtest_text") ]] answers.append( InlineQueryResultArticle( title="Speed Test", description="test your speed", input_message_content=InputTextMessageContent( "Select SpeedTest Mode", parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "alive": repo = git.Repo(os.getcwd()) master = repo.head.reference commit_id = master.commit.hexsha commit_link = f"[{commit_id[:7]}](https://github.com/pokurt/Nana-Remix/commit/{commit_id})" try: me = await app.get_me() except ConnectionError: me = None if not me: nana_stats = 'stopped' else: nana_stats = 'alive' buttons = [[ InlineKeyboardButton("stats", callback_data="alive_message") ]] answers.append( InlineQueryResultArticle( title="Alive", description="Nana Userbot", input_message_content=InputTextMessageContent( tld("alive_str").format(commit_link, nana_stats, USERBOT_VERSION, __version__, python_version(), DB_AVAILABLE), parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "anime": if len(string.split()) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Search an Anime", switch_pm_parameter="help_inline") return search = string.split(None, 1)[1] variables = {'search': search} async with aiohttp.ClientSession() as session: async with session.post(url, json={ 'query': anime_query, 'variables': variables }) as resp: r = await resp.json() json = r['data'].get('Media', None) if json: msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Type**: {json['format']}\n**Status**: {json['status']}\n**Episodes**: {json.get('episodes', 'N/A')}\n**Duration**: {json.get('duration', 'N/A')} Per Ep.\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' msg += "**Studios**: `" for x in json['studios']['nodes']: msg += f"{x['name']}, " msg = msg[:-2] + '`\n' info = json.get('siteUrl') trailer = json.get('trailer', None) if trailer: trailer_id = trailer.get('id', None) site = trailer.get('site', None) if site == "youtube": trailer = 'https://youtu.be/' + trailer_id description = json.get('description', 'N/A').replace( '<i>', '').replace('</i>', '').replace('<br>', '') msg += shorten(description, info) image = json.get('bannerImage', None) if trailer: buttons = [[ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton("Trailer 🎬", url=trailer) ], [ InlineKeyboardButton( 'Add to Watchlist', callback_data= f'addfav_{json["title"]["romaji"]}') ]] else: buttons = [[ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton( 'Add to Watchlist', callback_data= f'addfav_{json["title"]["romaji"]}') ]] if image: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=image, parse_mode="markdown", title=f"{json['title']['romaji']}", description=f"{json['format']}", reply_markup=InlineKeyboardMarkup(buttons))) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description=f"{json['averageScore']}", input_message_content=InputTextMessageContent( msg, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "favourite": fav = sql.get_fav(Owner) if fav: text = "**My watchlist:**\n" for title in fav: text += f" - {title.data}\n" keyb = [[ InlineKeyboardButton(text="Watched ✅", callback_data=f"remfav_{Owner}") ]] answers.append( InlineQueryResultArticle( title="Favourites", description="Anime", input_message_content=InputTextMessageContent( text, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(keyb))) else: answers.append( InlineQueryResultArticle( title="Fabourites", description="Anime", input_message_content=InputTextMessageContent( "**No favourites yet!**", parse_mode="markdown"))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "favourite": fav = sql.get_fav(Owner) if fav: text = "**My watchlist:**\n" for title in fav: text += f" - {title.data}\n" keyb = [[ InlineKeyboardButton(text="Watched ✅", callback_data=f"remfav_{Owner}") ]] answers.append( InlineQueryResultArticle( title="Favourites", description="Anime", input_message_content=InputTextMessageContent( text, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(keyb))) else: answers.append( InlineQueryResultArticle( title="Fabourites", description="Anime", input_message_content=InputTextMessageContent( "**No favourites yet!**", parse_mode="markdown"))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "cat": image = f"https://d2ph5fj80uercy.cloudfront.net/0{random.randint(1, 6)}/cat{random.randint(0,4999)}.jpg" buttons = [[ InlineKeyboardButton("Source", url="https://thiscatdoesnotexist.com/"), InlineKeyboardButton("Refresh", callback_data='cat_pic') ]] answers.append( InlineQueryResultPhoto(caption='Hi I like you too >~<', photo_url=image, parse_mode="markdown", title="Cursed Cat", description="Cursed Cat", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) if string.split()[0] == "lookup": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Search in SpamProtection Database", switch_pm_parameter="help_inline") return get_user = string.split(None, 1)[1] try: user = await app.get_chat(get_user) except PeerIdInvalid: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Can't Find the Chat in Database", switch_pm_parameter="help_inline") return api_url = f'https://api.intellivoid.net/spamprotection/v1/lookup?query={user.id}' a = await AioHttp().get_json(api_url) response = a['success'] if response == True: date = a["results"]["last_updated"] stats = f'**◢ Intellivoid• SpamProtection Info**:\n' stats += f' - **Updated on**: `{datetime.fromtimestamp(date).strftime("%Y-%m-%d %I:%M:%S %p")}`\n' if a["results"]["attributes"]["is_potential_spammer"] == True: stats += f' - **User**: `USERxSPAM`\n' elif a["results"]["attributes"]["is_operator"] == True: stats += f' - **User**: `USERxOPERATOR`\n' elif a["results"]["attributes"]["is_agent"] == True: stats += f' - **User**: `USERxAGENT`\n' elif a["results"]["attributes"]["is_whitelisted"] == True: stats += f' - **User**: `USERxWHITELISTED`\n' stats += f' - **Type**: `{a["results"]["entity_type"]}`\n' stats += f' - **Language**: `{a["results"]["language_prediction"]["language"]}`\n' stats += f' - **Language Probability**: `{a["results"]["language_prediction"]["probability"]}`\n' stats += f'**Spam Prediction**:\n' stats += f' - **Ham Prediction**: `{a["results"]["spam_prediction"]["ham_prediction"]}`\n' stats += f' - **Spam Prediction**: `{a["results"]["spam_prediction"]["spam_prediction"]}`\n' stats += f'**Blacklisted**: `{a["results"]["attributes"]["is_blacklisted"]}`\n' if a["results"]["attributes"]["is_blacklisted"] == True: stats += f' - **Reason**: `{a["results"]["attributes"]["blacklist_reason"]}`\n' stats += f' - **Flag**: `{a["results"]["attributes"]["blacklist_flag"]}`\n' stats += f'**TELEGRAM HASH**:\n`{a["results"]["private_telegram_id"]}`\n' buttons = [[ InlineKeyboardButton("Logs", url="https://t.me/SpamProtectionLogs"), InlineKeyboardButton( 'Info', url=f't.me/SpamProtectionBot/?start=00_{user.id}') ]] answers.append( InlineQueryResultArticle( title=f'{a["results"]["entity_type"]}', description=f'{a["results"]["private_telegram_id"]}', input_message_content=InputTextMessageContent( stats, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) return
async def inline(client, query): offset = int(query.offset or 0) results = [] string = query.query.lower() if string == "": await query.answer( results=DEFAULT_RESULTS, cache_time=CACHE_TIME, switch_pm_text="How do I work", switch_pm_parameter="start", ) return if string.split()[0] == "yandere": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=results, switch_pm_text="Search for an image on Yande.re", switch_pm_parameter="start") return tags = string.split(None, 1)[1].replace("#", '') counter = randint(1, 10) while_counter = 1 while while_counter <= 50: while_counter += 1 data = await sauce(tags, counter, url="https://yande.re/post.json?") counter += 1 count = 0 if len(data) == 0: break else: for item in data[offset:offset + NEXT_OFFSET]: count += 1 if count % 50 == 0: break if "file_url" in item: picture_url = item["file_url"] text = f'**Post ID**: `{item["id"]}`\n' text += f'**Author:** `{item["author"]}`\n' text += f'**Score**: `{item["score"]}`' buttons = [[ InlineKeyboardButton( 'Source', url=f'https://yande.re/post/show/{item["id"]}') ]] results.append( InlineQueryResultPhoto( photo_url=picture_url, title=f'Result:{item["id"]}', caption=text, description=f"Tags Matched: #{tags}", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=results, is_gallery=True, cache_time=CACHE_TIME) elif string.split()[0] == "konachan": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=results, switch_pm_text="Search for an image on Kanachan", switch_pm_parameter="start") return tags = string.split(None, 1)[1].replace("#", '') counter = randint(1, 10) while_counter = 1 while while_counter <= 50: while_counter += 1 data = await sauce(tags, counter, url="https://konachan.com/post.json?") counter += 1 count = 0 if len(data) == 0: break else: for item in data[offset:offset + NEXT_OFFSET]: count += 1 if count % 50 == 0: break if "file_url" in item: picture_url = item["file_url"] text = f'**Post ID**: `{item["id"]}`\n' text += f'**Author:** `{item["author"]}`\n' text += f'**Score**: `{item["score"]}`' buttons = [[ InlineKeyboardButton( 'Source', url=f'https://yande.re/post/show/{item["id"]}') ]] results.append( InlineQueryResultPhoto( photo_url=picture_url, title=f'Result:{item["id"]}', caption=text, description=f"Tags Matched: #{tags}", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=results, is_gallery=True, cache_time=CACHE_TIME) elif string.split()[0] == "danbooru": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=results, switch_pm_text="Search for an image on Danbooru", switch_pm_parameter="start") return tags = string.split(None, 1)[1].replace("#", '') counter = randint(1, 10) while_counter = 1 while while_counter <= 50: while_counter += 1 data = await sauce(tags, counter, url="https://danbooru.donmai.us/posts.json?") counter += 1 count = 0 if len(data) == 0: break else: for item in data[offset:offset + NEXT_OFFSET]: count += 1 if count % 50 == 0: break if "file_url" in item: picture_url = item["file_url"] text = f'**Post ID**: `{item["id"]}`\n' text += f'**Author:** `{item["tag_string_artist"]}`\n' text += f'**Score**: `{item["score"]}`' buttons = [[ InlineKeyboardButton( 'Source', url= f'https://danbooru.donmai.us/posts/{item["id"]}' ), InlineKeyboardButton( 'Artist', url= f'https://danbooru.donmai.us/artists/{item["uploader_id"]}' ) ]] results.append( InlineQueryResultPhoto( photo_url=picture_url, title=f'Result:{item["id"]}', caption=text, description=f"Tags Matched: #{tags}", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=results, is_gallery=True, cache_time=CACHE_TIME) return
async def owo(client, inline_query): string_given = inline_query.query.lower() if string_given.startswith("not4u"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_s.insert(stark_data) texts = f"Everyone Except {owo} Can Read This Message. \nClick Below To Check Message! \n**Note :** `Only He/She Can't Open It!`" ok_s = [(InlineQueryResultArticle( title="OwO! Not For You", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"nu_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("yt"): results = [] try: input = string_given.split(" ", maxsplit=1)[1] except: return search = SearchVideos(str(input), offset=1, mode="dict", max_results=50) rt = search.result() result_s = rt["search_result"] for i in result_s: url = i["link"] vid_title = i["title"] yt_id = i["id"] uploade_r = i["channel"] views = i["views"] thumb = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" capt = f""" **Video Title :** `{vid_title}` **Link :** `{url}` **Uploader :** `{uploade_r}` **Views :** `{views}` """ results.append( InlineQueryResultPhoto( photo_url=thumb, title=vid_title, caption=capt, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Download - Audio", callback_data=f"ytdl_{url}_audio"), InlineKeyboardButton(text="Download - Video", callback_data=f"ytdl_{url}_video") ]]), )) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif string_given.startswith("whisper"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_m.insert(stark_data) texts = f"A Whisper Has Been Sent For {owo} . \nClick Below To Check Message! \n**Note :** `Only He/She Can Open It!`" ok_s = [(InlineQueryResultArticle( title="Ssh! This is A Secret Message", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"sc_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("help"): total_ = len(CMD_LIST) bttn = [ [ InlineKeyboardButton(text="Command Help", callback_data=f"make_cmd_buttons") ], [ InlineKeyboardButton(text="Restart UserBot", callback_data=f"restart_bot") ], [ InlineKeyboardButton(text="Update UserBot", callback_data=f"updTe_bot") ], [InlineKeyboardButton(text="SyS Info", callback_data=f"sys_info")], ] if Config.LOAD_UNOFFICIAL_PLUGINS: total_ = len(XTRA_CMD_LIST) + len(CMD_LIST) nice_text = f"**FridayUserBot Commands** \n**Friday Version :** __{friday_version}__ \n**PyroGram Version :** __{__version__}__ \n**Total Plugins Loaded :** __{total_}__" await client.answer_inline_query( inline_query.id, cache_time=0, results=[(InlineQueryResultArticle( title="Help Article!", reply_markup=InlineKeyboardMarkup(bttn), input_message_content=InputTextMessageContent(nice_text), ))], )
async def inline_answer(_, inline_query: InlineQuery): results = [] i_q = inline_query.query string = i_q.lower() # All lower str_x = i_q.split(" ", 2) # trigger @username Text str_y = i_q.split(" ", 1) # trigger and Text string_split = string.split() # All lower and Split each word iq_user_id = inline_query.from_user.id if ( (iq_user_id in Config.OWNER_ID) or (iq_user_id in Config.SUDO_USERS) and Config.SUDO_ENABLED ): if string == "syntax": owner = [ [ InlineKeyboardButton( text="Contact", url="https://t.me/deleteduser420" ) ] ] results.append( InlineQueryResultPhoto( photo_url="https://coverfiles.alphacoders.com/123/123388.png", caption="Hey I solved **𝚂𝚢𝚗𝚝𝚊𝚡's ░ Σrr♢r**", reply_markup=InlineKeyboardMarkup(owner), ) ) if string == "age_verification_alert": buttons = [ [ InlineKeyboardButton( text="Yes I'm 18+", callback_data="age_verification_true" ), InlineKeyboardButton( text="No I'm Not", callback_data="age_verification_false" ), ] ] results.append( InlineQueryResultPhoto( photo_url="https://i.imgur.com/Zg58iXc.jpg", caption="**ARE YOU OLD ENOUGH FOR THIS ?**", reply_markup=InlineKeyboardMarkup(buttons), ) ) if str_y[0] == "reddit": reddit_api = "https://meme-api.herokuapp.com/gimme/" if len(str_y) == 2: subreddit_regex = r"^([a-zA-Z]+)\.$" match = re.search(subreddit_regex, str_y[1]) if match: subreddit_name = match.group(1) reddit_api += f"{subreddit_name}/30" else: return else: reddit_api += "30" try: r = await get_response.json(reddit_api) except ValueError: results.append( InlineQueryResultArticle( title="Reddit Api is Down !", input_message_content=InputTextMessageContent( "**Error Code: Status != 200**" ), thumb_url="https://i.imgur.com/7a7aPVa.png", ) ) else: if "code" in r: bool_is_gallery = False code = r["code"] code_message = r["message"] results.append( InlineQueryResultArticle( title=str(code), input_message_content=InputTextMessageContent( f"**Error Code: {code}**\n`{code_message}`" ), description="Enter A Valid Subreddit Name !", thumb_url="https://i.imgur.com/7a7aPVa.png", ) ) else: bool_is_gallery = True for post in r["memes"]: if "url" in post: postlink = post["postLink"] subreddit = post["subreddit"] title = post["title"] media_url = post["url"] author = post["author"] upvote = post["ups"] captionx = f"<b>{title}</b>\n" captionx += f"`Posted by u/{author}`\n" captionx += f"↕️ <code>{upvote}</code>\n" thumbnail = reddit_thumb_link(post["preview"]) if post["spoiler"]: captionx += "⚠️ Post marked as SPOILER\n" if post["nsfw"]: captionx += "🔞 Post marked Adult \n" buttons = [ [ InlineKeyboardButton( f"Source: r/{subreddit}", url=postlink ) ] ] if media_url.endswith(".gif"): results.append( InlineQueryResultAnimation( animation_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup(buttons), ) ) else: results.append( InlineQueryResultPhoto( photo_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup(buttons), ) ) await inline_query.answer( results=results, cache_time=1, is_gallery=bool_is_gallery, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if string == "alive": me = await userge.get_me() alive_info = Bot_Alive.alive_info(me) buttons = Bot_Alive.alive_buttons() if not Config.ALIVE_MEDIA: results.append( InlineQueryResultPhoto( photo_url=Bot_Alive.alive_default_imgs(), caption=alive_info, reply_markup=buttons, ) ) else: if Config.ALIVE_MEDIA.lower().strip() == "false": results.append( InlineQueryResultArticle( title="USERGE-X", input_message_content=InputTextMessageContent( alive_info, disable_web_page_preview=True ), description="ALIVE", reply_markup=buttons, ) ) else: _media_type, _media_url = await Bot_Alive.check_media_link( Config.ALIVE_MEDIA ) if _media_type == "url_gif": results.append( InlineQueryResultAnimation( animation_url=_media_url, caption=alive_info, reply_markup=buttons, ) ) elif _media_type == "url_image": results.append( InlineQueryResultPhoto( photo_url=_media_url, caption=alive_info, reply_markup=buttons, ) ) elif _media_type == "tg_media": c_file_id = Bot_Alive.get_bot_cached_fid() if c_file_id is None: try: c_file_id = get_file_id( await userge.bot.get_messages( _media_url[0], _media_url[1] ) ) except Exception as b_rr: await CHANNEL.log(str(b_rr)) if Bot_Alive.is_photo(c_file_id): results.append( InlineQueryResultCachedPhoto( file_id=c_file_id, caption=alive_info, reply_markup=buttons, ) ) else: results.append( InlineQueryResultCachedDocument( title="USERGE-X", file_id=c_file_id, caption=alive_info, description="ALIVE", reply_markup=buttons, ) ) if string == "geass": results.append( InlineQueryResultAnimation( animation_url="https://i.imgur.com/DeZHcRK.gif", caption="To defeat evil, I must become a greater evil", ) ) if str_y[0] == "inotes" and len(str_y) == 2: note_data = str_y[1].split("_", 2) note_data = [int(x) for x in note_data] if len(note_data) == 3: cnote = await get_inote( note_id=note_data[0], chat_id=note_data[1], user_id=note_data[2] ) type_ = cnote.get("type") if type_ == "image": results.append( InlineQueryResultCachedPhoto( file_id=cnote.get("file_id"), caption=cnote.get("caption"), reply_markup=cnote.get("buttons"), ) ) elif type_ == "media": results.append( InlineQueryResultCachedDocument( title="Inline Note", file_id=cnote.get("file_id"), caption=cnote.get("caption"), description=f"#{note_data[0]}", reply_markup=cnote.get("buttons"), ) ) else: results.append( InlineQueryResultArticle( title="Inline Note", input_message_content=InputTextMessageContent( cnote.get("caption"), disable_web_page_preview=True ), description=f"#{note_data[0]}", reply_markup=cnote.get("buttons"), ) ) if string == "gapps": buttons = [ [ InlineKeyboardButton("Open GApps", callback_data="open_gapps"), InlineKeyboardButton( "Flame GApps", callback_data="flame_gapps" ), ], [InlineKeyboardButton("Nik GApps", callback_data="nik_gapps")], ] results.append( InlineQueryResultArticle( title="GApps", input_message_content=InputTextMessageContent( "[\u200c](https://i.imgur.com/BZBMrfn.jpg) **LATEST Android 10 arm64 GApps**" ), description="Get Latest GApps Download Links Directly from SF", thumb_url="https://i.imgur.com/Npzw8Ph.png", reply_markup=InlineKeyboardMarkup(buttons), ) ) if len(string_split) == 2 and (string_split[0] == "ofox"): codename = string_split[1] t = TelegraphPoster(use_api=True) t.create_api_token("Userge-X") photo = "https://i.imgur.com/582uaSk.png" api_host = "https://api.orangefox.download/v2/device/" try: async with get_response.get_session() as session: r = await get_response.json( f"{api_host}{codename}", session=session ) s = await get_response.json( f"{api_host}{codename}/releases/stable/last", session=session, ) except ValueError: return info = f"📱 **Device**: {r['fullname']}\n" info += f"👤 **Maintainer**: {r['maintainer']['name']}\n\n" recovery = f"🦊 <code>{s['file_name']}</code>\n" recovery += f"📅 {s['date']}\n" recovery += f"ℹ️ **Version:** {s['version']}\n" recovery += f"📌 **Build Type:** {s['build_type']}\n" recovery += f"🔰 **Size:** {s['size_human']}\n\n" recovery += "📍 **Changelog:**\n" recovery += f"<code>{s['changelog']}</code>\n\n" msg = info msg += recovery notes_ = s.get("notes") if notes_: notes = t.post(title="READ Notes", author="", text=notes_) buttons = [ [ InlineKeyboardButton("🗒️ NOTES", url=notes["url"]), InlineKeyboardButton("⬇️ DOWNLOAD", url=s["url"]), ] ] else: buttons = [[InlineKeyboardButton(text="⬇️ DOWNLOAD", url=s["url"])]] results.append( InlineQueryResultPhoto( photo_url=photo, thumb_url="https://i.imgur.com/o0onLYB.jpg", title="Latest OFOX RECOVERY", description=f"For device : {codename}", caption=msg, reply_markup=InlineKeyboardMarkup(buttons), ) ) if string == "repo": results.append(REPO_X) if len(str_y) == 2 and str_y[0] == "anime": for i in await Anime.search(str_y[1]): results.append( InlineQueryResultArticle( title=i.get("title"), input_message_content=InputTextMessageContent( f'[\u200c]({i.get("image")})**{i.get("title")}**\n{i.get("release")}' ), description=i.get("release"), thumb_url=i.get("image"), reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="⬇️ Download", callback_data=f'get_eps{i.get("key")}', ) ] ] ), ) ) if len(results) != 0: await inline_query.answer( results=results[:50], cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if str_y[0] == "spoiler": if not os.path.exists(f"{Config.CACHE_PATH}/spoiler_db.json"): results.append( InlineQueryResultArticle( title="No Spoiler Found", input_message_content=InputTextMessageContent( "No Spoiler Found !\nLet's Add Some 😈" ), description="See .help spoiler for more info", ) ) else: bot_name = (await userge.bot.get_me()).username if len(str_y) == 2: link = f"https://t.me/{bot_name}?start=spoiler_{str_y[1]}" buttons = [ [InlineKeyboardButton(text="View Spoiler", url=link)] ] results.append( InlineQueryResultArticle( title="Spoiler", input_message_content=InputTextMessageContent( "<b>Click To View The Spoiler !</b>" ), description="Click To Send", thumb_url="https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup(buttons), ) ) else: fo = open(f"{Config.CACHE_PATH}/spoiler_db.json") view_db = ujson.load(fo) fo.close() if len(view_db) != 0: for numm, spoilerr in enumerate(view_db, start=1): buttons = [ [ InlineKeyboardButton( text="View Spoiler", url=f"https://t.me/{bot_name}?start=spoiler_{spoilerr}", ) ] ] saved_at = view_db.get(spoilerr, None) savetime = ( saved_at.get("savetime", None) if saved_at else None ) results.append( InlineQueryResultArticle( title=f"#{numm} Spoiler", input_message_content=InputTextMessageContent( "<b>Click To View The Spoiler !</b>" ), description=f"Created At: {savetime}", thumb_url="https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup(buttons), ) ) if str_x[0].lower() == "op" and len(str_x) > 1: txt = i_q[3:] opinion = os.path.join(Config.CACHE_PATH, "emoji_data.txt") if os.path.exists(opinion): with open(opinion) as fo: view_data = ujson.load(fo) # Uniquely identifies an inline message new_id = {int(inline_query.id): [{}]} view_data.update(new_id) else: view_data = {int(inline_query.id): [{}]} with open(opinion, "w") as outfile: ujson.dump(view_data, outfile) buttons = [ [ InlineKeyboardButton( "👍", callback_data=f"op_y_{inline_query.id}" ), InlineKeyboardButton( "👎", callback_data=f"op_n_{inline_query.id}" ), ] ] results.append( InlineQueryResultArticle( title="Ask For Opinion", input_message_content=InputTextMessageContent(txt), description=f"Q. {txt}", thumb_url="https://i.imgur.com/Zlc98qS.jpg", reply_markup=InlineKeyboardMarkup(buttons), ) ) if "btn_" in str_y[0] or str_y[0] == "btn": inline_db_path = f"{Config.CACHE_PATH}/inline_db.json" if os.path.exists(inline_db_path): with open(inline_db_path, "r") as data_file: view_db = ujson.load(data_file) data_count_n = 1 reverse_list = list(view_db) reverse_list.reverse() for butt_ons in reverse_list: if data_count_n > 30: view_db.pop(butt_ons, None) data_count_n += 1 with open(inline_db_path, "w") as data_file: ujson.dump(view_db, data_file) if str_y[0] == "btn": inline_storage = list(view_db) else: rnd_id = (str_y[0].split("_", 1))[1] inline_storage = [rnd_id] if len(inline_storage) == 0: return for inline_content in inline_storage: inline_db = view_db.get(inline_content) if inline_db: if ( inline_db["media_valid"] and int(inline_db["media_id"]) != 0 ): saved_msg = await userge.bot.get_messages( Config.LOG_CHANNEL_ID, int(inline_db["media_id"]) ) media_data = get_file_id(saved_msg) textx, buttonsx = pb(inline_db["msg_content"]) if inline_db["media_valid"]: if saved_msg.photo: results.append( InlineQueryResultCachedPhoto( file_id=media_data, caption=textx, reply_markup=buttonsx, ) ) else: results.append( InlineQueryResultCachedDocument( title=textx, file_id=media_data, caption=textx, description="Inline Button", reply_markup=buttonsx, ) ) else: results.append( InlineQueryResultArticle( title=textx, input_message_content=InputTextMessageContent( textx ), reply_markup=buttonsx, ) ) if str_y[0].lower() == "stylish" and len(str_y) == 2: results = [] for f_name in Styled.font_choice: styled_str = font_gen(f_name, str_y[1]) results.append( InlineQueryResultArticle( title=f_name.upper(), input_message_content=InputTextMessageContent( f"`{styled_str}`" ), description=styled_str, ) ) await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if str_x[0].lower() in ["secret", "troll"] and len(str_x) == 3: user_name = str_x[1] msg = str_x[2] try: receiver = await userge.get_users(user_name) except (BadRequest, IndexError): return secret = os.path.join(Config.CACHE_PATH, "secret.json") key_ = rand_key() r_name = ( ("@" + receiver.username) if receiver.username else f"{receiver.first_name} {receiver.last_name or ''}" ) secret_data = { key_: { "sender": iq_user_id, "receiver": {"id": receiver.id, "name": r_name}, "msg": msg, "views": [], } } if os.path.exists(secret): with open(secret) as outfile: view_data = ujson.load(outfile) view_data.update(secret_data) else: view_data = secret_data # Save with open(secret, "w") as r: ujson.dump(view_data, r, indent=4) if str_x[0].lower() == "secret": c_data = f"secret_{key_}" i_m_content = f"📩 <b>Secret Msg</b> for <b>{r_name}</b>. Only he/she can open it." i_l_des = f"Send Secret Message to: {r_name}" title = "Send A Secret Message" thumb_img = "https://i.imgur.com/c5pZebC.png" else: c_data = f"troll_{key_}" i_m_content = f"😈 Only <b>{r_name}</b> can't view this message. UwU" i_l_des = f"Message Hidden from {r_name}" title = "😈 Troll" thumb_img = "https://i.imgur.com/0vg5B0A.png" buttons = [[InlineKeyboardButton("🔐 SHOW", callback_data=c_data)]] results.append( InlineQueryResultArticle( title=title, input_message_content=InputTextMessageContent(i_m_content), description=i_l_des, thumb_url=thumb_img, reply_markup=InlineKeyboardMarkup(buttons), ) ) if str_y[0].lower() == "ytdl" and len(str_y) == 2: link = get_yt_video_id(str_y[1].strip()) found_ = True if link is None: search = VideosSearch(str_y[1].strip(), limit=15) resp = (search.result()).get("result") if len(resp) == 0: found_ = False else: outdata = await result_formatter(resp) key_ = rand_key() ytsearch_data.store_(key_, outdata) buttons = InlineKeyboardMarkup( [ [ InlineKeyboardButton( text=f"1 / {len(outdata)}", callback_data=f"ytdl_next_{key_}_1", ) ], [ InlineKeyboardButton( text="📜 List all", callback_data=f"ytdl_listall_{key_}_1", ), InlineKeyboardButton( text="⬇️ Download", callback_data=f'ytdl_download_{outdata[1]["video_id"]}_0', ), ], ] ) caption = outdata[1]["message"] photo = outdata[1]["thumb"] else: caption, buttons = await download_button(link, body=True) photo = await get_ytthumb(link) if found_: results.append( InlineQueryResultPhoto( photo_url=photo, title=link, description="⬇️ Click to Download", caption=caption, reply_markup=buttons, ) ) else: results.append( InlineQueryResultArticle( title="not Found", input_message_content=InputTextMessageContent( f"No Results found for `{str_y[1]}`" ), description="INVALID", ) ) MAIN_MENU = InlineQueryResultArticle( title="Main Menu", input_message_content=InputTextMessageContent(" 𝐒𝐇𝐀𝐑𝐈𝐍𝐆𝐀𝐍 MAIN MENU "), url="https://github.com/code-rgb/USERGE-X", description="Sharingan Main Menu", thumb_url="https://telegra.ph/file/8fa91f9c7f6f4f6b8fa6c.jpg", reply_markup=InlineKeyboardMarkup(main_menu_buttons()), ) results.append(MAIN_MENU) if len(results) != 0: await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) else: results.append(REPO_X) owner_name = (await userge.get_me()).first_name await inline_query.answer( results=results, cache_time=1, switch_pm_text=f"This bot is only for {owner_name}", switch_pm_parameter="start", )
async def inline_answer(_, inline_query: InlineQuery): results = [] i_q = inline_query.query string = i_q.lower() # All lower str_x = i_q.split(" ", 2) # trigger @username Text str_y = i_q.split(" ", 1) # trigger and Text string_split = string.split() # All lower and Split each word if (inline_query.from_user.id == Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS): if string == "syntax": owner = [[ InlineKeyboardButton(text="Contact", url="https://t.me/deleteduser420") ]] results.append( InlineQueryResultPhoto( photo_url= "https://coverfiles.alphacoders.com/123/123388.png", caption="Hey I solved **𝚂𝚢𝚗𝚝𝚊𝚡's ░ Σrr♢r**", reply_markup=InlineKeyboardMarkup(owner), )) if str_y[0] == "ytdl": if len(str_y) == 2: link = str_y[1] x = ytdl.YoutubeDL({ "no-playlist": True }).extract_info(link, download=False) formats = x.get("formats", [x]) ytlink_code = x.get("id", None) # uploader = x.get('uploader', None) # channel_url = x.get('channel_url', None) vid_title = x.get("title", None) # upload_date = date_formatter(str(x.get('upload_date', None))) vid_thumb = get_ytthumb(ytlink_code) buttons = ytdl_btn_generator(formats, ytlink_code) caption_text = f"**{vid_title}**" # caption_text += f"🔗 [Link]({link}) | 📅 : {upload_date}" # caption_text += f"📹 : [{uploader}]({channel_url})" results.append( InlineQueryResultPhoto( photo_url=vid_thumb, title=vid_title, description="⬇️ Click to Download", caption=caption_text, reply_markup=InlineKeyboardMarkup(buttons), )) if string == "age_verification_alert": buttons = [[ InlineKeyboardButton( text="Yes I'm 18+", callback_data="age_verification_true"), InlineKeyboardButton( text="No I'm Not", callback_data="age_verification_false"), ]] results.append( InlineQueryResultPhoto( photo_url="https://i.imgur.com/Zg58iXc.jpg", caption="**ARE YOU OLD ENOUGH FOR THIS ?**", reply_markup=InlineKeyboardMarkup(buttons), )) if str_y[0] == "reddit": reddit_api = "https://meme-api.herokuapp.com/gimme/" if len(str_y) == 2: subreddit_regex = r"^([a-zA-Z]+)\.$" match = re.search(subreddit_regex, str_y[1]) if match: subreddit_name = match.group(1) reddit_api += f"{subreddit_name}/30" else: return else: reddit_api += "30" cn = requests.get(reddit_api) r = cn.json() if "code" in r: bool_is_gallery = False code = r["code"] code_message = r["message"] results.append( InlineQueryResultArticle( title=str(code), input_message_content=InputTextMessageContent( f"**Error Code: {code}**\n`{code_message}`"), description="Enter A Valid Subreddit Name !", thumb_url="https://i.imgur.com/7a7aPVa.png", )) else: bool_is_gallery = True for post in r["memes"]: if "url" in post: postlink = post["postLink"] subreddit = post["subreddit"] title = post["title"] media_url = post["url"] author = post["author"] upvote = post["ups"] captionx = f"<b>{title}</b>\n" captionx += f"`Posted by u/{author}`\n" captionx += f"↕️ <code>{upvote}</code>\n" thumbnail = reddit_thumb_link(post["preview"]) if post["spoiler"]: captionx += "⚠️ Post marked as SPOILER\n" if post["nsfw"]: captionx += "🔞 Post marked Adult \n" buttons = [[ InlineKeyboardButton(f"Source: r/{subreddit}", url=postlink) ]] if media_url.endswith(".gif"): results.append( InlineQueryResultAnimation( animation_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup( buttons), )) else: results.append( InlineQueryResultPhoto( photo_url=media_url, thumb_url=thumbnail, caption=captionx, reply_markup=InlineKeyboardMarkup( buttons), )) await inline_query.answer( results=results, cache_time=1, is_gallery=bool_is_gallery, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if string == "rick": rick = [[ InlineKeyboardButton( text="🔍", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") ]] results.append( InlineQueryResultArticle( title="Not a Rick Roll", input_message_content=InputTextMessageContent( "Search Results"), description="Definately Not a Rick Roll", thumb_url="https://i.imgur.com/hRCaKAy.png", reply_markup=InlineKeyboardMarkup(rick), )) if string == "alive": buttons = [[ InlineKeyboardButton("🔧 SETTINGS", callback_data="settings_btn"), InlineKeyboardButton(text="⚡️ REPO", url=Config.UPSTREAM_REPO), ]] alive_info = f""" **[USERGE-X](https://telegram.dog/x_xtests) is Up and Running** • 🐍 Python : `v{versions.__python_version__}` • 🔥 Pyrogram : `v{versions.__pyro_version__}` • 🧬 𝑿 : `v{get_version()}` 🕔 Uptime : {userge.uptime} """ if not MEDIA_URL and Config.ALIVE_MEDIA: await get_alive_() if MEDIA_URL: if MEDIA_TYPE == "url_gif": results.append( InlineQueryResultAnimation( animation_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) elif MEDIA_TYPE == "url_image": results.append( InlineQueryResultPhoto( photo_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) elif MEDIA_TYPE == "tg_image": results.append( InlineQueryResultCachedPhoto( file_id=MEDIA_URL[0], file_ref=MEDIA_URL[1], caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) else: results.append( InlineQueryResultCachedDocument( title="USERGE-X", file_id=MEDIA_URL[0], file_ref=MEDIA_URL[1], caption=alive_info, description="ALIVE", reply_markup=InlineKeyboardMarkup(buttons), )) else: # default random_alive = random.choice(ALIVE_IMGS) results.append( InlineQueryResultPhoto( photo_url=random_alive, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons), )) if string == "geass": results.append( InlineQueryResultAnimation( animation_url="https://i.imgur.com/DeZHcRK.gif", caption="To defeat evil, I must become a greater evil", )) if string == "gapps": buttons = [ [ InlineKeyboardButton("Open GApps", callback_data="open_gapps"), InlineKeyboardButton("Flame GApps", callback_data="flame_gapps"), ], [ InlineKeyboardButton("Nik GApps", callback_data="nik_gapps") ], ] results.append( InlineQueryResultArticle( title="GApps", input_message_content=InputTextMessageContent( "[\u200c](https://i.imgur.com/BZBMrfn.jpg) **LATEST Android 10 arm64 GApps**" ), description= "Get Latest GApps Download Links Directly from SF", thumb_url="https://i.imgur.com/Npzw8Ph.png", reply_markup=InlineKeyboardMarkup(buttons), )) if len(string_split ) == 2: # workaround for list index out of range if string_split[0] == "ofox": codename = string_split[1] t = TelegraphPoster(use_api=True) t.create_api_token("Userge-X") photo = "https://i.imgur.com/582uaSk.png" api_host = "https://api.orangefox.download/v2/device/" try: cn = requests.get(f"{api_host}{codename}") r = cn.json() except ValueError: return s = requests.get( f"{api_host}{codename}/releases/stable/last").json() info = f"📱 **Device**: {r['fullname']}\n" info += f"👤 **Maintainer**: {r['maintainer']['name']}\n\n" recovery = f"🦊 <code>{s['file_name']}</code>\n" recovery += f"📅 {s['date']}\n" recovery += f"ℹ️ **Version:** {s['version']}\n" recovery += f"📌 **Build Type:** {s['build_type']}\n" recovery += f"🔰 **Size:** {s['size_human']}\n\n" recovery += "📍 **Changelog:**\n" recovery += f"<code>{s['changelog']}</code>\n\n" msg = info msg += recovery notes_ = s.get("notes") if notes_: notes = t.post(title="READ Notes", author="", text=notes_) buttons = [[ InlineKeyboardButton("🗒️ NOTES", url=notes["url"]), InlineKeyboardButton("⬇️ DOWNLOAD", url=s["url"]), ]] else: buttons = [[ InlineKeyboardButton(text="⬇️ DOWNLOAD", url=s["url"]) ]] results.append( InlineQueryResultPhoto( photo_url=photo, thumb_url="https://i.imgur.com/o0onLYB.jpg", title="Latest OFOX RECOVERY", description=f"For device : {codename}", caption=msg, reply_markup=InlineKeyboardMarkup(buttons), )) if string == "repo": results.append(REPO_X) if str_y[0] == "spoiler": if not os.path.exists("./userge/xcache/spoiler_db.json"): results.append( InlineQueryResultArticle( title="No Spoiler Found", input_message_content=InputTextMessageContent( "No Spoiler Found !\nLet's Add Some 😈"), description="See .help spoiler for more info", )) else: bot_name = (await userge.bot.get_me()).username if len(str_y) == 2: link = f"https://t.me/{bot_name}?start=spoiler_{str_y[1]}" buttons = [[ InlineKeyboardButton(text="View Spoiler", url=link) ]] results.append( InlineQueryResultArticle( title="Spoiler", input_message_content=InputTextMessageContent( "<b>Click To View The Spoiler !</b>"), description="Click To Send", thumb_url= "https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup(buttons), )) else: view_db = json.load( open("./userge/xcache/spoiler_db.json")) if len(view_db) != 0: numm = 0 for spoilerr in view_db: numm += 1 buttons = [[ InlineKeyboardButton( text="View Spoiler", url= f"https://t.me/{bot_name}?start=spoiler_{spoilerr}", ) ]] saved_at = view_db.get(spoilerr, None) savetime = (saved_at.get("savetime", None) if saved_at else None) results.append( InlineQueryResultArticle( title=f"#{numm} Spoiler", input_message_content= InputTextMessageContent( "<b>Click To View The Spoiler !</b>" ), description=f"Created At: {savetime}", thumb_url= "https://telegra.ph/file/ee3a6439494463acd1a3a.jpg", reply_markup=InlineKeyboardMarkup( buttons), )) if str_x[0].lower() == "op" and len(str_x) > 1: txt = i_q[3:] opinion = os.path.join(PATH, "emoji_data.txt") try: view_data = json.load(open(opinion)) except: view_data = False if view_data: # Uniquely identifies an inline message new_id = {int(inline_query.id): [{}]} view_data.update(new_id) json.dump(view_data, open(opinion, "w")) else: d = {int(inline_query.id): [{}]} json.dump(d, open(opinion, "w")) buttons = [[ InlineKeyboardButton( "👍", callback_data=f"op_y_{inline_query.id}"), InlineKeyboardButton( "👎", callback_data=f"op_n_{inline_query.id}"), ]] results.append( InlineQueryResultArticle( title="Ask For Opinion", input_message_content=InputTextMessageContent(txt), description=f"Q. {txt}", thumb_url="https://i.imgur.com/Zlc98qS.jpg", reply_markup=InlineKeyboardMarkup(buttons), )) if string == "buttonnn": async for data in BUTTON_BASE.find(): button_data = data["msg_data"] text, buttons = pb(button_data) try: photo_url = data["photo_url"] except KeyError: photo_url = None if photo_url: results.append( InlineQueryResultPhoto(photo_url=photo_url, caption=text, reply_markup=buttons)) else: results.append( InlineQueryResultArticle( title=text, input_message_content=InputTextMessageContent( text), reply_markup=buttons, )) if str_y[0].lower() == "stylish": if len(str_y) == 2: results = [] input_text = str_y[1] font_names = [ "serif", "sans", "sans_i", "serif_i", "medi_b", "medi", "double", "cursive_b", "cursive", "bigsmall", "reverse", "circle", "circle_b", "mono", "square_b", "square", "smoth", "goth", "wide", "web", "weeb", "weeeb", ] for f_name in font_names: styled_str = await font_gen(f_name, input_text) results.append( InlineQueryResultArticle( title=f_name.upper(), input_message_content=InputTextMessageContent( styled_str), description=styled_str, )) await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) return if str_x[0].lower() == "secret": if len(str_x) == 3: user_name = str_x[1] msg = str_x[2] try: a = await userge.get_users(user_name) user_id = a.id except: return secret = os.path.join(PATH, "secret.txt") try: view_data = json.load(open(secret)) except: view_data = False if view_data: # Uniquely identifies an inline message new_id = { str(inline_query.id): { "user_id": user_id, "msg": msg } } view_data.update(new_id) json.dump(view_data, open(secret, "w")) else: d = { str(inline_query.id): { "user_id": user_id, "msg": msg } } json.dump(d, open(secret, "w")) buttons = [[ InlineKeyboardButton( "🔐 SHOW", callback_data=f"secret_{inline_query.id}") ]] results.append( InlineQueryResultArticle( title="Send A Secret Message", input_message_content=InputTextMessageContent( f"📩 <b>Secret Msg</b> for {user_name}. Only he/she can open it." ), description=f"Send Secret Message to: {user_name}", thumb_url="https://i.imgur.com/c5pZebC.png", reply_markup=InlineKeyboardMarkup(buttons), )) MAIN_MENU = InlineQueryResultArticle( title="Main Menu", input_message_content=InputTextMessageContent( " 𝐔𝐒𝐄𝐑𝐆𝐄-𝐗 𝗠𝗔𝗜𝗡 𝗠𝗘𝗡𝗨 "), url="https://github.com/lostb053/USERGE-X", description="Userge-X Main Menu", thumb_url="https://i.imgur.com/NfIsDQ5.png", reply_markup=InlineKeyboardMarkup(main_menu_buttons()), ) results.append(MAIN_MENU) if len(results) != 0: await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline", ) else: results.append(REPO_X) owner_name = (await userge.get_me()).first_name await inline_query.answer( results=results, cache_time=1, switch_pm_text=f"This bot is only for {owner_name}", switch_pm_parameter="start", )
async def owo(client, inline_query): string_given = inline_query.query.lower() if "modapk" in inline_query.query.lower(): if not " " in inline_query.query.lower(): return string_given = inline_query.query.lower() sgname = string_given.split(" ", maxsplit=1)[1] print(sgname) PabloEscobar = ( f"https://an1.com/tags/MOD/?story={sgname}&do=search&subaction=search" ) r = requests.get(PabloEscobar) results = [] soup = BeautifulSoup(r.content, "html5lib") mydivs = soup.find_all("div", {"class": "search-results"}) Pop = soup.find_all("div", {"class": "title"}) cnte = len(mydivs) for cnt in range(cnte): sucker = mydivs[cnt] pH9 = sucker.find("a").contents[0] file_name = pH9 pH = sucker.findAll("img") imme = pH[0]["src"] Pablo = Pop[0].a["href"] ro = requests.get(Pablo) soupe = BeautifulSoup(ro.content, "html5lib") myopo = soupe.find_all("div", {"class": "item"}) capt = f"**{file_name}** \n** {myopo[0].text}**\n**{myopo[1].text}**\n**{myopo[2].text}**\n**{myopo[3].text}**" mydis0 = soupe.find_all("a", {"class": "get-product"}) Lol9 = mydis0[0] lemk = "https://an1.com" + Lol9["href"] results.append( InlineQueryResultPhoto( photo_url=imme, title=file_name, caption=capt, reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="<<! Download Link!>>", callback_data=f"apk_{lemk}", ), ] ] ), ) ) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif "not4u" in string_given: if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = ( f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})" ) chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_s.insert(stark_data) texts = f"Everyone Except {owo} Can Read This Message. \nClick Below To Check Message! \n**Note :** `Only He/She Can't Open It!`" ok_s = [ ( InlineQueryResultArticle( title="OwO! Not For You", reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="Show Message !", callback_data=f"nu_{randomc}" ) ] ] ), input_message_content=InputTextMessageContent(texts), ) ) ] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif "whisper" in string_given: if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = ( f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})" ) chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_m.insert(stark_data) texts = f"A Whisper Has Been Sent For {owo} . \nClick Below To Check Message! \n**Note :** `Only He/She Can Open It!`" ok_s = [ ( InlineQueryResultArticle( title="Ssh! This is A Secret Message", reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="Show Message !", callback_data=f"sc_{randomc}" ) ] ] ), input_message_content=InputTextMessageContent(texts), ) ) ] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif "help" in string_given: bttn = [ [ InlineKeyboardButton( text="Main Command Help", callback_data=f"make_basic_button_True" ) ] ] if Config.LOAD_UNOFFICIAL_PLUGINS: bttn = [ [ InlineKeyboardButton( text="Xtra Command Help", callback_data=f"make_basic_button_False", ) ], [ InlineKeyboardButton( text="Main Command Help", callback_data=f"make_basic_button_True", ) ], ] nice_text = f"**FridayUserBot Commands** \n**Friday Version :** __{friday_version}__ \n**PyroGram Version :** __{__version__}__ \n**Total Plugins Loaded :** __{len(CMD_LIST)}__" await client.answer_inline_query( inline_query.id, cache_time=0, results=[ ( InlineQueryResultArticle( title="Help Article!", reply_markup=InlineKeyboardMarkup(bttn), input_message_content=InputTextMessageContent(nice_text), ) ) ], )
async def inline_answer(_, inline_query: InlineQuery): results = [] i_q = inline_query.query string = i_q.lower() # All lower str_x = i_q.split(" ", 2) # trigger @username Text str_y = i_q.split(" ", 1) # trigger and Text string_split = string.split() # All lower and Split each word if inline_query.from_user.id == Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS: if string == "syntax": owner = [[ InlineKeyboardButton(text="Contact", url="https://t.me/deleteduser420") ]] results.append( InlineQueryResultPhoto( photo_url= "https://coverfiles.alphacoders.com/123/123388.png", caption="Hey I solved **𝚂𝚢𝚗𝚝𝚊𝚡's ░ Σrr♢r**", reply_markup=InlineKeyboardMarkup(owner))) if string == "rick": rick = [[ InlineKeyboardButton( text="🔍", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") ]] results.append( InlineQueryResultArticle( title="Not a Rick Roll", input_message_content=InputTextMessageContent( "Search Results"), description="Definately Not a Rick Roll", thumb_url="https://i.imgur.com/hRCaKAy.png", reply_markup=InlineKeyboardMarkup(rick))) if string == "alive": buttons = [[ InlineKeyboardButton("🔧 SETTINGS", callback_data="settings_btn"), InlineKeyboardButton(text="⚡️ REPO", url=Config.UPSTREAM_REPO) ]] alive_info = f""" **[USERGE-X](https://telegram.dog/x_xtests) is Up and Running** • 🐍 Python : `v{versions.__python_version__}` • 🔥 Pyrogram : `v{versions.__pyro_version__}` • 🧬 𝑿 : `v{get_version()}` 🕔 Uptime : {userge.uptime} """ if not MEDIA_URL: check_url() if MEDIA_URL: if MEDIA_TYPE == 'gif': results.append( InlineQueryResultAnimation( animation_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons))) else: results.append( InlineQueryResultPhoto( photo_url=MEDIA_URL, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons))) else: #default random_alive = random.choice(ALIVE_IMGS) results.append( InlineQueryResultPhoto( photo_url=random_alive, caption=alive_info, reply_markup=InlineKeyboardMarkup(buttons))) if string == "geass": results.append( InlineQueryResultAnimation( animation_url="https://i.imgur.com/DeZHcRK.gif", caption="To defeat evil, I must become a greater evil", )) if string == "gapps": buttons = [[ InlineKeyboardButton("Open GApps", callback_data="open_gapps"), InlineKeyboardButton("Flame GApps", callback_data="flame_gapps") ], [ InlineKeyboardButton("Nik GApps", callback_data="nik_gapps") ]] results.append( InlineQueryResultArticle( title="GApps", input_message_content=InputTextMessageContent( "[\u200c](https://i.imgur.com/BZBMrfn.jpg) **LATEST Android 10 arm64 GApps**" ), description= "Get Latest GApps Download Links Directly from SF", thumb_url="https://i.imgur.com/Npzw8Ph.png", reply_markup=InlineKeyboardMarkup(buttons))) if len(string_split) == 2: #workaround for list index out of range if string_split[0] == "ofox": codename = string_split[1] t = TelegraphPoster(use_api=True) t.create_api_token('Userge-X') photo = "https://i.imgur.com/582uaSk.png" api_host = 'https://api.orangefox.download/v2/device/' try: cn = requests.get(f"{api_host}{codename}") r = cn.json() except ValueError: return s = requests.get( f"{api_host}{codename}/releases/stable/last").json() info = f"📱 **Device**: {r['fullname']}\n" info += f"👤 **Maintainer**: {r['maintainer']['name']}\n\n" recovery = f"🦊 <code>{s['file_name']}</code>\n" recovery += f"📅 {s['date']}\n" recovery += f"ℹ️ **Version:** {s['version']}\n" recovery += f"📌 **Build Type:** {s['build_type']}\n" recovery += f"🔰 **Size:** {s['size_human']}\n\n" recovery += "📍 **Changelog:**\n" recovery += f"<code>{s['changelog']}</code>\n\n" msg = info msg += recovery notes_ = s.get('notes') if notes_: notes = t.post(title='READ Notes', author="", text=notes_) buttons = [[ InlineKeyboardButton("🗒️ NOTES", url=notes['url']), InlineKeyboardButton("⬇️ DOWNLOAD", url=s['url']) ]] else: buttons = [[ InlineKeyboardButton(text="⬇️ DOWNLOAD", url=s['url']) ]] results.append( InlineQueryResultPhoto( photo_url=photo, thumb_url="https://i.imgur.com/o0onLYB.jpg", title="Latest OFOX RECOVERY", description=f"For device : {codename}", caption=msg, reply_markup=InlineKeyboardMarkup(buttons))) if string == "repo": results.append(REPO_X) if str_x[0].lower() == "op" and len(str_x) > 1: txt = i_q[3:] opinion = os.path.join(PATH, "emoji_data.txt") try: view_data = json.load(open(opinion)) except: view_data = False if view_data: # Uniquely identifies an inline message new_id = {int(inline_query.id): [{}]} view_data.update(new_id) json.dump(view_data, open(opinion, 'w')) else: d = {int(inline_query.id): [{}]} json.dump(d, open(opinion, 'w')) buttons = [[ InlineKeyboardButton( "👍", callback_data=f"op_y_{inline_query.id}"), InlineKeyboardButton( "👎", callback_data=f"op_n_{inline_query.id}") ]] results.append( InlineQueryResultArticle( title="Ask For Opinion", input_message_content=InputTextMessageContent(txt), description=f"Q. {txt}", thumb_url="https://i.imgur.com/Zlc98qS.jpg", reply_markup=InlineKeyboardMarkup(buttons))) if string == "buttonnn": async for data in BUTTON_BASE.find(): button_data = data['msg_data'] text, buttons = pb(button_data) try: photo_url = data['photo_url'] except KeyError: photo_url = None if photo_url: results.append( InlineQueryResultPhoto(photo_url=photo_url, caption=text, reply_markup=buttons)) else: results.append( InlineQueryResultArticle( title=text, input_message_content=InputTextMessageContent( text), reply_markup=buttons)) if str_y[0].lower() == "stylish": if len(str_y) == 2: results = [] input_text = str_y[1] font_names = [ 'serif', 'sans', 'sans_i', 'serif_i', 'medi_b', 'medi', 'double', 'cursive_b', 'cursive', 'bigsmall', 'reverse', 'circle', 'circle_b', 'mono', 'square_b', 'square', 'smoth', 'goth', 'wide', 'web', 'weeb', 'weeeb' ] for f_name in font_names: styled_str = await font_gen(f_name, input_text) results.append( InlineQueryResultArticle( title=f_name.upper(), input_message_content=InputTextMessageContent( styled_str), description=styled_str)) await inline_query.answer( results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline") return if str_x[0].lower() == "secret": if len(str_x) == 3: user_name = str_x[1] msg = str_x[2] try: a = await userge.get_users(user_name) user_id = a.id except: return secret = os.path.join(PATH, "secret.txt") try: view_data = json.load(open(secret)) except: view_data = False if view_data: # Uniquely identifies an inline message new_id = { str(inline_query.id): { 'user_id': user_id, 'msg': msg } } view_data.update(new_id) json.dump(view_data, open(secret, 'w')) else: d = { str(inline_query.id): { 'user_id': user_id, 'msg': msg } } json.dump(d, open(secret, 'w')) buttons = [[ InlineKeyboardButton( "🔐 SHOW", callback_data=f"secret_{inline_query.id}") ]] results.append( InlineQueryResultArticle( title="Send A Secret Message", input_message_content=InputTextMessageContent( f"📩 <b>Secret Msg</b> for {user_name}. Only he/she can open it." ), description=f"Send Secret Message to: {user_name}", thumb_url="https://i.imgur.com/c5pZebC.png", reply_markup=InlineKeyboardMarkup(buttons))) MAIN_MENU = InlineQueryResultArticle( title="Main Menu", input_message_content=InputTextMessageContent( " 𝐔𝐒𝐄𝐑𝐆𝐄-𝐗 𝗠𝗔𝗜𝗡 𝗠𝗘𝗡𝗨 "), url="https://github.com/code-rgb/USERGE-X", description="Userge-X Main Menu", thumb_url="https://i.imgur.com/1xsOo9o.png", reply_markup=InlineKeyboardMarkup(main_menu_buttons())) results.append(MAIN_MENU) if len(results) != 0: await inline_query.answer(results=results, cache_time=1, switch_pm_text="Available Commands", switch_pm_parameter="inline") else: results.append(REPO_X) owner_name = (await userge.get_me()).first_name await inline_query.answer( results=results, cache_time=1, switch_pm_text=f"This bot is only for {owner_name}", switch_pm_parameter="start")
async def owo(client, inline_query): string_given = inline_query.query.lower() if string_given.startswith("not4u"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_s.insert(stark_data) texts = f"Everyone Except {owo} Can Read This Message. \nClick Below To Check Message! \n**Note :** `Only He/She Can't Open It!`" ok_s = [(results.append( title="OwO! Not For You", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"nu_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("yt"): results = [] try: input = string_given.split(" ", maxsplit=1)[1] except: return search = SearchVideos(str(input), offset=1, mode="dict", max_results=50) rt = search.result() result_s = rt["search_result"] for i in result_s: url = i["link"] vid_title = i["title"] yt_id = i["id"] uploade_r = i["channel"] views = i["views"] thumb = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" capt = f""" **Video Title :** `{vid_title}` **Link :** `{url}` **Uploader :** `{uploade_r}` **Views :** `{views}` """ results.append( InlineQueryResultPhoto( photo_url=thumb, title=vid_title, caption=capt, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Download - Audio", callback_data=f"ytdl_{url}_audio"), InlineKeyboardButton(text="Download - Video", callback_data=f"ytdl_{url}_video") ]]), )) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif string_given.startswith("git"): try: input_ = string_given.split(" ", maxsplit=1)[1] except: return results = [] r = requests.get("https://api.github.com/search/repositories", params={"q": input_}) lool = r.json() if lool.get("total_count") == 0: return lol = lool.get("items") for X in lol: qw = X txt = f""" <b>Name :</b> <i>{qw.get("name")}</i> <b>Full Name :</b> <i>{qw.get("full_name")}</i> <b>Link :</b> {qw.get("html_url")} <b>Fork Count :</b> <i>{qw.get("forks_count")}</i> <b>Open Issues :</b> <i>{qw.get("open_issues")}</i> """ if qw.get("description"): txt += f'\n<b>Description :</b> <code>{qw.get("description")}</code>' if qw.get("language"): txt += f'\n<b>Language :</b> <code>{qw.get("language")}</code>' if qw.get("size"): txt += f'\n<b>Size :</b> <code>{qw.get("size")}</code>' if qw.get("score"): txt += f'\n<b>Score :</b> <code>{qw.get("score")}</code>' if qw.get("created_at"): txt += f'\n<b>Created At :</b> <code>{qw.get("created_at")}</code>' if qw.get("archived") == True: txt += f"\n<b>This Project is Archived</b>" results.append( InlineQueryResultArticle( thumb_url="https://simpleicons.org/icons/github.svg", url=qw.get("html_url"), description=qw.get("description", "No Description"), title=qw.get("name"), input_message_content=InputTextMessageContent( txt, disable_web_page_preview=True))) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif string_given.startswith("whisper"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_m.insert(stark_data) texts = f"A Whisper Has Been Sent For {owo} . \nClick Below To Check Message! \n**Note :** `Only He/She Can Open It!`" ok_s = [(InlineQueryResultArticle( title="Ssh! This is A Secret Message", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"sc_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("help"): total_ = len(CMD_LIST) bttn = [ [ InlineKeyboardButton(text="Command Help", callback_data=f"make_cmd_buttons") ], [ InlineKeyboardButton(text="Restart UserBot", callback_data=f"restart_bot") ], [ InlineKeyboardButton(text="Update UserBot", callback_data=f"updTe_bot") ], [InlineKeyboardButton(text="SyS Info", callback_data=f"sys_info")], [ InlineKeyboardButton(text="Change UserBot Language", callback_data=f"change_lang") ], ] if Config.LOAD_UNOFFICIAL_PLUGINS: total_ = len(XTRA_CMD_LIST) + len(CMD_LIST) nice_text = f"**FridayUserBot Commands** \n**Friday Version :** __{friday_version}__ \n**PyroGram Version :** __{__version__}__ \n**Total Plugins Loaded :** __{total_}__" await client.answer_inline_query( inline_query.id, cache_time=0, results=[(InlineQueryResultArticle( title="Help Article!", reply_markup=InlineKeyboardMarkup(bttn), input_message_content=InputTextMessageContent(nice_text), ))], )
async def inline_docs(_, i_q: InlineQuery): query = i_q.query.lower() if query == "": await i_q.answer( results=docs.USERGE, cache_time=5, switch_pm_text="🔍 Type to search UserGe Docs", switch_pm_parameter="start", ) return results = [] if query in ["decorator", "decorators"]: results.append( InlineQueryResultArticle( title="Decorators", description="UserGe Decorators online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe Decorators.`"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("📚 Online docs", url=docs.decorators) ]]), thumb_url=docs.USERGE_THUMB, )) for i in docs.DECORATORS: results.append( InlineQueryResultArticle( title=i[0], description=i[1], input_message_content=InputTextMessageContent( docs.intro + i[2], disable_web_page_preview=True), thumb_url=docs.DECORATORS_THUMB)) elif query == "deployment": results.append( InlineQueryResultArticle( title="Deployment", description="UserGe Deployment online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe Deployment.`"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("📚 Online docs", url=docs.deployment) ]]), thumb_url=docs.USERGE_THUMB, )) for i in docs.DEPLOYMENT: results.append( InlineQueryResultArticle( title=i[0], description=i[1], input_message_content=InputTextMessageContent( docs.intro + i[2], disable_web_page_preview=True), thumb_url=docs.DEPLOYMENT_THUMB)) elif query in ["var", "vars"]: results.append( InlineQueryResultArticle( title="VARS", description="UserGe Vars online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe Vars.`"), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("📚 Online docs", url=docs.vars)]]), thumb_url=docs.USERGE_THUMB, )) for i in docs.VARS: results.append( InlineQueryResultArticle( title=i[0], description=i[1], input_message_content=InputTextMessageContent( docs.intro + i[2], disable_web_page_preview=True), thumb_url=docs.VARS_THUMB)) elif query in ["mode", "modes"]: results.append( InlineQueryResultArticle( title="UserGe Modes", description="UserGe Modes online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe Modes.`"), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("📚 Online docs", url=docs.modes)]]), thumb_url=docs.USERGE_THUMB, )) for i in docs.MODES: results.append( InlineQueryResultArticle( title=i[0], description=i[1], input_message_content=InputTextMessageContent( docs.intro + i[2], disable_web_page_preview=True), thumb_url=i[3])) elif query in ["example", "examples"]: results.append( InlineQueryResultArticle( title="UserGe Example", description="UserGe Example-Plugins online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe Example-Plugins.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("📚 Online docs", url=docs.examples) ]]), thumb_url=docs.USERGE_THUMB, )) for i in docs.EXAMPLES: results.append( InlineQueryResultArticle( title=i[0], description=i[1], input_message_content=InputTextMessageContent( docs.intro + i[2], disable_web_page_preview=True), thumb_url=docs.EXAMPLE_THUMB)) elif query in ["faq", "faqs"]: results.append( InlineQueryResultArticle( title="UserGe-FAQs", description="UserGe-FAQs online documentation page", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe-FAQs.`"), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("📚 Online docs", url=docs.faqs)]]), thumb_url=docs.USERGE_THUMB, )) for i in range(len(docs.FAQS)): results.append( InlineQueryResultArticle( title=f"FAQ {i+1}", description=docs.FAQS[i][0], input_message_content=InputTextMessageContent( f"{docs.intro}**FAQ {i+1}:-**\n" f"[{docs.FAQS[i][0]}]({docs.FAQS[i][1]})", disable_web_page_preview=True), thumb_url=docs.FAQS_THUMB)) elif query in ["error", "errors"]: results.append( InlineQueryResultArticle( title="Errors and their Fixes", input_message_content=InputTextMessageContent( f"{docs.intro}" f"`Online Documentation Page for UserGe-Errors.`"), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("📚 Online docs", url=docs.errors)]]), thumb_url=docs.ERRORS_THUMB, )) for i in range(len(docs.ERRORS)): results.append( InlineQueryResultPhoto( photo_url=f"{docs.ERRORS[i][2]}", title=f"{docs.ERRORS[i][0]}", caption=( "__Click On the below Button to Get the Solution.__"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "📚 Solution", url=f"{docs.errors}{docs.ERRORS[i][1]}") ]]), )) if results: switch_pm_text = f"📖 {len(results)} Results for \"{query}\"" await i_q.answer(results=results, cache_time=5, switch_pm_text=switch_pm_text, switch_pm_parameter="start") else: await i_q.answer(results=[], cache_time=5, switch_pm_text=f'❌ No results for "{query}"', switch_pm_parameter="okay")