예제 #1
0
async def set_default_commands(dp: Dispatcher):
    """
    Ставит стандартные команды бота
    """

    logger.info("Установка стандартных команд-подсказок...")

    commands_members = {
        "gay": "Узнать, на сколько % пользователь гей",
        "biba": "Узнать сколько см у пользователя биба",
        "top_helpers": "Узнать топ хелперов"
    }
    command_defaults = {'help': 'Help me'}
    commands_admins = {
        "set_photo": "(admins only) Установить фото в чате",
        "set_title": "(admins only) Установить название группы",
        "set_description": "(admins only) Установить описание группы",
        "unro": "(admins only) Размутить пользователя",
        "unban": "(admins only) Разбанить пользователя",
        "media_false": "(admins only) Запрещает использование media",
        "media_true": "(admins only) Разрешает использование media",
    }
    await dp.bot.set_my_commands(
        [BotCommand(name, value) for name, value in command_defaults.items()],
        scope=types.BotCommandScopeDefault())
    await dp.bot.set_my_commands(
        [BotCommand(name, value) for name, value in commands_members.items()],
        scope=types.BotCommandScopeAllGroupChats())
    await dp.bot.set_my_commands(
        [BotCommand(name, value) for name, value in commands_admins.items()],
        scope=types.BotCommandScopeAllChatAdministrators())
    logger.info('Команды назначены.')
예제 #2
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/drinks", description="Заказать напитки"),
        BotCommand(command="/food", description="Заказать блюда"),
        BotCommand(command="/cancel", description="Отменить текущее действие")
    ]
    await bot.set_my_commands(commands)
예제 #3
0
async def set_commands(bot):
    commands = [
        BotCommand(command="/random", description="Случайный фильм"),
        BotCommand(command="/stop", description="Рыба-акула игра утонула"),
    ]

    await bot.set_my_commands(commands)
예제 #4
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/start", description="Запустить бота"),
        BotCommand(command="/anketa", description="Заполнить анкету"),
        BotCommand(command="/cancel", description="Отменить действие")
    ]
    await bot.set_my_commands(commands)
예제 #5
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/add", description="Добавить новую ссылку"),
        BotCommand(command="/links", description="Просмотр списка ссылок"),
        BotCommand(command="/cancel", description="Отменить текущее действие")
    ]
    await bot.set_my_commands(commands)
예제 #6
0
async def set_commands(bot: Bot):
    # команды бота
    commands = [
        BotCommand(command='/start', description='Запустить бота'),
        BotCommand(command='/help', description='Помощь'),
    ]
    await bot.set_my_commands(commands)
예제 #7
0
async def set_commands(message: Message):
    commands = [
        BotCommand(command="/start", description="Start"),
        BotCommand(command="/help", description="Help message"),
        BotCommand(command="/tasks", description="Allow tasks")
    ]
    await message.bot.set_my_commands(commands)
    await message.answer("Commands set up!")
예제 #8
0
async def set_my_commands(dp: Dispatcher):
    await dp.bot.set_my_commands(
        [
            BotCommand("/start", "🟢 Setup bot"),
            BotCommand("/ping", "🏓 Pong"),
            BotCommand("/help", "? Help page"),
        ]
    )
예제 #9
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/me", description="Мой профиль"),
        BotCommand(command="/cart", description="Корзина покупок"),
        BotCommand(command="/shop", description="Каталог товаров"),
        BotCommand(command="/about", description="О боте")
    ]
    await bot.set_my_commands(commands)
예제 #10
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command='/start', description='How to start'),
        BotCommand(command='/cancel', description='Reset to start'),
        BotCommand(command='/stop', description='Stop all rigs'),
        BotCommand(command='/run', description='Run choosen miner')
    ]

    await bot.set_my_commands(commands)
예제 #11
0
async def on_startup_commands(dp):
    """
    Configuring commands for the bot at the first start.
    You can add the required commands here yourself.
    """
    await dp.bot.set_my_commands([
        BotCommand("start", "About me."),
        BotCommand("settings", "My settings.")
    ])
예제 #12
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command=COMMAND_CREATE_EVENT[0],
                   description=COMMAND_CREATE_EVENT[1]),
        BotCommand(command=COMMAND_HELP[0], description=COMMAND_HELP[1]),
        BotCommand(command=COMMAND_START[0], description=COMMAND_START[1]),
        BotCommand(command=COMMAND_TEST[0], description=COMMAND_TEST[1]),
    ]
    await bot.set_my_commands(commands)
예제 #13
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/status",
                   description="Взять паузу от встреч/возобновить встречи"),
        BotCommand(command="/settings", description="Настройки аккаунта"),
        BotCommand(command="/payment", description="Изменить тарифный план"),
        BotCommand(command="/contact", description="Связаться с нами"),
    ]
    await bot.set_my_commands(commands)
예제 #14
0
def get_default_commands(lang: str = 'en') -> list[BotCommand]:
    commands = [
        BotCommand('/start', _('start bot', locale=lang)),
        BotCommand('/help', _('how it works?', locale=lang)),
        BotCommand('/lang', _('change language', locale=lang)),
        BotCommand('/settings', _('open bot settings', locale=lang)),
    ]

    return commands
예제 #15
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/new_task", description="Начать создания заявки"),
        BotCommand(command="/present_task",
                   description="Показать созданную заявку"),
        BotCommand(command="/reload", description="Повторить ввод"),
        BotCommand(command="/cancel", description="Сбросить создания заявки")
    ]
    await bot.set_my_commands(commands)
예제 #16
0
async def set_commands(message: Message):
    commands = [
        BotCommand(command="/start", description=Button.START),
        BotCommand(command="/set_commands", description=Button.SET_COMMANDS),
        BotCommand(command="/help", description=Button.HELP),
    ]
    await message.answer(
        'Команды установлены. \nДля отображения списка комманд перезапустите приложение телеграм'
    )
    await bot.set_my_commands(commands)
예제 #17
0
async def setMyCommands(dp):
    await dp.bot.set_my_commands(
        [
            BotCommand("start", "Start bot"),
            BotCommand("show", "Show all items"),
            BotCommand("add", "Add new item"),
            BotCommand("del", "Delete some item"),
            BotCommand("help", "Show info commands")
        ]
    )
예제 #18
0
async def set_commands(bot: Bot):
    commands = [
        BotCommand(command="/services",
                   description="📄 Get list of supported streaming services"),
        BotCommand(command="/lang",
                   description="🇺🇸 Set bot language [/lang en]"),
        BotCommand(command="/contacts",
                   description="✉️ Get contacts for communication"),
        BotCommand(command='/layout',
                   description='🗒️ Select layout for streaming links response')
    ]
    await bot.set_my_commands(commands)
예제 #19
0
def get_admin_commands(lang: str = 'en') -> list[BotCommand]:
    commands = get_default_commands(lang)

    commands.extend([
        BotCommand('/export_users', _('export users to csv', locale=lang)),
        BotCommand('/count_users',
                   _('count users who contacted the bot', locale=lang)),
        BotCommand(
            '/count_active_users',
            _('count active users (who didn\'t block the bot)', locale=lang)),
    ])

    return commands
예제 #20
0
async def on_startup(dp):
    import filters
    import middlewares
    filters.setup(dp)
    middlewares.setup(dp)
    await bot.set_webhook(WEBHOOK_URL)
    from utils.notify_admins import on_startup_notify
    await on_startup_notify(dp)
    commands = [
        BotCommand(command='/start', description='Начать'),
        BotCommand(command='/help', description='Получить справку'),
        BotCommand(command='/register', description='Регистрация'),
        BotCommand(command='/now',
                   description='Получить данные по отключениям сейчас'),
    ]
    await bot.set_my_commands(commands)
예제 #21
0
async def set_default_commands(dp):
    """
    Ставит стандартные комманды бота
    """

    logger.info("Установка стандартных комманд-подсказок...")
    
    # TODO: Переместить это в нормальное место
    commands = {
        "set_photo": "(admins only) Установить фото в чате",
        "set_title": "(admins only) Установить название группы",
        "set_description": "(admins only) Установить описание группы",
        # no u
        "gay": "Узнать, на сколько % пользователь гей",
        "metabolism": "Узнать свою суточную норму калорий",
        "biba": "Узнать сколько см у пользователя биба",
        "unro": "(admins only) Размутить пользователя",
        "unban": "(admins only) Разбанить пользователя",
        "media_false": "(admins only) Запрещает использование media",
        "media_true": "(admins only) Разрешает использование media",
    }

    await dp.bot.set_my_commands(
        [BotCommand(name, value) for name, value in commands.items()]
    )
예제 #22
0
async def get_default_commands():
	commands = [
        {
            'command': 'demotivator',
            'description': '🌄 Создание демотиватора',
        }, {
            'command': 'qr',
            'description': '📊 Разпознать QR-код',
        }, {
            'command': 'settings',
            'description': '🔧 Настройки',
        }, {
            'command': 'get_keyboard',
            'description': '🟩 Вкл. клавиатуру ответов',
        }, {
            'command': 'rm_keyboard',
            'description': '🟥 Выкл. клавиатуру ответов',
        },
    ]

	commands = [
        BotCommand(command['command'], command['description'])
        for command in commands
    ]

	return commands
예제 #23
0
async def set_command(message: Message, new_commands):
    commands = [command.split(',') for command in new_commands.split(';')]
    if len(commands[::-1][0]) == 1: commands = commands[::-1][1:]
    await telegramBot.bot.set_my_commands([
        BotCommand(command=command[0], description=command[1])
        for command in commands
    ])
    await message.answer("Команды настроены.")
예제 #24
0
async def set_commands(bot: Bot):
    """Set commands for run dot."""
    command_list = []
    for command, description in COMMANDS.items():
        command_list.append(
            BotCommand(command=command, description=description)
        )
    await bot.set_my_commands(command_list)
예제 #25
0
async def set_commands(dp: Dispatcher, commands: dict):
    """
    Set command hints
    """

    await dp.bot.set_my_commands([
        BotCommand(command, description)
        for command, description in commands.items()
    ])
예제 #26
0
def initialize_project(dispatcher: Dispatcher = None,
                       bot: Bot = None,
                       loop=None) -> typing.Tuple[Dispatcher, Bot]:
    if not TELEGRAM_BOT_TOKEN and not bot:
        raise exceptions.BotTokenNotDefined
    if not dispatcher:
        loop = loop or asyncio.get_event_loop()
        bot = bot or Bot(token=TELEGRAM_BOT_TOKEN, parse_mode=PARSE_MODE)
        dp = dispatcher or Dispatcher(bot=bot, storage=BOT_STORAGE, loop=loop)
    else:
        dp = dispatcher
        bot = bot or dp.bot
    Dispatcher.set_current(dp)

    dp.filters_factory.bind(
        Entities, event_handlers=[dp.message_handlers, dp.poll_handlers])
    dp.filters_factory.bind(
        ChatTypeFilter,
        event_handlers=[dp.message_handlers, dp.callback_query_handlers])
    dp.filters_factory.bind(
        ChatMemberStatus,
        event_handlers=[dp.message_handlers, dp.callback_query_handlers])
    dp.filters_factory.bind(PollTypeFilter,
                            event_handlers=[
                                dp.message_handlers,
                                dp.callback_query_handlers, dp.poll_handlers
                            ])
    dp.filters_factory.bind(
        DiceEmoji,
        event_handlers=[dp.message_handlers, dp.callback_query_handlers])
    dp.filters_factory.bind(FuncFilter)

    utils.import_all_modules_in_project(project=PROJECT)
    views = utils.get_non_original_subclasses(BaseView,
                                              'aiogram_oop_framework')

    for middleware in MIDDLEWARES:
        dp.middleware.setup(middleware())

    from aiogram.types import BotCommand
    command_objects = {}
    ordered_views = utils.order_views(views)
    for view in ordered_views:
        view.bot = view.bot or bot
        if UserBaseView in view.__bases__:
            continue
        if AUTO_REGISTER_VIEWS is True and view.auto_register is True:
            view.register(dp=dp)
        if view.short_description and view.set_my_commands:
            commands = utils.resolve_set_my_commands(view)
            for command in commands:
                command_objects[command] = command_objects.get(
                    command, BotCommand(command, view.short_description))
    if command_objects:
        dp.loop.run_until_complete(
            bot.set_my_commands(list(command_objects.values())))
    return dp, bot
예제 #27
0
async def bot_startup(_: Dispatcher):
    await bot.set_my_commands([
        BotCommand(command=command, description=description)
        for command, description in {
            **COMMON_COMMANDS,
            **ADMIN_COMMANDS
        }.items()
    ])
    if settings.WEBHOOK_ENABLED:
        await bot.set_webhook(settings.WEBHOOK_URL)
예제 #28
0
async def on_startup_notify(dp: Dispatcher):
    try:

        await dp.bot.send_message(AdminId[0], "🟢 Бот запущен")

        await dp.bot.set_my_commands(
            [BotCommand(command='/start', description='Начать работу')])

    except Exception as err:

        logging.exception(err)
async def set_default_commands(dp):
    await dp.bot.set_my_commands([
        BotCommand('start', 'Start Bot'),
        BotCommand('help', 'Helper'),
        BotCommand('menu', 'Bots menu'),
        BotCommand('quiz', 'Quick test'),
        BotCommand('get_crypto_price', 'Get cryptocurrency price'),
        BotCommand('show_on_map', 'Show nearest crypto exchangers'),
        BotCommand('email', 'Update email in database')
    ])
예제 #30
0
async def set_my_commands(bot: Bot):
    await bot.set_my_commands([
        BotCommand("start", "Start"),
        BotCommand("help", "Help"),
        BotCommand("settings", "Settings"),
        BotCommand("clear", "Clear caption (Reply to message)"),
        BotCommand("del", "Delete message (Reply to message)"),
        BotCommand("delete_all", "⚠️ Delete all messages"),
    ])