예제 #1
0
import nana.plugins.meme_strings as meme_strings
from nana import AdminSettings
from nana import BotID
from nana import BotUsername
from nana import LYDIA_API
from nana import Owner
from nana import setbot
from nana.utils import filt
from nana.plugins.assistant.database import lydia_db as sql

CoffeeHouseAPI = API(LYDIA_API)
api_ = LydiaAI(CoffeeHouseAPI)


@setbot.on_message(filters.user(AdminSettings) & filt.command(['addchat']))
async def add_chat(_, message):
    global api_
    chat_id = message.chat.id
    is_chat = sql.is_chat(chat_id)
    if not is_chat:
        ses = api_.create_session()
        ses_id = str(ses.id)
        expires = str(ses.expires)
        sql.set_ses(chat_id, ses_id, expires)
        await message.reply('AI successfully enabled for this chat!')
    else:
        await message.reply('AI is already enabled for this chat!')


@setbot.on_message(filters.user(AdminSettings) & filt.command(['rmchat']))
예제 #2
0
Here are some links for you
        """
    buttons = InlineKeyboard(row_width=2)
    buttons.add(
        InlineKeyboardButton(
            'Documentation', url='https://aman-a.gitbook.io/nana-remix/',
        ),
        InlineKeyboardButton(
            'Repository', url='https://github.com/pokurt/Nana-Remix',
        ),
        InlineKeyboardButton('Support', url='https://t.me/nanabotsupport'),
    )
    await message.reply(msg, reply_markup=buttons)


@setbot.on_message(filters.user(AdminSettings) & filt.command(['start']))
async def start(_, message):
    if message.chat.type != 'private':
        await message.reply('henlo ^0^')
    else:
        if len(message.text.split()) >= 2:
            helparg = message.text.split()[1]
            if helparg == 'help_inline':
                await message.reply(
                    tld(
                        'inline_help_text',
                    ).format(
                        BotUsername,
                    ),
                )
                return
예제 #3
0
            callback_data='setsticker',
        ),
        InlineKeyboardButton(
            tld('language_btn'),
            callback_data='set_lang_',
        ),
        InlineKeyboardButton(
            'Select Branch',
            callback_data='change_branches',
        ),
    )
    return list_button


@setbot.on_message(
    filters.user(AdminSettings) & filt.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:
예제 #4
0
async def help_parser(client, chat_id, text, keyboard=None):
    if not keyboard:
        keyboard = InlineKeyboardMarkup(
            paginate_modules(0, HELP_COMMANDS, 'help'), )
    if NANA_IMG:
        await client.send_photo(
            chat_id,
            NANA_IMG,
            caption=text,
            reply_markup=keyboard,
        )
    else:
        await client.send_message(chat_id, text, reply_markup=keyboard)


@setbot.on_message(filters.user(AdminSettings) & filt.command(['help']))
async def help_command(client, message):
    if message.chat.type != 'private':
        buttons = InlineKeyboardMarkup([
            [
                InlineKeyboardButton(
                    text='Help',
                    url=f't.me/{BotUsername}?start=help',
                ),
            ],
        ], )
        await message.reply(
            '**OWNER ONLY**\nContact me in PM',
            reply_markup=buttons,
        )
        return
예제 #5
0
import os
import re
import subprocess
import sys
import traceback
from io import StringIO

from pyrogram import filters

from nana import Owner
from nana import setbot
from nana.utils import filt
from nana.plugins.devs import aexec


@setbot.on_message(filters.user(Owner) & filt.command(['eval']))
async def eval(client, message):
    status_message = await message.reply_text('`Running ...`')
    try:
        cmd = message.text.split(' ', maxsplit=1)[1]
    except IndexError:
        await status_message.delete()
        return
    reply_to_id = message.message_id
    if message.reply_to_message:
        reply_to_id = message.reply_to_message.message_id
    old_stderr = sys.stderr
    old_stdout = sys.stdout
    redirected_output = sys.stdout = StringIO()
    redirected_error = sys.stderr = StringIO()
    stdout, stderr, exc = None, None, None
예제 #6
0
from nekobin import NekoBin
from nana import setbot
from nana import AdminSettings
from nana.utils.dynamic_filt import dynamic_data_filter
from nana.utils import filt

from pyrogram import filters
from pyrogram.types import InlineKeyboardButton

from pykeyboard import InlineKeyboard


@setbot.on_message(
    filters.user(AdminSettings) &
    filt.command('logs'),
)
async def logs(_, message):
    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
예제 #7
0
from nana import DB_AVAILABLE
from nana import NANA_IMG
from nana import Owner
from nana import setbot
from nana.utils import filt
from nana.plugins.assistant.database.stickers_db import set_stanim_set
from nana.plugins.assistant.database.stickers_db import set_sticker_set
from nana.utils.dynamic_filt import dynamic_data_filter

TEMP_KEYBOARD = []
USER_SET = {}
TODEL = {}


@setbot.on_message(
    filters.user(AdminSettings) & filt.command(['setsticker']), )
async def get_stickers(_, 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)
    keyboard = await app.get_history('@Stickers', limit=1)
    keyboard = keyboard[0].reply_markup.keyboard
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)
    await app.send_message('@Stickers', '/cancel')
    msg = await message.reply(
        'Select your stickers for set as kang sticker',
예제 #8
0
from nekobin import NekoBin
from nana import setbot
from nana import AdminSettings
from nana.utils.dynamic_filt import dynamic_data_filter
from nana.utils import filt

from pyrogram import filters
from pyrogram.types import InlineKeyboardButton

from pykeyboard import InlineKeyboard


@setbot.on_message(
    filters.user(AdminSettings) & filt.command('logs'), )
async def logs(_, message):
    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,
    )


@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)
예제 #9
0
import os

from pydrive import auth
from pydrive.drive import GoogleDrive
from pyrogram import filters

from nana import setbot, AdminSettings, gauth, GDRIVE_CREDENTIALS, ENV
from nana.languages.strings import tld
from nana.utils import filt


@setbot.on_message(filters.user(AdminSettings) & filt.command(['gdrive']))
async def gdrive_helper(_, message):
    if len(message.text.split()) == 1:
        gdriveclient = os.path.isfile('client_secrets.json')
        if ENV:
            if not GDRIVE_CREDENTIALS:
                await message.reply(tld('gdrive_credential_err_heroku'))
                return
            elif not gdriveclient:
                with open('client_secrets.json', 'w') as gfile:
                    gfile.write(GDRIVE_CREDENTIALS)
                    gfile.close()
                gdriveclient = os.path.isfile('client_secrets.json')
        if not gdriveclient:
            await message.reply(tld('gdrive_credential_err'))
            return

        gauth.LoadCredentialsFile('nana/session/drive')
        if gauth.credentials is None:
            try: