예제 #1
0
파일: kang.py 프로젝트: rebel732/USERGE-X
async def sticker_search(message: Message):
    """search sticker packs"""
    reply = message.reply_to_message
    query_ = None
    if message.input_str:
        query_ = message.input_str
    elif reply and reply.from_user:
        query_ = reply.from_user.username or reply.from_user.id

    if not query_:
        return message.err(
            "reply to a user or provide text to search sticker packs",
            del_in=3)

    await message.edit(f'🔎 Searching for sticker packs for "`{query_}`"...')
    titlex = f'<b>Sticker Packs For:</b> "<u>{query_}</u>"\n'
    sticker_pack = ""
    text = await AioHttp.get_text(
        f"https://combot.org/telegram/stickers?q={query_}")
    soup = bs(text[1], "lxml")
    results = soup.find_all("div", {"class": "sticker-pack__header"})
    for pack in results:
        if pack.button:
            title_ = (pack.find("div", {"class": "sticker-pack__title"})).text
            link_ = (pack.a).get("href")
            sticker_pack += f"\n• [{title_}]({link_})"
    if not sticker_pack:
        sticker_pack = "`❌ Not Found!`"
    await message.edit((titlex + sticker_pack), disable_web_page_preview=True)
예제 #2
0
async def sticker_search(message: Message):
    # search sticker packs
    reply = message.reply_to_message
    query_ = None
    if message.input_str:
        query_ = message.input_str
    elif reply and reply.from_user:
        query_ = reply.from_user.username or reply.from_user.id

    if not query_:
        return message.err(
            "reply to a user or provide text to search sticker packs",
            del_in=3)

    await message.edit(f'Searching for sticker packs for "`{query_}`"...')
    titlex = f'<b>Sticker Packs For:</b> "<u>{query_}</u>"\n'
    sticker_pack = ""
    try:
        text = await get_response.text(
            f"https://combot.org/telegram/stickers?q={query_}")
    except ValueError:
        return await message.err(
            "Response was not 200!, Api is having some issues\n Please try again later.",
            del_in=5,
        )
    soup = bs(text, "lxml")
    results = soup.find_all("div", {"class": "sticker-pack__header"})
    for pack in results:
        if pack.button:
            title_ = (pack.find("div", {"class": "sticker-pack__title"})).text
            link_ = (pack.a).get("href")
            sticker_pack += f"\n• [{title_}]({link_})"
    if not sticker_pack:
        sticker_pack = "`Not Found!`"
    await message.edit((titlex + sticker_pack), disable_web_page_preview=True)