Ejemplo n.º 1
0
    return list_button


@setbot.on_message(
    filters.user(AdminSettings) & filters.command(['settings'])
    & filters.private, )
async def settings(_, message):
    text = await get_text_settings()
    button = await get_button_settings()
    if NANA_IMG:
        await message.reply_photo(NANA_IMG, caption=text, reply_markup=button)
    else:
        await message.reply(text, reply_markup=button)


@setbot.on_callback_query(dynamic_data_filter('toggle_startbot'))
async def start_stop_bot(client, query):
    try:
        await app.stop()
    except ConnectionError:
        await reload_userbot()
        text = await get_text_settings()
        button = await get_button_settings()
        text += tld('settings_stats_botstart')
        try:
            await query.message.edit_text(text, reply_markup=button)
        except errors.exceptions.bad_request_400.MessageNotModified:
            pass
        await client.answer_callback_query(
            query.id,
            tld('settings_stats_botstart'),
Ejemplo n.º 2
0
        getpp = await client.download_media(
            me.photo.big_file_id,
            file_name='nana/downloads/pfp.png',
        )
        await message.reply_photo(
            photo=getpp,
            caption=text,
            reply_markup=button,
        )
    else:
        await message.reply(text, reply_markup=button)
    if os.path.exists(getpp):
        os.remove(getpp)


@setbot.on_callback_query(dynamic_data_filter('hide_number'))
async def get_myself_btn(client, query):
    try:
        me = await app.get_me()
    except ConnectionError:
        await client.answer_callback_query(
            query.id, 'Bot is currently turned off!', show_alert=True,
        )
        return

    if query.message.caption:
        text = query.message.caption.markdown
    else:
        text = query.message.text.markdown

    num = ['#' * len(me.phone_number)]
Ejemplo n.º 3
0
from pyrogram import filters
from pyrogram.types import InlineKeyboardButton
from pyrogram.types import InlineKeyboardMarkup

from nana import NANA_IMG
from nana import setbot
from nana.__main__ import restart_all
from nana.utils.dynamic_filt import dynamic_data_filter

try:
    repo = Repo()
except InvalidGitRepositoryError:
    pass


@setbot.on_callback_query(dynamic_data_filter('change_branches'))
async def chng_branch(_, query):
    buttons = [[InlineKeyboardButton(r, callback_data=f'chng_branch_{r}')]
               for r in repo.branches]
    if NANA_IMG:
        await query.message.edit_caption(
            'Which Branch would you like to change to?\n' +
            '(this might break your userbot' +
            'if you are not cautious of what you are doing)', ),
        await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
    else:
        await query.message.edit(
            'Which Branch would you like to change to?',
            reply_markup=InlineKeyboardMarkup(buttons),
        )
Ejemplo n.º 4
0
            break
        time_list.append(int(result))
        seconds = int(remainder)

    for x in range(len(time_list)):
        time_list[x] = str(time_list[x]) + time_suffix_list[x]
    if len(time_list) == 4:
        ping_time += time_list.pop() + ", "

    time_list.reverse()
    ping_time += ":".join(time_list)

    return ping_time


@setbot.on_callback_query(dynamic_data_filter("alive_message"))
async def alivemsg_callback(client, query):
    start_time = time.time()
    uptime = get_readable_time((time.time() - StartTime))
    reply_msg = f"{OwnerUsername}@nana-remix\n"
    reply_msg += "------------------\n"
    end_time = time.time()
    ping_time = round((end_time - start_time) * 1000, 3)
    reply_msg += f"Ping: {ping_time}ms\n"
    reply_msg += f"Userbot uptime: {uptime}"
    await client.answer_callback_query(query.id, reply_msg, show_alert=True)


@app.on_message(
    filters.user(AdminSettings) & filters.command("alive", COMMAND_PREFIXES))
async def alive_msg(client, message):
Ejemplo n.º 5
0
    try:
        keyboard = InlineKeyboard(row_width=1)
        keyboard.add(
            InlineKeyboardButton('~ Nekofy', callback_data='nekofy'),
        )
        await message.reply_document(
            'nana/logs/error.txt',
            caption='Here are your logs!',
            reply_markup=keyboard,
        )
    except ValueError:
        await message.reply('**Codes are clean! :D**')
        return


@setbot.on_callback_query(dynamic_data_filter('nekofy'))
async def paste_log_neko(client, query):
    nekobin = NekoBin()
    if query.from_user.id in AdminSettings:
        with open('nana/logs/error.txt') as f:
            data = await nekobin.nekofy(f.read())
        keyb = InlineKeyboard(row_width=2)
        keyb.add(
            InlineKeyboardButton('URL', url=(str(data.url)) + '.py'),
            InlineKeyboardButton('RAW', url=(str(data.raw)) + '.py'),
        )
        await query.message.edit_caption(
            '🐱 **Successfully Nekofied ~**', reply_markup=keyb,
        )
    else:
        await client.answer_callback_query(
Ejemplo n.º 6
0
    button = InlineKeyboardMarkup([[
        InlineKeyboardButton("Hide phone number", callback_data="hide_number")
    ]])
    if me.photo:
        getpp = await client.download_media(me.photo.big_file_id,
                                            file_name="nana/downloads/pfp.png")
        await message.reply_photo(photo=getpp,
                                  caption=text,
                                  reply_markup=button)
    else:
        await message.reply(text, reply_markup=button)
    if os.path.exists(getpp):
        os.remove(getpp)


@setbot.on_callback_query(dynamic_data_filter("hide_number"))
async def get_myself_btn(client, query):
    try:
        me = await app.get_me()
    except ConnectionError:
        await client.answer_callback_query(query.id,
                                           "Bot is currently turned off!",
                                           show_alert=True)
        return

    if query.message.caption:
        text = query.message.caption.markdown
    else:
        text = query.message.text.markdown

    num = ["*" * len(me.phone_number)]
Ejemplo n.º 7
0
    if NANA_IMG:
        await setbot.send_photo(
            message.chat.id,
            NANA_IMG,
            caption=text,
            reply_markup=button,
        )
    else:
        await client.send_message(
            message.chat.id,
            text,
            reply_markup=button,
        )


@setbot.on_callback_query(dynamic_data_filter('setsticker'))
async def settings_sticker(_, message):
    if not DB_AVAILABLE:
        await message.edit("You haven't set up a database!")
        return
    global TEMP_KEYBOARD, USER_SET
    await app.send_message('@Stickers', '/stats')
    await asyncio.sleep(0.2)
    try:
        keyboard = await app.get_history('@Stickers', limit=1)
        keyboard = keyboard[0].reply_markup.keyboard
    except IndexError:
        await message.edit(
            'You dont have any sticker pack!\nAdd stickers pack in @Stickers ',
        )
        return
Ejemplo n.º 8
0
    text += f'**CHANGELOG:**\n`{changelog}`'
    button = InlineKeyboard(row_width=1)
    button.add(
        InlineKeyboardButton(
            tld('update_now_btn'),
            callback_data='update_now',
        ), )
    await setbot.send_message(
        Owner,
        text,
        reply_markup=button,
        parse_mode='markdown',
    )


@setbot.on_callback_query(dynamic_data_filter('update_now'))
async def update_button(client, query):
    await query.message.delete()
    await client.send_message(Owner, 'Updating, please wait...')
    try:
        repo = Repo()
    except NoSuchPathError as error:
        log.warning(f'Check update failed!\nDirectory {error} is not found!')
        return
    except InvalidGitRepositoryError as error:
        log.warning(
            'Check update failed!\nDirectory {} Not a git repository'.format(
                error, ), )
        return
    except GitCommandError as error:
        log.warning(f'Check update failed!\n{error}')
Ejemplo n.º 9
0
    return InlineKeyboardMarkup(list_button)


@setbot.on_message(
    filters.user(AdminSettings) & filters.command(["settings"])
    & filters.private)
async def settings(_, message):
    text = await get_text_settings()
    button = await get_button_settings()
    if NANA_IMG:
        await message.reply_photo(NANA_IMG, caption=text, reply_markup=button)
    else:
        await message.reply(text, reply_markup=button)


@setbot.on_callback_query(dynamic_data_filter("toggle_startbot"))
async def start_stop_bot(client, query):
    try:
        await app.stop()
    except ConnectionError:
        await reload_userbot()
        text = await get_text_settings()
        button = await get_button_settings()
        text += tld("settings_stats_botstart")
        try:
            await query.message.edit_text(text, reply_markup=button)
        except errors.exceptions.bad_request_400.MessageNotModified:
            pass
        await client.answer_callback_query(query.id,
                                           tld("settings_stats_botstart"))
        return