Example #1
0
async def create_button(msg: Message):
    """ Create Buttons Using Bot """
    if Config.BOT_TOKEN is None:
        await msg.err("First Create a Bot via @Botfather to Create Buttons...")
        return
    replied = msg.reply_to_message
    if not (replied and replied.text):
        await msg.err("Reply a text Msg")
        return
    rep_txt = check_brackets(replied.text)
    text, buttons = pb(rep_txt)
    try:
        await userge.bot.send_message(chat_id=msg.chat.id,
                                      text=text,
                                      reply_to_message_id=replied.message_id,
                                      reply_markup=buttons)
    except UserIsBot:
        await msg.err("oops, your Bot is not here to send Msg!")
    except BadRequest:
        await msg.err("Check Syntax of Your Message for making buttons!")
    except MessageEmpty:
        await msg.err("Message Object is Empty!")
    except Exception as error:
        await msg.edit(f"`Something went Wrong! `\n\n**ERROR:** `{error}`")
    else:
        await msg.delete()
Example #2
0
async def create_button(msg: Message):
    """ Create Buttons Using Bot """
    if Config.BOT_TOKEN is None:
        await msg.err("First Create a Bot via @Botfather to Create Buttons...")
        return
    string = msg.input_or_reply_raw
    if not string:
        await msg.err("`need an input!`")
        return
    text, markup = pb(string)
    if not text:
        await msg.err("`need text too!`")
        return
    replied = msg.reply_to_message
    message_id = replied.message_id if replied else msg.message_id
    client = msg.client if msg.client.is_bot else msg.client.bot
    try:
        await client.send_message(chat_id=msg.chat.id,
                                  text=text,
                                  reply_to_message_id=message_id,
                                  reply_markup=markup)
    except UserIsBot:
        await msg.err("oops, your Bot is not here to send Msg!")
    except BadRequest:
        await msg.err("Check Syntax of Your Message for making buttons!")
    except Exception as error:
        await msg.edit(f"`Something went Wrong! 😁`\n\n**ERROR:** `{error}`")
    else:
        await msg.delete()
Example #3
0
async def create_button(msg: Message):
    """ Create Buttons Using Bot """
    if config.BOT_TOKEN is None:
        await msg.err("First Create a Bot via @Botfather to Create Buttons...")
        return
    string = msg.input_raw
    if not msg.client.is_bot:
        client = msg.client.bot
        replied = msg.reply_to_message
        if replied:
            try:
                replied = await client.get_messages(
                    replied.chat.id,
                    replied.id
                )
            except ChannelInvalid:
                await msg.err("`Are you sure that your bot is here?`\n"
                              "If not , then add it here")
                return
    else:
        client = msg.client
        replied = msg.reply_to_message
    file_id = None
    if replied:
        if replied.caption:
            string = replied.caption.html
        elif replied.text:
            string = replied.text.html
        file_id = get_file_id_of_media(replied)
    if not string:
        await msg.err("`need an input!`")
        return
    text, markup = pb(string)
    if not text:
        await msg.err("`need text too!`")
        return
    message_id = replied.id if replied else None
    try:
        if replied and replied.media and file_id:
            await client.send_cached_media(
                chat_id=msg.chat.id,
                file_id=file_id,
                caption=text,
                reply_to_message_id=message_id,
                reply_markup=markup)
        else:
            await client.send_message(
                chat_id=msg.chat.id,
                text=text,
                reply_to_message_id=message_id,
                reply_markup=markup)
    except UserIsBot:
        await msg.err("oops, your Bot is not here to send Msg!")
    except BadRequest as err:
        await msg.err("Check Syntax of Your Message for making buttons!")
        log.debug(str(err))
    except Exception as error:
        await msg.edit(f"`Something went Wrong! 😁`\n\n**ERROR:** `{error}`")
    else:
        await msg.delete()
Example #4
0
async def create_button(msg: Message):
    """ Create Buttons Using Bot """
    if Config.BOT_TOKEN is None:
        await msg.err("First Create a Bot via @Botfather to Create Buttons...")
        return
    string = msg.input_raw
    replied = msg.reply_to_message
    file_id = None
    if replied:
        if replied.caption:
            string = replied.caption.html
        elif replied.text:
            string = replied.text.html
        file_id = get_file_id(replied)
    if not string:
        await msg.err("`need an input!`")
        return
    text, markup = pb(check_brackets(string))
    if not text:
        await msg.err("`need text too!`")
        return
    message_id = replied.message_id if replied else None
    client = msg.client if msg.client.is_bot else msg.client.bot
    try:
        if replied and replied.media and file_id:
            await client.send_cached_media(
                chat_id=msg.chat.id,
                file_id=file_id,
                caption=text,
                reply_to_message_id=message_id,
                reply_markup=markup,
            )
        else:
            await client.send_message(
                chat_id=msg.chat.id,
                text=text,
                reply_to_message_id=message_id,
                reply_markup=markup,
            )
    except UserIsBot:
        await msg.err("oops, your Bot is not here to send Msg!")
    except BadRequest:
        await msg.err("Check Syntax of Your Message for making buttons!")
    except Exception as error:
        await msg.edit(f"`Something went Wrong! 😁`\n\n**ERROR:** `{error}`")
    else:
        await msg.delete()
Example #5
0
    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",
            )
Example #6
0
    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")
Example #7
0
    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",
            )
Example #8
0
    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",
            )
Example #9
0
    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 and inline_query.from_user.id == Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS:
            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 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://github.com/code-rgb/USERGE-X) is Up and Running**

 • 🐍 Python :  `v{versions.__python_version__}`
 • 🔥 Pyrogram :  `v{versions.__pyro_version__}`
 • 🧬 𝑿 :  `v{get_version()}`

    🕔 Uptime : {userge.uptime}
"""

                if not MEDIA_URL:
                    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_x[0].lower() == "op" and len(str_x) > 1:
                txt = i_q[3:]  # TODO change it

                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="e.g @yourbot op Are Cats Cute?",
                        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]
                    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="🖋 Sylish FONTS",
                                              switch_pm_parameter="start")
                    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(
                            "🔐 REVEAL",
                            callback_data=f"secret_{inline_query.id}")
                    ]]
                    results.append(
                        InlineQueryResultArticle(
                            title="Send A Secret Message",
                            input_message_content=InputTextMessageContent(
                                f"📩 <b>TOPSECRET!</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)))
                else:
                    results = [(InlineQueryResultArticle(
                        title="Send A Secret Message",
                        input_message_content=InputTextMessageContent(
                            "Do `.secret` for more info"),
                        description="secret @username message ..."))]
                    await inline_query.answer(results=results,
                                              cache_time=1,
                                              switch_pm_text="🔒 SECRETS",
                                              switch_pm_parameter="start")
Example #10
0
    async def inline_answer(_, inline_query: InlineQuery):
        results = []
        i_q = inline_query.query
        string = i_q.lower()
        str_x = i_q.split(" ", 2)
        if inline_query.from_user and inline_query.from_user.id == Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS:
            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 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":
                random_alive = random.choice(ALIVE_IMGS)
                buttons = [[
                    InlineKeyboardButton("🔧 SETTINGS",
                                         callback_data="settings_btn"),
                    InlineKeyboardButton(text="⚡️ REPO",
                                         url=Config.UPSTREAM_REPO)
                ]]

                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 string == "repo":
                results.append(REPO_X)

            if str_x[0].lower() == "op" and len(str_x) > 1:
                txt = i_q[3:]
                buttons = [[
                    InlineKeyboardButton("👍", callback_data="opinion_y"),
                    InlineKeyboardButton("👎", callback_data="opinion_n")
                ]]
                results.append(
                    InlineQueryResultArticle(
                        title="Ask For Opinion",
                        input_message_content=InputTextMessageContent(txt),
                        description="e.g @yourbot op Are Cats Cute?",
                        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_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
                    buttons = [[
                        InlineKeyboardButton("🔐 REVEAL",
                                             callback_data="secret_btn")
                    ]]
                    await SECRET_MSG.drop()
                    SECRET_MSG.insert_one({'user_id': user_id, 'msg': msg})

                    results.append(
                        InlineQueryResultArticle(
                            title="Send A Secret Message",
                            input_message_content=InputTextMessageContent(
                                f"☣️ <b>TOPSECRET!</b> for {user_name}. Only he/she can open it."
                            ),
                            description="secret @username you message here",
                            thumb_url="https://i.imgur.com/lx3nT7p.png",
                            reply_markup=InlineKeyboardMarkup(buttons)))
                else:
                    buttons_h = [[
                        InlineKeyboardButton("See Help",
                                             callback_data="secret_btn_help")
                    ]]
                    results.append(
                        InlineQueryResultArticle(
                            title="Send A Secret Message",
                            input_message_content=InputTextMessageContent(
                                "@xyzbot secret @username <your message>"),
                            description="secret @username you message here",
                            #thumb_url="https://i.imgur.com/lx3nT7p.png"
                            reply_markup=InlineKeyboardMarkup(buttons_h)))

        else:
            results.append(REPO_X)
        try:
            if not len(results) == 0:
                await inline_query.answer(results=results, cache_time=1)
        except MessageEmpty:
            return
Example #11
0
    async def inline_answer(_, inline_query: InlineQuery):
        results = []
        i_q = inline_query.query
        string = i_q.lower()
        str_x = i_q.split(" ", 2)
        string_split = string.split()

        if inline_query.from_user and inline_query.from_user.id == Config.OWNER_ID or inline_query.from_user.id in Config.SUDO_USERS:
            MAIN_MENU = InlineQueryResultArticle(
                title="DGMain Menu",
                input_message_content=InputTextMessageContent(
                    " 𝗗𝗔𝗥𝗞𝗚𝗘-𝗫  𝗠𝗔𝗜𝗡  𝗠𝗘𝗡𝗨 "),
                url="https://github.com/DevTeady/DARKGE-X",
                description="Darkge-X Main Menu",
                thumb_url="https://i.imgur.com/xIvub1a.jpeg",
                reply_markup=InlineKeyboardMarkup(main_menu_buttons()))
            results.append(MAIN_MENU)

            if string == "darksoda_xd":
                owner = [[
                    InlineKeyboardButton(text="Contact",
                                         url="https://t.me/DarkSoda_XD")
                ]]
                results.append(
                    InlineQueryResultPhoto(
                        photo_url="https://i.imgur.com/xKG5gSC.jpg",
                        caption="Hey I solved **DARKSODA_XD**",
                        reply_markup=InlineKeyboardMarkup(owner)))

            if string == "vijay":
                rick = [[
                    InlineKeyboardButton(text="🔍",
                                         url="https://t.me/tha1apathy")
                ]]
                results.append(
                    InlineQueryResultArticle(
                        title="The Noob Guy !",
                        input_message_content=InputTextMessageContent(
                            "Search Results"),
                        description="Definately Not a normal Guy !",
                        thumb_url="https://i.imgur.com/6RM9NNk.jpg",
                        reply_markup=InlineKeyboardMarkup(rick)))

            if string == "alive":
                random_alive = random.choice(ALIVE_IMGS)
                buttons = [[
                    InlineKeyboardButton("🔧 SETTINGS",
                                         callback_data="settings_btn"),
                    InlineKeyboardButton(text="⚡️ REPO",
                                         url=Config.UPSTREAM_REPO)
                ]]

                alive_info = f"""
     **DARKGE-X** is Up and Running ⚡**
 • 🐍 Python :  `v{versions.__python_version__}`
 • 🔥 Pyrogram :  `v{versions.__pyro_version__}`
 • 🔅 DARK UI :  `0.2.8`
                """

                results.append(
                    InlineQueryResultPhoto(
                        photo_url=random_alive,
                        caption=alive_info,
                        reply_markup=InlineKeyboardMarkup(buttons)))

            if string == "darkge":
                results.append(
                    InlineQueryResultAnimation(
                        animation_url="https://i.imgur.com/o6WHRa9.gif",
                        caption="To be animal, I must be a great lazy!",
                    ))

            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 string_split[0] == "ofox" and len(string_split) == 2:
                codename = string_split[1]
                t = TelegraphPoster(use_api=True)
                t.create_api_token('DARKGE-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,
                        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:]
                buttons = [[
                    InlineKeyboardButton("👍", callback_data="opinion_y"),
                    InlineKeyboardButton("👎", callback_data="opinion_n")
                ]]
                results.append(
                    InlineQueryResultArticle(
                        title="Ask For Opinion",
                        input_message_content=InputTextMessageContent(txt),
                        description="e.g @yourbot op Are Cats Cute?",
                        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_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
                    try:
                        view_data = json.load(open(SECRETS))
                    except:
                        view_data = False

                    if view_data:
                        # Uniquely identifies an inline message
                        new_id = {
                            inline_query.id: {
                                'user_id': user_id,
                                'msg': msg
                            }
                        }
                        view_data.update(new_id)
                        json.dump(view_data, open(SECRETS, 'w'))
                    else:
                        d = {inline_query.id: {'user_id': user_id, 'msg': msg}}
                        json.dump(d, open(SECRETS, 'w'))

                    buttons = [[
                        InlineKeyboardButton(
                            "🔐 REVEAL",
                            callback_data=f"secret_{inline_query.id}")
                    ]]
                    results.append(
                        InlineQueryResultArticle(
                            title="Send A Secret Message",
                            input_message_content=InputTextMessageContent(
                                f"📨 <b>TOPSECRET!</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)))
                else:
                    results = [(InlineQueryResultArticle(
                        title="Send A Secret Message",
                        input_message_content=InputTextMessageContent(
                            "Do `.secret` for more info"),
                        description="secret @username message ..."))]
                    await inline_query.answer(results=results,
                                              cache_time=1,
                                              switch_pm_text="🔒 SECRETS",
                                              switch_pm_parameter="start")
                    return
        else:
            results.append(REPO_X)
        try:
            if not len(results) == 0:
                await inline_query.answer(results=results, cache_time=1)
        except MessageEmpty:
            return