Ejemplo n.º 1
0
async def speedtest_init(query):
    answers = []
    user_id = query.from_user.id
    if user_id not in SUDOERS:
        msg = "**ERROR**\n__THIS FEATURE IS ONLY FOR SUDO USERS__"
        answers.append(
            InlineQueryResultArticle(
                title="ERROR",
                description="THIS FEATURE IS ONLY FOR SUDO USERS",
                input_message_content=InputTextMessageContent(msg)
            ))
        return answers
    msg = "**Click The Button Below To Perform A Speedtest**"
    button = InlineKeyboard(row_width=1)
    button.add(InlineKeyboardButton(
        text="Test", callback_data="test_speedtest"))
    answers.append(
        InlineQueryResultArticle(
            title="Click Here",
            input_message_content=InputTextMessageContent(msg),
            reply_markup=button
        )
    )
    return answers
Ejemplo n.º 2
0
async def on_index(c, iq):
    index = int(iq.matches[0]['index'])
    message = await Message.get_or_none(key=index)
    if not message:
        results = [
            InlineQueryResultArticle(
                title="undefined index",
                input_message_content=InputTextMessageContent(
                    f"Undefined index {index}"))
        ]
        return await iq.answer(results, cache_time=0)

    keyboard = ikb(message.keyboard)
    text = message.text

    results = [
        InlineQueryResultArticle(title="index",
                                 input_message_content=InputTextMessageContent(
                                     text, disable_web_page_preview=True),
                                 reply_markup=keyboard)
    ]

    await iq.answer(results, cache_time=0)
    await Message.get(key=message.key).delete()
Ejemplo n.º 3
0
async def info_inline_func(answers, peer):
    not_found = InlineQueryResultArticle(
        title="PEER NOT FOUND",
        input_message_content=InputTextMessageContent("PEER NOT FOUND"),
    )
    try:
        user = await app.get_users(peer)
        caption, _ = await get_user_info(user, True)
    except IndexError:
        try:
            chat = await app.get_chat(peer)
            caption, _ = await get_chat_info(chat, True)
        except Exception:
            return [not_found]
    except Exception:
        return [not_found]

    answers.append(
        InlineQueryResultArticle(
            title="Found Peer.",
            input_message_content=InputTextMessageContent(
                caption, disable_web_page_preview=True),
        ))
    return answers
 async def wrapper(client, inline_query):
     users = await get_all_pros()
     if inline_query.from_user.id not in users:
         await client.answer_inline_query(
             inline_query.id,
             cache_time=1,
             results=[(InlineQueryResultArticle(
                 title="Sorry, Friend You Can't Use Me!",
                 input_message_content=InputTextMessageContent(
                     "**Hai!** Well, I am Not For You, I Only Work For My Master. Why Don't You Deploy Your Own @FridayOT ?"
                 ),
             ))],
         )
     else:
         await func(client, inline_query)
Ejemplo n.º 5
0
async def inline_nhentai(client, inline_query):
    query = int(inline_query.matches[0].group(1))
    n_title, tags, artist, total_pages, post_url, cover_image = nhentai_data(
        query)
    reply_message = f"<code>{n_title}</code>\n\n<b>Tags:</b>\n{tags}\n<b>Artists:</b>\n{artist}\n<b>Pages:</b>\n{total_pages}"
    await inline_query.answer(results=[
        InlineQueryResultArticle(
            title=n_title,
            input_message_content=InputTextMessageContent(reply_message),
            description=tags,
            thumb_url=cover_image,
            reply_markup=InlineKeyboardMarkup(
                [[InlineKeyboardButton("Read Here", url=post_url)]]))
    ],
                              cache_time=1)
Ejemplo n.º 6
0
async def translate_func(answers, lang, tex):
    result = await arq.translate(tex, lang)
    if not result.ok:
        answers.append(
            InlineQueryResultArticle(
                title="Error",
                description=result.result,
                input_message_content=InputTextMessageContent(result.result),
            )
        )
        return answers
    result = result.result
    msg = f"""
__**Translated from {result.src} to {result.dest}**__

**INPUT:**
{tex}

**OUTPUT:**
{result.translatedText}"""
    answers.extend(
        [
            InlineQueryResultArticle(
                title=f"Translated from {result.src} to {result.dest}.",
                description=result.translatedText,
                input_message_content=InputTextMessageContent(msg),
            ),
            InlineQueryResultArticle(
                title=result.translatedText,
                input_message_content=InputTextMessageContent(
                    result.translatedText
                ),
            ),
        ]
    )
    return answers
Ejemplo n.º 7
0
 async def func(client, inline_query):
     if inline_query.from_user.id not in app_user_ids:
         await inline_query.answer([
             InlineQueryResultArticle('...no',
                                      InputTextMessageContent('...no'))
         ],
                                   cache_time=3600,
                                   is_personal=True)
         return
     async with session.get(f'https://nekos.life/api/v2/img/{i}') as resp:
         url = (await resp.json())['url']
     call = InlineQueryResultAnimation if '.gif' == os.path.splitext(
         url)[1] else InlineQueryResultPhoto
     await inline_query.answer([call(url, caption=url, parse_mode=None)],
                               cache_time=0)
Ejemplo n.º 8
0
async def translate_func(answers, lang, tex):
    i = Translator().translate(tex, dest=lang)
    msg = f"""
__**Translated from {i.src} to {lang}**__

**INPUT:**
{tex}

**OUTPUT:**
{i.text}"""
    answers.extend(
        [
            InlineQueryResultArticle(
                title=f'Translated from {i.src} to {lang}.',
                description=i.text,
                input_message_content=InputTextMessageContent(msg)
            ),
            InlineQueryResultArticle(
                title=i.text,
                input_message_content=InputTextMessageContent(i.text)
            )
        ]
    )
    return answers
Ejemplo n.º 9
0
async def answer(timebot, inline_query):
    string = TimeTeller.india()
    if inline_query.query == "time":
        await inline_query.answer(
            results=[
                InlineQueryResultArticle(
                    title=f"Time at Present",
                    input_message_content=InputTextMessageContent(string),
                    description="Tap to send time to current chat",
                    thumb_url=
                    "https://telegra.ph/file/b29908ccae574846c264a.jpg",
                )
            ],
            cache_time=1,
        )
    elif inline_query.query == "":
        await inline_query.answer(
            results=[
                InlineQueryResultArticle(
                    title=f"Time at Present",
                    input_message_content=InputTextMessageContent(string),
                    description="Tap to send time to current chat",
                    thumb_url=
                    "https://telegra.ph/file/b29908ccae574846c264a.jpg",
                ),
                InlineQueryResultArticle(
                    title=f"How to use this bot ?",
                    input_message_content=InputTextMessageContent(
                        Data.HELP, parse_mode="Markdown"),
                    description=f"Tap to know how to use me properly.",
                    thumb_url=
                    "https://telegra.ph/file/b29908ccae574846c264a.jpg",
                )
            ],
            cache_time=1,
        )
Ejemplo n.º 10
0
async def torrent_func(answers, text):
    results = await arq.torrent(text)
    if not results.ok:
        answers.append(
            InlineQueryResultArticle(
                title="Error",
                description=results.result,
                input_message_content=InputTextMessageContent(results.result),
            ))
        return answers
    results = results.result[0:48]
    for i in results:
        title = i.name
        size = i.size
        seeds = i.seeds
        leechs = i.leechs
        upload_date = i.uploaded
        magnet = i.magnet
        caption = f"""
**Title:** __{title}__
**Size:** __{size}__
**Seeds:** __{seeds}__
**Leechs:** __{leechs}__
**Uploaded:** __{upload_date}__
**Magnet:** `{magnet}`"""

        description = f"{size} | {upload_date} | Seeds: {seeds}"
        answers.append(
            InlineQueryResultArticle(
                title=title,
                description=description,
                input_message_content=InputTextMessageContent(
                    caption, disable_web_page_preview=True),
            ))
        pass
    return answers
Ejemplo n.º 11
0
async def inline_help_func(__HELP__):
    buttons = InlineKeyboard(row_width=4)
    buttons.add(
        *[(InlineKeyboardButton(text=i, switch_inline_query_current_chat=i))
          for i in keywords_list])
    answerss = [
        InlineQueryResultArticle(
            title="Inline Commands",
            description="Help Related To Inline Usage.",
            input_message_content=InputTextMessageContent(
                "Click A Button To Get Started."),
            thumb_url="https://telegra.ph/file/7ee7b8ea4b6955642aa2e.jpg",
            reply_markup=buttons,
        ),
        InlineQueryResultArticle(
            title="Github Repo",
            description="Get Github Respository Of Bot.",
            input_message_content=InputTextMessageContent(
                "https://github.com/TeamInnexia"),
            thumb_url="https://telegra.ph/file/36d8e6e3d7849e7e8d396.jpg",
        ),
    ]
    answerss = await alive_function(answerss)
    return answerss
Ejemplo n.º 12
0
async def wiki_func(answers, text):
    data = await arq.wiki(text)
    msg = f"""
**QUERY:**
{data['title']}

**ANSWER:**
__{data['answer']}__"""
    answers.append(
        InlineQueryResultArticle(
            title=data["title"],
            description=data["answer"],
            input_message_content=InputTextMessageContent(msg),
        ))
    return answers
Ejemplo n.º 13
0
async def inline_help(c: Korone, q: InlineQuery):
    articles = [
        InlineQueryResultArticle(
            title="Informações",
            input_message_content=InputTextMessageContent(
                f"<b>Uso:</b> <code>@{c.me.username} user</code> - Exibe informações sobre você."
            ),
            description="Informações sobre você.",
            thumb_url="https://piics.ml/amn/eduu/info.png",
        ),
        InlineQueryResultArticle(
            title="Informações SpamWatch",
            input_message_content=InputTextMessageContent(
                f"<b>Uso:</b> <code>@{c.me.username} sw (id/username)</code> - Verifique se um usuário está banido no SpamWatch."
            ),
            description="Veja se um usuário está banido no SpamWatch.",
            thumb_url="https://telegra.ph/file/1c18bdedaf01664dc0029.png",
        ),
        InlineQueryResultArticle(
            title="Animes",
            input_message_content=InputTextMessageContent(
                f"<b>Uso:</b> <code>@{c.me.username} anime (pesquisa)</code> - Pesquise animes pelo inline."
            ),
            description="Pesquisa de animes com o Anilist.co.",
            thumb_url="https://telegra.ph/file/c41e41a22dcf6479137d0.png",
        ),
        InlineQueryResultArticle(
            title="Mangás",
            input_message_content=InputTextMessageContent(
                f"<b>Uso:</b> <code>@{c.me.username} manga (pesquisa)</code> - Pesquise mangás pelo inline."
            ),
            description="Pesquisa de mangás com o Anilist.co.",
            thumb_url="https://telegra.ph/file/c41e41a22dcf6479137d0.png",
        ),
    ]
    await q.answer(results=articles, cache_time=0)
Ejemplo n.º 14
0
async def deezer_func(answers, text):
    buttons_list = []
    results = await arq.deezer(text, 5)
    if not results.ok:
        answers.append(
            InlineQueryResultArticle(
                title="Error",
                description=results.result,
                input_message_content=InputTextMessageContent(results.result),
            )
        )
        return answers
    results = results.result
    for count, i in enumerate(results):
        buttons = InlineKeyboard(row_width=1)
        buttons.add(InlineKeyboardButton("Download | Play", url=i.url))
        buttons_list.append(buttons)
        duration = await time_convert(i.duration)
        caption = f"""
**Title:** {i.title}
**Artist:** {i.artist}
**Duration:** {duration}
**Source:** [Deezer]({i.source})"""
        description = f"{i.artist} | {duration}"
        answers.append(
            InlineQueryResultArticle(
                title=i.title,
                thumb_url=i.thumbnail,
                description=description,
                input_message_content=InputTextMessageContent(
                    caption, disable_web_page_preview=True
                ),
                reply_markup=buttons_list[count],
            )
        )
    return answers
Ejemplo n.º 15
0
        def __new__(cls, item):
            constructor_id = hex(item[1].ID)
            path = cls.DOCS.format(Result.snek(item[0]).replace("_", "-").replace(".-", "/"))

            return InlineQueryResultArticle(
                title=f"{item[0]}",
                description=f"Raw Type - {constructor_id}\nSchema: Layer {layer}",
                input_message_content=InputTextMessageContent(
                    f"{emoji.ORANGE_BOOK} **Pyrogram Docs**\n\n"
                    f"[{item[0]}]({path}) - Raw Type\n\n"
                    f"`ID`: **{constructor_id}**\n"
                    f"`Schema`: **Layer {layer}**",
                    disable_web_page_preview=True,
                ),
                thumb_url=cls.THUMB,
            )
Ejemplo n.º 16
0
async def inline_help_func(__help__):
    buttons = InlineKeyboard(row_width=2)
    buttons.add(
        InlineKeyboardButton('Get More Help?',
                             url=f"t.me/{BOT_USERNAME}?start=help"),
        InlineKeyboardButton("Go Inline!",
                             switch_inline_query_current_chat=""))
    answerss = [
        InlineQueryResultArticle(
            title="Inline Commands",
            description="Help Related To Inline Usage.",
            input_message_content=InputTextMessageContent(__help__),
            thumb_url="https://telegra.ph/file/a39e5688b6764c6c29809.jpg",
            reply_markup=buttons)
    ]
    return answerss
Ejemplo n.º 17
0
async def pastebin_func(answers, link):
    link = link.split("/")
    if link[3] == "c":
        chat, message_id = int("-100" + link[4]), int(link[5])
    else:
        chat, message_id = link[3], link[4]
    m = await app.get_messages(chat, message_ids=int(message_id))
    if not m.text and not m.document:
        m = await app2.get_messages(chat, message_ids=int(message_id))
    if m.text:
        content = m.text
    else:
        if m.document.file_size > 1048576:
            answers.append(
                InlineQueryResultArticle(
                    title="DOCUMENT TOO BIG",
                    description="Maximum supported size is 1MB",
                    input_message_content=InputTextMessageContent(
                        "DOCUMENT TOO BIG")

                )
            )
            return answers
        doc = await m.download()
        async with aiofiles.open(doc, mode="r") as f:
            content = await f.read()
        os.remove(doc)
    link = await paste(content)
    preview = link + "/preview.png"
    status_code = await get_http_status_code(preview)
    i = 0
    while status_code != 200:
        if i == 5:
            break
        status_code = await get_http_status_code(preview)
        await asyncio.sleep(0.2)
        i += 1
    await app.send_photo(MESSAGE_DUMP_CHAT, preview)  # To Pre-cache the media
    buttons = InlineKeyboard(row_width=1)
    buttons.add(InlineKeyboardButton(text="Paste Link", url=link))
    answers.append(
        InlineQueryResultPhoto(
            photo_url=preview,
            reply_markup=buttons
        )
    )
    return answers
Ejemplo n.º 18
0
async def tmdb_func(answers, query):
    response = await arq.tmdb(query)
    if not response.ok:
        answers.append(
            InlineQueryResultArticle(
                title="Error",
                description=response.result,
                input_message_content=InputTextMessageContent(response.result),
            )
        )
        return answers
    results = response.result[:49]
    for result in results:
        if not result.poster and not result.backdrop:
            continue
        if not result.genre:
            genre = None
        else:
            genre = " | ".join(result.genre)
        description = result.overview[0:900] if result.overview else "None"
        caption = f"""
**{result.title}**
**Type:** {result.type}
**Rating:** {result.rating}
**Genre:** {genre}
**Release Date:** {result.releaseDate}
**Description:** __{description}__
"""
        buttons = InlineKeyboard(row_width=1)
        buttons.add(
            InlineKeyboardButton(
                "Search Again",
                switch_inline_query_current_chat="tmdb",
            )
        )
        answers.append(
            InlineQueryResultPhoto(
                photo_url=result.backdrop
                if result.backdrop
                else result.poster,
                caption=caption,
                title=result.title,
                description=f"{genre} • {result.releaseDate} • {result.rating} • {description}",
                reply_markup=buttons,
            )
        )
    return answers
Ejemplo n.º 19
0
async def github_repo_func(answers, text):
    url = text
    text = text.replace("https://github.com/", "")
    text = text.replace("http://github.com/", "")
    if text[-1] == "/":
        text = text[0:-1]
    URL = f"https://api.github.com/repos/{text}"
    URL2 = f"https://api.github.com/repos/{text}/contributors"
    results = await asyncio.gather(fetch(URL), fetch(URL2))
    r = results[0]
    r1 = results[1]
    commits = 0
    for developer in r1:
        commits += developer['contributions']
    buttons = InlineKeyboard(row_width=1)
    buttons.add(
        InlineKeyboardButton(
            'Open On Github',
            url=f"https://github.com/{text}"
        )
    )
    caption = f"""
**Info Of {r['full_name']}**
**Stars:** `{r['stargazers_count']}`
**Watchers:** `{r['watchers_count']}`
**Forks:** `{r['forks_count']}`
**Commits:** `{commits}`
**Is Fork:** `{r['fork']}`
**Language:** `{r['language']}`
**Contributors:** `{len(r1)}`
**License:** `{r['license']['name'] if r['license'] else None}`
**Repo Owner:** [{r['owner']['login']}]({r['owner']['html_url']})
**Created On:** `{r['created_at']}`
**Homepage:** {r['homepage']}
**Description:** __{r['description']}__"""
    answers.append(
        InlineQueryResultArticle(
            title="Found Repo",
            description=text,
            reply_markup=buttons,
            input_message_content=InputTextMessageContent(
                caption,
                disable_web_page_preview=True
            )
        ))
    return answers
    def get_item(
            cls,
            db_from_user: graph_models.vertices.User,
    ) -> Optional['pyrogram.types.InlineQueryResult']:
        if db_from_user is None:
            return None

        return InlineQueryResultArticle(
            title=_trans("No Results Were Found", db_from_user.chosen_language_code),
            description=_trans(
                "You haven't created any playlist yet",
                db_from_user.chosen_language_code
            ),
            input_message_content=InputTextMessageContent(
                message_text=emoji.high_voltage,
            )
        )
Ejemplo n.º 21
0
def user_eazy(bunch):
    result = []
    for one in bunch:
        user = one._json
        text = simstuff(user)
        uname = user['screen_name']
        reply_markup = InlineKeyboardMarkup(user_reply_markup(one))
        result.append(
            InlineQueryResultArticle(
                title=user["name"],
                description=f"@{uname}",
                url="https://twitter.com/" + uname,
                thumb_url=user["profile_image_url"],
                reply_markup=reply_markup,
                input_message_content=InputTextMessageContent(
                    text, disable_web_page_preview=True)))
    return result[:50]
Ejemplo n.º 22
0
async def google_search_func(answers, text):
    gresults = await GoogleSearch().async_search(text)
    for i in gresults:
        try:
            msg = f"""
[{i['titles']}]({i['links']})
{i['descriptions']}"""

            answers.append(
                InlineQueryResultArticle(
                    title=i['titles'],
                    description=i['descriptions'],
                    input_message_content=InputTextMessageContent(
                        msg, disable_web_page_preview=True)))
        except KeyError:
            pass
    return answers
Ejemplo n.º 23
0
async def music_inline_func(answers, query):
    chat_id = -1001445180719
    group_invite = "https://t.me/joinchat/vSDE2DuGK4Y4Nzll"
    try:
        messages = [
            m
            async for m in app2.search_messages(
                chat_id, query, filter="audio", limit=199
            )
        ]
    except Exception as e:
        print(e)
        msg = f"You Need To Join Here With Your Bot And Userbot To Get Cached Music.\n{group_invite}"
        answers.append(
            InlineQueryResultArticle(
                title="ERROR",
                description="Click Here To Know More.",
                input_message_content=InputTextMessageContent(
                    msg, disable_web_page_preview=True
                ),
            )
        )
        return answers
    messages_ids_and_duration = []
    for f_ in messages:
        messages_ids_and_duration.append(
            {
                "message_id": f_.message_id,
                "duration": f_.audio.duration if f_.audio.duration else 0,
            }
        )
    messages = list(
        {v["duration"]: v for v in messages_ids_and_duration}.values()
    )
    messages_ids = []
    for ff_ in messages:
        messages_ids.append(ff_["message_id"])
    messages = await app.get_messages(chat_id, messages_ids[0:48])
    for message_ in messages:
        answers.append(
            InlineQueryResultCachedDocument(
                file_id=message_.audio.file_id, title=message_.audio.title
            )
        )
    return answers
Ejemplo n.º 24
0
async def combot_start(client, inline_query):
    async with message_lock:
        user = inline_query.matches[0].group(1)
        try:
            u, uc = await get_user(client, user)
            text = f'CAS messages for: <a href="https://cas.chat/query?u={u.id}">{u.first_name}</a>\n\n'
        except:
            text = f'CAS messages for: <a href="https://cas.chat/query?u={user}">{user}</a>\n\n'
        answers = []
        results, page = cas_queries[user]
        results = results['result']['messages']
        parser = pyrogram_html(client)
        for a, result in enumerate(results):
            full_snippet = None

            if result:
                full_snippet = snippet = (await
                                          parser.parse(result))['message']
                total_length = len((await parser.parse(text))['message'])
                if len(snippet) > 1022 - total_length:
                    snippet = snippet[:1021 - total_length] + '…'
                text += snippet
            buttons = [
                InlineKeyboardButton(
                    'Back',
                    f'engine_cas_prev={inline_query.from_user.id}-{user}'),
                InlineKeyboardButton(f'{a + 1}/{len(results)}',
                                     'wikipedia_nop'),
                InlineKeyboardButton(
                    'Next',
                    f'engine_cas_next={inline_query.from_user.id}-{user}')
            ]
            if not a:
                buttons.pop(0)
            if len(results) == a + 1:
                buttons.pop()
            answers.append(
                InlineQueryResultArticle(
                    "Engine CAS",
                    InputTextMessageContent(text,
                                            disable_web_page_preview=True),
                    reply_markup=InlineKeyboardMarkup([buttons]),
                    id=f'cas{a}-{time.time()}',
                    description=full_snippet))
        await inline_query.answer(answers, is_personal=True)
Ejemplo n.º 25
0
async def fullSearchAccount(client: lolBot, query: InlineQuery):
    args = query.query.split(' full ')
    if len(args[1]) < 3:
        return
    errmsg = None
    try:
        if (args[0].upper() == 'EUW'):
            user = client.lolWatcher.summoner.by_name('euw1', args[1])
            advancedData = client.lolWatcher.league.by_summoner(
                'euw1', user['id'])
            #sorted(champMastery, key=lambda x: x['championPoints'], reverse=True)

        elif (args[0].upper() == 'NA'):
            user = client.lolWatcher.summoner.by_name('na1', args[1])
            advancedData = client.lolWatcher.league.by_summoner(
                'na1', user['id'])

    except ApiError as err:
        if err.response.status_code == 404:
            errmsg = f"User not found in region {args[0].upper()}"

    #if there is no error -> create the text to return to the user.
    if not errmsg:
        userinfo = f"**Region**: {args[0].upper()}\n\
**Name**: {user['name']}\n\
**Level**: {user['summonerLevel']}\n"

        #advancedData will be [] if the player has not joined a tier.
        if advancedData:
            for item in advancedData:
                userinfo = userinfo + f"**=====================**\n\
**Game**: {item['queueType']}\n\
**Tier**: {item['tier']} {item['rank']}\n\
**Wins**: {item['wins']}\n\
**Losses**: {item['losses']}\n"

        else:
            userinfo = userinfo + f"{args[1]} Has not ranked yet."

    # send back the result
    await query.answer(results=[
        InlineQueryResultArticle(
            f"{args[1]} Full Information",
            InputTextMessageContent(errmsg if errmsg else userinfo))
    ])