Beispiel #1
0
async def add_status(msg: types.Message, state: FSMContext):
    if msg.text.lower() == 'закрашена':
        await state.update_data(status='buff')
    elif msg.text.lower() == 'на месте':
        await state.update_data(status='onspot')
    data = await state.get_data()
    text = f'''
Название: {data.get('name')}
Автор: {data.get('author')}
Местечко: {data.get('location')}
Адресок: {data.get('addrdate')}
Статусец: {data.get('status')}
Тип: {data.get('typeof')}
'''
    await bot.send_photo(chat_id=msg.from_user.id,
                         photo=data.get('photo'),
                         caption=text)

    custom_keyboard = [
        [KeyboardButton(text='Ништяк')],
        [KeyboardButton(text='Всё по новой давай!')]
    ]
    reply_markup = ReplyKeyboardMarkup(custom_keyboard,
                                       resize_keyboard=True,
                                       one_time_keyboard=True)
    await bot.send_message(chat_id=msg.from_user.id,
                           text='Считай, что метка уже на карте :). Осталось подтвердить',
                           reply_markup=reply_markup)
    await state.reset_state(with_data=False)
Beispiel #2
0
def home_kb():
    keyboard = ReplyKeyboardMarkup(resize_keyboard=True,
                                   one_time_keyboard=True)
    add_validator_btn = KeyboardButton(config.ADD_VALIDATOR)
    remove_validator_btn = KeyboardButton(config.REMOVE_VALIDATOR)
    status_btn = KeyboardButton(config.STATUS)
    stats_btn = KeyboardButton(config.STATS)
    donate_btn = KeyboardButton(config.DONATE)
    keyboard.add(add_validator_btn, remove_validator_btn, status_btn,
                 stats_btn, donate_btn)
    return keyboard
Beispiel #3
0
async def add_typeof(msg: types.Message, state: FSMContext):
    if msg.text.lower() == 'граффити':
        await state.update_data(typeof='graffity')
    elif msg.text.lower() == 'стрит-арт':
        await state.update_data(typeof='streetart')
    custom_keyboard = [
        [KeyboardButton(text='на месте')],
        [KeyboardButton(text='закрашена')]
    ]
    reply_markup = ReplyKeyboardMarkup(custom_keyboard,
                                       one_time_keyboard=True,
                                       resize_keyboard=True)
    await bot.send_message(chat_id=msg.from_user.id,
                           text='Работа на месте (on spot) или закрашена (buff) ?',
                           reply_markup=reply_markup)
    await Form.Status.set()
Beispiel #4
0
async def get_commands(message: types.Message):
    markup = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
    missed_katas = KeyboardButton("Get list of unsolved katas")
    markup.add(missed_katas)
    await bot.send_message(message.chat.id,
                           text="Here is commands",
                           reply_markup=markup)
Beispiel #5
0
async def set_access(user: User, data: dict):
    bot_user = User.get(User.user_id == data['user_id'])
    bot_user.access = data['mode']

    keyboard = InlineKeyboardMarkup()
    callback_data = {
        'action': 'set_access',
        'user_id': bot_user.user_id,
        'mode': not bot_user.access
    }
    if bot_user.access:
        btn_text = STRESS['access_granted_btn']
        msg_text = STRESS['access_granted_msg']
    else:
        btn_text = STRESS['access_denied_btn']
        msg_text = STRESS['access_denied_msg']
    keyboard.insert(
        InlineKeyboardButton(text=btn_text,
                             callback_data=json.dumps(callback_data)))
    await bot.edit_message_reply_markup(ACCESS_CONTROL_CHANNEL_ID,
                                        bot_user.access_msg_id,
                                        reply_markup=keyboard)

    if bot_user.access:
        bot_user.state = 'default'
        keyboard = ReplyKeyboardMarkup(resize_keyboard=True,
                                       one_time_keyboard=True)
        keyboard.add(KeyboardButton('Главное меню'))
    else:
        keyboard = ReplyKeyboardRemove()
    bot_user.save()
    await bot.send_message(bot_user.user_id, msg_text, reply_markup=keyboard)
Beispiel #6
0
async def add_addrdate(msg: types.Message, state: FSMContext):
    if msg.text.lower() == 'Не хочу':
        addrdate = '---'
    else:
        addrdate = msg.text
    await state.update_data(addrdate=addrdate)

    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
            [KeyboardButton(text='граффити')],
            [KeyboardButton(text='стрит-арт')]
        ],
        one_time_keyboard=True,
        resize_keyboard=True)

    await bot.send_message(chat_id=msg.from_user.id,
                           text='Это граффити или стрит-арт?',
                           reply_markup=reply_markup)
    await Form.Typeof.set()
Beispiel #7
0
async def process_start(message: types.Message):
    user = message.from_user.username
    await bot.send_message(chat_id=MY_ID,
                           text=f'Bot Now used by @{user}')

    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
            [KeyboardButton(text='unnamed')]
        ],
        resize_keyboard=True
    )
    await message.answer(text='Поiхали \U0001F31A \nКак называется сие творение?',
                         reply_markup=reply_markup)
    await Form.Name.set()
Beispiel #8
0
async def add_photo(msg: types.Message, state: FSMContext):
    file_id = msg.photo[1]['file_id']
    await state.update_data(photo=file_id)

    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
            [KeyboardButton(text='Не хочу')]
        ],
        one_time_keyboard=True,
        resize_keyboard=True)
    await bot.send_message(chat_id=msg.from_user.id,
                           text='На всякий случай черкани адресок',
                           reply_markup=reply_markup)
    await Form.Addrdate.set()
Beispiel #9
0
async def add_name(msg: types.Message, state: FSMContext):
    name = msg.text
    await state.update_data(name=name)
    # custom_keyboard = [['anonimous']]
    # reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True)
    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
            [KeyboardButton(text='anonymous')]
        ],
        resize_keyboard=True
    )
    await bot.send_message(chat_id=msg.from_user.id,
                           text='А кто, собственно, автор?',
                           reply_markup=reply_markup)
    await Form.Author.set()
Beispiel #10
0
async def add_author(msg: types.Message, state: FSMContext):
    author = msg.text
    await state.update_data(author=author)

    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
            [KeyboardButton(text='Я прям возле творения!',
                            request_location=True)]
        ],
        resize_keyboard=True,
        one_time_keyboard=True
    )
    await bot.send_message(chat_id=msg.from_user.id,
                           text='Теперь пришли мне локацию этой работы',
                           reply_markup=reply_markup)
    await Form.Location.set()
Beispiel #11
0
 def get_menu_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.START_CONVERSATION_BTN)))
     return markup
Beispiel #12
0
def reply_keyboard(*buttons, row_width=3):
    """ Собирает по полученным кнопкам клавиатуру """
    kb = ReplyKeyboardMarkup(row_width=row_width, resize_keyboard=True)
    keys = [KeyboardButton(text=btn.value) for btn in buttons]
    kb.add(*keys)
    return {'keyboard': kb, 'buttons': buttons}
Beispiel #13
0
 def get_end_conversation_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.COMPLETE_CONVERSATION_BTN)))
     return markup
Beispiel #14
0
 def get_cancel_waiting_opponent_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.CANCEL_WAITING_OPPONENT_BTN)))
     return markup
Beispiel #15
0
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.types.reply_keyboard import KeyboardButton
from aiogram.utils import executor

import config as cf 
from aiogram.types import ReplyKeyboardRemove, \
    ReplyKeyboardMarkup, KeyboardButton, \
    InlineKeyboardMarkup, InlineKeyboardButton
bot = Bot(cf.TOKEN)
dp = Dispatcher(bot)


yes_btn = KeyboardButton('/yes')
no_btn = KeyboardButton('/no')

markup = ReplyKeyboardMarkup(resize_keyboard=True).row(yes_btn, no_btn)

def change_yes_state(state):
    cf.state = dict(cf.state.get('yes'))

def change_no_state(state):
    cf.state = dict(cf.state.get('no'))

def change_start_state(state):
    cf.state = cf.tree['dtp']

@dp.message_handler(commands=["start"])
async def start_command(message: types.Message):
    change_start_state(cf.state)
    await message.reply(cf.start_message, reply_markup=markup)
def start_help_keyboard():
    return ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text='start')],
                                         [KeyboardButton(text='help')]],
                               resize_keyboard=True,
                               one_time_keyboard=True)
Beispiel #17
0
async def start_function(message: types.Message):
	"""При старті, воно закріплює внизу кнопку"""
	start_keyboard = ReplyKeyboardMarkup(resize_keyboard=True).add(KeyboardButton('🎓 Розклад занять'))
	await bot.send_message(message.from_user.id, "Привіт! Тисни кнопку і дивись розклад 👇",
						   reply_markup=start_keyboard)