Exemplo n.º 1
0
@dp.message_handler(commands=['help'])
async def cmd_help(msg: ats.Message):
    await msg.answer('Hello, i MyEverBestBot')


@dp.message_handler(filters.CommandPrivacy())
async def cmd_privacy(msg: ats.Message):
    await msg.answer('Privacy')

@dp.message_handler(commands=['test'], commands_prefix='/!')
async def cmd_test(msg: ats.Message):
    await msg.answer('Test')


@dp.message_handler(regexp_commands=[r'r_(\d+)'])
async def cmd_r(msg: ats.Message, regexp_command):
    await msg.answer(f'ref is {regexp_command[1]}')


@dp.message_handler(
    filters.CommandStart(re.compile(r'u(\d+)')))
async def cmd_start(msg: ats.Message, deep_link):
    await msg.answer(f'Deep link u is {deep_link[1]}')


@dp.message_handler(text='some')
@dp.message_handler(commands=['some'])
async def some_start(msg: ats.Message):
    await msg.answer('Hello from some')
Exemplo n.º 2
0
@repeat
def watcher_photos():
    if Raspberry.Isrun and watcher.Isrun and today.Isbusinessday(
    ) and today.Isworktime() and Raspberry.Muvement():
        loop.create_task(send_photo(CHAT))
    return LOOP_DELAY


@repeat
def periodic_photos():
    if Raspberry.Isrun and periodic.Isrun:
        loop.create_task(send_photo(CHAT))
    return periodic.period


@dp.message_handler(filters.CommandStart())
async def process_start(message: Message):
    await bot.send_message(message.from_user.id,
                           "Hi! What do you want to do?",
                           reply_markup=keyboard.main_keyboard)


@dp.callback_query_handler(lambda command: command.data == 'make_photo')
async def callback_make_photo(callback_query: CallbackQuery):
    await bot.answer_callback_query(callback_query.id)
    if Raspberry.Isrun:
        await send_photo(callback_query.from_user.id)
        await edit_message("Anything else?", callback_query)
    else:
        await edit_message("Access to the camera is forbidden.Anything else?",
                           callback_query)
Exemplo n.º 3
0
from aiogram import filters
from aiogram.types import (Message, CallbackQuery, ParseMode, BotCommand, ReplyKeyboardMarkup, KeyboardButton,
                           ContentType, ChatActions)
from app.core.bot import dp, bot
from app.core.config import settings
from app.core.language import _  # noqa
from app.crud import crud_user, crud_task
from app.keyboards import task_keyboard, welcome_keyboard
from app.utils import (not_registered, check_value, registration_messages, task_parser, is_admin, is_task, menu,
                       menu_parser, is_private, is_task_lock, time_left_start, is_deactivate)


@dp.message_handler(filters.CommandStart(), is_private)
async def start_handler(message: Message):
    # Welcome
    text = _(
        "Hello! With this bot, you can subscribe to the **EUC Testing Initiative for UniRoadMap** to help us create a "
        "really polished and _good_ product! Your data will be used to create **unique** settings for **each** EUC "
        "model for our navigation engine. Every personal information about you is stored _securely_ and **no one** "
        "except our developers can access it. "
    )

    registered = await crud_user.is_registered(message.from_user.id)

    if registered:
        await message.answer(text, parse_mode=ParseMode.MARKDOWN)

        if await is_task_lock(message):
            await tasks_plug(message)
        else:
            await tasks_handler(message)