コード例 #1
0
async def lydia_reply(_client, message):
    global lydia_status, session
    if lydia_status:
        output = session.think_thought(message.text)
        await message.reply_text(f"`{output}`",
                                 quote=True,
                                 reply_to_message_id=ReplyCheck(message))
    else:
        return
コード例 #2
0
async def favourite_animelist(client, message):
    x = await client.get_inline_bot_results(f"{BotUsername}", "favourite")
    await message.delete()
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True,
    )
コード例 #3
0
async def speed_test_inline(client, message):
    x = await client.get_inline_bot_results(f"{BotUsername}", "speedtest")
    await message.delete()
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True,
    )
コード例 #4
0
ファイル: meme.py プロジェクト: muhammedfurkan/Nana-Bot
async def mock_spongebob(client, message):
    await message.delete()
    mock = message.reply_to_message.text
    x = await client.get_inline_bot_results("Stickerizerbot", f"#7{mock}")
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True)
コード例 #5
0
async def google_search(client, message):
    googles = message.reply_to_message.text
    x = await client.get_inline_bot_results("Stickerizerbot", f"#12{googles}")
    await message.delete()
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True)
コード例 #6
0
ファイル: meme.py プロジェクト: yunosaint/Nana-Bot
async def pat(client, message):
    URL = "https://some-random-api.ml/animu/pat"
    async with aiohttp.ClientSession() as session:
        async with session.get(URL) as request:
            if request.status == 404:
                return await message.edit("`no Pats for u :c")
            result = await request.json()
            url = result.get("link", None)
            await message.delete()
            await client.send_video(message.chat.id,
                                    url,
                                    reply_to_message_id=ReplyCheck(message))
コード例 #7
0
ファイル: meme.py プロジェクト: wulan17/Nana-Remix
async def spam(client, message):
    await message.delete()
    times = message.command[1]
    to_spam = ' '.join(message.command[2:])
    if message.chat.type in ['supergroup', 'group']:
        for _ in range(int(times)):
            await client.send_message(message.chat.id, to_spam, reply_to_message_id=ReplyCheck(message))
            await asyncio.sleep(0.20)

    if message.chat.type == "private":
        for _ in range(int(times)):
            await client.send_message(message.chat.id, to_spam)
            await asyncio.sleep(0.20)
コード例 #8
0
async def github(client, message):
    if len(message.text.split()) == 1:
            await edrep(message, text="Usage: `git (username)`")
            return
    username = message.text.split(None, 1)[1]
    URL = f"https://api.github.com/users/{username}"
    async with aiohttp.ClientSession() as session:
        async with session.get(URL) as request:
            if request.status == 404:
                return await edrep(message, text="`" + username + " not found`")

            result = await request.json()

            url = result.get("html_url", None)
            name = result.get("name", None)
            company = result.get("company", None)
            bio = result.get("bio", None)
            created_at = result.get("created_at", "Not Found")

            REPLY = (
                f"**GitHub Info for {name}**"
                f"\n**Username:** `{username}`\n**Bio:** `{bio}`\n**Profile Link:** [Link]({url})"
                f"\n**Company:** `{company}`\n**Created at:** `{created_at}`"
                f"\n**Repository:** [Link](https://github.com/{username}?tab=repositories)"
            )
        url = f"https://ghchart.rshah.org/{username}"
        file_name = f"{randint(1, 999)}{username}"
        resp = await AioHttp.get_raw(url)
        f = await aiofiles.open(f"{file_name}.svg", mode='wb')
        await f.write(resp)
        await f.close()

        try:
            drawing = svg2rlg(f"{file_name}.svg")
            renderPM.drawToFile(drawing, f"{file_name}.png")
        except UnboundLocalError:
            await edrep(message, text="Username does not exist!")
            await sleep(2)
            await message.delete()
            return
        await asyncio.gather(
            client.send_photo(
            chat_id=message.chat.id,
            photo=f"{file_name}.png",
            caption=REPLY,
            reply_to_message_id=ReplyCheck(message)
            )
    )
    for file in iglob(f"{file_name}.*"):
        os.remove(file)
コード例 #9
0
ファイル: animelist.py プロジェクト: alivya/Nana-Bot
async def character(client, message):
    cmd = message.command
    search_query = ""
    if len(cmd) > 1:
        search_query = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        search_query = message.reply_to_message.text
    elif not message.reply_to_message and len(cmd) == 1:
        await message.edit("Usage: `character`")
        await asyncio.sleep(2)
        await message.delete()
        return
    await message.delete()
    jikan = jikanpy.jikan.Jikan()
    try:
        search_result = jikan.search("character", search_query)
    except jikanpy.APIException:
        await message.edit("Character not found.")
        return
    first_mal_id = search_result["results"][0]["mal_id"]
    character = jikan.character(first_mal_id)
    caption = f"[{character['name']}]({character['url']})"
    if character['name_kanji'] != "Japanese":
        caption += f" ({character['name_kanji']})\n"
    else:
        caption += "\n"

    if character['nicknames']:
        nicknames_string = ", ".join(character['nicknames'])
        caption += f"\n**Nicknames** : `{nicknames_string}`"
    about = character['about'].split(" ", 60)
    try:
        about.pop(60)
    except IndexError:
        pass
    about_string = ' '.join(about)
    mal_url = search_result["results"][0]['url']
    for entity in character:
        if character[entity] is None:
            character[entity] = "Unknown"
    caption += f"\n**About**: {about_string}"
    caption += f" [Read More]({mal_url})..."
    await client.send_photo(message.chat.id,
                            photo=character['image_url'],
                            caption=replace_text(caption),
                            reply_to_message_id=ReplyCheck(message),
                            parse_mode='markdown'
                        )
コード例 #10
0
ファイル: animelist.py プロジェクト: nana73838/Nana-Remix
async def anime_search(client, message):
    cmd = message.command
    mock = ""
    if len(cmd) > 1:
        mock = " ".join(cmd[1:])
    elif len(cmd) == 1:
        await edrep(message, text="`Format: anime <anime name>`")
        await asyncio.sleep(2)
        await message.delete()
        return
    x = await client.get_inline_bot_results(f"{BotUsername}", f"anime {mock}")
    await message.delete()
    await client.send_inline_bot_result(chat_id=message.chat.id,
                                        query_id=x.query_id,
                                        result_id=x.results[0].id,
                                        reply_to_message_id=ReplyCheck(message),
                                        hide_via=True)
コード例 #11
0
ファイル: stickerizer.py プロジェクト: yunosaint/Nana-Bot
async def waifu_sticker(client, message):
    cmd = message.command
    waifu = ""
    if len(cmd) > 1:
        waifu = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        waifu = message.reply_to_message.text
    elif not message.reply_to_message and len(cmd) == 1:
        await message.edit("`No text Given hence the waifu Ran Away.`")
        await asyncio.sleep(2)
        await message.delete()
        return
    x = await client.get_inline_bot_results("Stickerizerbot", f"#{random.choice(waifus)}{waifu}")
    await message.delete()
    await client.send_inline_bot_result(chat_id=message.chat.id,
                                        query_id=x.query_id,
                                        result_id=x.results[0].id,
                                        reply_to_message_id=ReplyCheck(message),
                                        hide_via=True)
コード例 #12
0
ファイル: stickerizer.py プロジェクト: yunosaint/Nana-Bot
async def mock_spongebob(client, message):
    cmd = message.command
    mock = ""
    if len(cmd) > 1:
        mock = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        mock = message.reply_to_message.text
    elif not message.reply_to_message and len(cmd) == 1:
        await message.edit("`Can't mock the void.`")
        await asyncio.sleep(2)
        await message.delete()
        return
    x = await client.get_inline_bot_results("Stickerizerbot", f"#7{mock}")
    await message.delete()
    await client.send_inline_bot_result(chat_id=message.chat.id,
                                        query_id=x.query_id,
                                        result_id=x.results[0].id,
                                        reply_to_message_id=ReplyCheck(message),
                                        hide_via=True)
コード例 #13
0
ファイル: stickerizer.py プロジェクト: yasirarism/Nana-Remix
async def google_search(client, message):
    cmd = message.command
    googles = ""
    if len(cmd) > 1:
        googles = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        googles = message.reply_to_message.text
    elif len(cmd) == 1:
        await message.edit("`No text Given hence can not google the void.`")
        await asyncio.sleep(2)
        await message.delete()
        return
    x = await client.get_inline_bot_results("Stickerizerbot", f"#12{googles}")
    await message.delete()
    await client.send_inline_bot_result(chat_id=message.chat.id,
                                        query_id=x.query_id,
                                        result_id=x.results[0].id,
                                        reply_to_message_id=ReplyCheck(message),
                                        hide_via=True)
コード例 #14
0
async def senpai_sticker(client, message):
    cmd = message.command
    senpai = ""
    if len(cmd) > 1:
        senpai = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        senpai = message.reply_to_message.text
    elif len(cmd) == 1:
        await edrep(message, text="`No text Given hence the senpai Ran Away.`")
        await asyncio.sleep(2)
        await message.delete()
        return
    x = await client.get_inline_bot_results(
        "Stickerizerbot", f"#{random.choice(senpais)}{senpai}")
    await message.delete()
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True)
コード例 #15
0
ファイル: meme.py プロジェクト: wulan17/Nana-Remix
async def spam_stick(client, message):
    if not message.reply_to_message:
        await edrep(message, text="**reply to a sticker with amount you want to spam**")
        return
    if not message.reply_to_message.sticker:
        await edrep(message, text="**reply to a sticker with amount you want to spam**")
        return
    else:
        times = message.command[1]
        if message.chat.type in ['supergroup', 'group']:
            for _ in range(int(times)):
                await client.send_sticker(message.chat.id,
                sticker=message.reply_to_message.sticker.file_id,
                reply_to_message_id=ReplyCheck(message)
                )
                await asyncio.sleep(0.20)

        if message.chat.type == "private":
            for _ in range(int(times)):
                await client.send_message(message.chat.id,
                sticker=message.reply_to_message.sticker.file_id)
                await asyncio.sleep(0.20)
コード例 #16
0
async def carbon(client, message):
    cmd = message.command
    text = ""
    if len(cmd) > 1:
        text = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        text = message.reply_to_message.text
    elif not message.reply_to_message and len(cmd) == 1:
        await message.edit("Usage: `carbon (reply to a text)`")
        await asyncio.sleep(2)
        await message.delete()
        return
    await message.edit("Carbonizing the Code")
    try:
        carbon_result = requests.get(
            "https://sjprojectsapi.herokuapp.com/carbon/?"
            f"text={text}&theme={theme}&bg={bg}").json()
        await client.send_photo(chat_id=message.chat.id, 
                                reply_to_message_id=ReplyCheck(message),
                                photo=carbon_result['link'])
        await message.delete()
    except Exception:
        await message.edit("`api is offline please try again later.`")
コード例 #17
0
ファイル: rmbg.py プロジェクト: wahyudi12/Nana-Remix
async def remove_bg(client, message):
    if not remove_bg_api:
        await edrep(
            message,
            text=
            "Get the API from [Remove.bg](https://www.remove.bg/b/background-removal-api)",
            disable_web_page_preview=True,
            parse_mode="html",
        )
    replied = message.reply_to_message
    if (replied and replied.media and
        (replied.photo or
         (replied.document and "image" in replied.document.mime_type))):
        if os.path.exists(IMG_PATH):
            os.remove(IMG_PATH)
        await client.download_media(message=replied, file_name=IMG_PATH)
        try:
            rmbg = RemoveBg(remove_bg_api, "rm_bg_error.log")
            rmbg.remove_background_from_img_file(IMG_PATH)
            remove_img = IMG_PATH + "_no_bg.png"
            await client.send_document(
                chat_id=message.chat.id,
                document=remove_img,
                reply_to_message_id=ReplyCheck(message),
                disable_notification=True,
            )
            await message.delete()
            os.remove(remove_img)
            os.remove(IMG_PATH)
        except Exception as e:
            print(e)
            await edrep(message, text="`Something went wrong!`")
            await sleep(3)
            await message.delete()
    else:
        await edrep(message,
                    text="Usage: reply to a photo to remove background!")
コード例 #18
0
async def get_note(client, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return
    if len(message.text.split()) >= 2:
        note = message.text.split()[1]
    else:
        await message.edit("Give me a note tag!")

    getnotes = db.get_selfnote(message.from_user.id, note)
    if not getnotes:
        await message.edit("This note does not exist!")
        return

    if getnotes['type'] == Types.TEXT:
        teks, button = parse_button(getnotes.get('value'))
        button = build_keyboard(button)
        if button:
            button = InlineKeyboardMarkup(button)
        else:
            button = None
        if button:
            try:
                inlineresult = await app.get_inline_bot_results(f"@{BotUsername}", f"note {note}")
            except errors.exceptions.bad_request_400.BotInlineDisabled:
                await message.edit("Your bot inline isn't available!\nCheck your bot for more information!")
                await setbot.send_message(Owner, "Hello, your notes is look like include button, but i can't do that "
                                                 "because **inline mode** is not enabled.\n\n**To enable inline "
                                                 "mode:**\n1. Go to @BotFather and type `/mybots`\n2. Select your bot, "
                                                 "then click **Bot Settings**, click **Inline Mode**, then click "
                                                 "**Turn on**.\nOther option is optional, you can edit inline "
                                                 "placeholder as you like!\n\nAfter that, you can try again to get "
                                                 "that note!")
                return
            try:
                await message.delete()
                await client.send_inline_bot_result(
                    message.chat.id,
                    inlineresult.query_id,
                    inlineresult.results[0].id,
                    reply_to_message_id=ReplyCheck(message)
                )
            except IndexError:
                await message.edit("An error has accured! Check your assistant for more information!")
                return
        else:
            await message.edit(teks)
    elif getnotes['type'] in (Types.STICKER, Types.VOICE, Types.VIDEO_NOTE, Types.CONTACT, Types.ANIMATED_STICKER):
        await GET_FORMAT[getnotes['type']](message.chat.id, getnotes['file'], reply_to_message_id=ReplyCheck(message))
    else:
        if getnotes.get('value'):
            teks, button = parse_button(getnotes.get('value'))
            button = build_keyboard(button)
            if button:
                button = InlineKeyboardMarkup(button)
            else:
                button = None
        else:
            teks = None
            button = None
        if button:
            try:
                inlineresult = await app.get_inline_bot_results(f"@{BotUsername}", f"note {note}")
            except errors.exceptions.bad_request_400.BotInlineDisabled:
                await message.edit("Your bot inline isn't available!\nCheck your bot for more information!")
                await setbot.send_message(Owner,
                                          "Hello, your notes is look like include button, but i can't do that because "
                                          "**inline mode** is not enabled.\n\n**To enable inline mode:**\n1. Go to "
                                          "@BotFather and type `/mybots`\n2. Select your bot, then click **Bot "
                                          "Settings**, click **Inline Mode**, then click **Turn on**.\nOther option is "
                                          "optional, you can edit inline placeholder as you like!\n\nAfter that, "
                                          "you can try again to get that note!")
                return
            try:
                await message.delete()
                await client.send_inline_bot_result(
                    message.chat.id,
                    inlineresult.query_id,
                    inlineresult.results[0].id,
                    reply_to_message_id=ReplyCheck(message)
                )
            except IndexError:
                message.edit("An error has accured! Check your assistant for more information!")
                return
        else:
            await GET_FORMAT[getnotes['type']](message.chat.id, getnotes['file'], caption=teks,
                                               reply_to_message_id=ReplyCheck(message))
コード例 #19
0
ファイル: whois.py プロジェクト: muhammedfurkan/Nana-Bot
async def whois(client, message):
    cmd = message.command
    if not message.reply_to_message and len(cmd) == 1:
        get_user = message.from_user.id
    elif message.reply_to_message and len(cmd) == 1:
        get_user = message.reply_to_message.from_user.id
    elif len(cmd) > 1:
        get_user = cmd[1]
        try:
            get_user = int(cmd[1])
        except ValueError:
            pass
    try:
        user = await client.get_users(get_user)
    except PeerIdInvalid:
        await message.edit("I don't know that User.")
        sleep(2)
        await message.delete()
        return
    desc = await client.get_chat(get_user)
    desc = desc.description
    user_pic = await client.get_profile_photos(user.id)
    pic_count = await client.get_profile_photos_count(user.id)
    common = await GetCommon(client, user.id)

    if not user.photo:
        await message.edit(WHOIS.format(
            full_name=FullName(user),
            user_id=user.id,
            first_name=user.first_name,
            last_name=user.last_name if user.last_name else "",
            username=user.username if user.username else "",
            last_online=LastOnline(user),
            common_groups=len(common.chats),
            bio=desc if desc else "`No bio set up.`"),
                           disable_web_page_preview=True)
    elif user.photo:
        await client.send_photo(
            message.chat.id,
            user_pic[0].file_id,
            caption=WHOIS_PIC.format(
                full_name=FullName(user),
                user_id=user.id,
                first_name=user.first_name,
                last_name=user.last_name if user.last_name else "",
                username=user.username if user.username else "",
                last_online=LastOnline(user),
                profile_pics=pic_count,
                common_groups=len(common.chats),
                bio=desc if desc else "`No bio set up.`",
                profile_pic_update=ProfilePicUpdate(user_pic)),
            reply_to_message_id=ReplyCheck(message),
            file_ref=user_pic[0].file_ref,
        )
        await message.delete()


# add_command_help(
#     'whois', [
#         ['.whois', 'Finds out who the person is. Reply to message sent by the person'
#                    'you want information from and send the command. Without the dot also works.']
#     ]
# )
コード例 #20
0
async def tracemoe_rs(client, message):
    dis_loc = ''
    if message.reply_to_message:
        message_ = message.reply_to_message
        if message_.sticker and message_.sticker.file_name.endswith('.tgs'):
            await message.delete()
            return
        if message_.photo or message_.animation or message_.sticker:
            dis = await client.download_media(message=message_,
                                              file_name=screen_shot)
            dis_loc = os.path.join(screen_shot, os.path.basename(dis))
        if message_.animation:
            await edrep(message, text="`Converting this Gif`")
            img_file = os.path.join(screen_shot, "grs.jpg")
            await take_screen_shot(dis_loc, 0, img_file)
            if not os.path.lexists(img_file):
                await edrep(message,
                            text="`Something went wrong in Conversion`")
                await asyncio.sleep(5)
                await message.delete()
                return
            dis_loc = img_file
        if message_.video:
            nama = "video_{}-{}.mp4".format(
                message.reply_to_message.video.date,
                message.reply_to_message.video.file_size)
            await client.download_media(message.reply_to_message.video,
                                        file_name="nana/downloads/" + nama)
            dis_loc = "nana/downloads/" + nama
            img_file = os.path.join(screen_shot, "grs.jpg")
            await take_screen_shot(dis_loc, 0, img_file)
            if not os.path.lexists(img_file):
                await edrep(message,
                            text="`Something went wrong in Conversion`")
                await asyncio.sleep(5)
                await message.delete()
                return
        if dis_loc:
            tracemoe = tracemoepy.async_trace.Async_Trace()
            if message_.video:
                search = await tracemoe.search(img_file, encode=True)
                os.remove(img_file)
            else:
                search = await tracemoe.search(dis_loc, encode=True)
            os.remove(dis_loc)
            result = search['docs'][0]
            ms_g = f"**Title**: {result['title_english']}" \
                  f"\n**Similarity**: {result['similarity']*100}"\
                  f"\n**Episode**: {result['episode']}"
            preview = await tracemoe.video_preview(search)
            with open('preview.mp4', 'wb') as f:
                f.write(preview)
            await message.delete()
            await client.send_video(message.chat.id,
                                    'preview.mp4',
                                    caption=ms_g,
                                    reply_to_message_id=ReplyCheck(message))
            await asyncio.sleep(5)
            await message.delete()
            os.remove('preview.mp4')
        else:
            await message.delete()
            return
    else:
        await edrep(message, text="`Reply to a message to proceed`")
        await asyncio.sleep(5)
        await message.delete()
        return
コード例 #21
0
ファイル: lydia.py プロジェクト: Reyatsu99/Nana-Bot
async def lydia_reply(_client, message):
    global session
    if lydia_status:
        output = session.think_thought(message.text)
        return await message.reply_text("`{0}`".format(output), quote=True, reply_to_message_id=ReplyCheck(message))
コード例 #22
0
ファイル: lastfm.py プロジェクト: aristahanif/Hitagi-Bot
async def lastfm(client, message):
    x = await client.get_inline_bot_results("lastfmrobot", "")
    await message.delete()
    await message.reply_inline_bot_result(x.query_id, x.results[0].id,
                                          reply_to_message_id=ReplyCheck(message),
                                          hide_via=True)