Пример #1
0
        return

    log.warning(f"New UPDATE available for [{brname}]!")

    text = tld("updater_available_text").format(brname)
    text += f"**CHANGELOG:**\n`{changelog}`"
    button = InlineKeyboardMarkup([[
        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(
            f"Check update failed!\nDirectory {error} does not seems to be a git repository"
        )
        return
    except GitCommandError as error:
        log.warning(f"Check update failed!\n{error}")
Пример #2
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
Пример #3
0
                remote = repo.create_remote("heroku", heroku_git_url)
            remote.push(refspec="HEAD:refs/heads/master", force=True)


async def configrepo():
    cache_path = "nana/cache/repo.json"
    if not os.path.exists(cache_path):
        config_url = "https://raw.githubusercontent.com/legenhand/Nana-bot-file/master/config/repo.json"
        urllib.request.urlretrieve(config_url, cache_path)
    f = open("nana/cache/repo.json")
    data_repo = json.load(f)
    f.close()
    return data_repo


@setbot.on_callback_query(dynamic_data_filter("change_repo"))
async def chgrepo(_, query):
    text = "**⚙️ Repository Configuration **\n" "`Change Your Repo Source Here! `\n"

    data_repo = await configrepo()

    list_button = []
    for r in data_repo.items():
        list_button.append([InlineKeyboardButton(r[0], callback_data=r[0])])
    list_button.append([InlineKeyboardButton("⬅ back️", callback_data="back")])
    button = InlineKeyboardMarkup(list_button)
    await query.message.edit_text(text, reply_markup=button)


@setbot.on_callback_query(filters.regex("^Nana"))
async def chgrepoo(_, query):
Пример #4
0
        TEMP_KEYBOARD = []
        USER_SET = {}
    else:
        status = "Invalid pack selected."
        TEMP_KEYBOARD = []
        USER_SET = {}
    text = await get_text_settings()
    text += "\n{}".format(status)
    button = await get_button_settings()
    await setbot.send_photo(message.chat.id,
                            NANA_IMG,
                            caption=text,
                            reply_markup=button)


@setbot.on_callback_query(dynamic_data_filter("setsticker"))
async def settings_sticker(client, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        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:
        await message.edit(
            "You dont have any sticker pack!\nAdd stickers pack in @Stickers ")
        return
    for x in keyboard:
Пример #5
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))
async def google_search(client, message):
Пример #6
0
from git import Repo
from git.exc import GitCommandError
from nana import setbot, app, AdminSettings, NANA_IMG
from nana.__main__ import restart_all
from nana.assistant.__main__ import dynamic_data_filter
import os
import re
from asyncio import create_subprocess_exec, sleep

from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram import filters

repo = Repo()


@setbot.on_callback_query(dynamic_data_filter("change_branches"))
async def chng_branch(client, 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),
        )