Пример #1
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)
Пример #2
0
def main_menu_btn():
    keyboard = ReplyKeyboardMarkup(resize_keyboard=True, row_width=1)
    #keyboard.add(_('Анонсы'), _('Выбор блокчейна'),
    #             _('FAQ'), _('Настройки'),
    #             _('Быстрая конвертация'),
    #             _('Мои кошельки'), _('Залистить проект')
    #             )
    keyboard.add(_('Анонсы'), _('Мои кошельки'), _('Настройки'), _('Партнеры'))
    return keyboard
Пример #3
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
Пример #4
0
async def process_simple_calendar(callback_query: CallbackQuery,
                                  callback_data: dict, state: FSMContext):
    selected, date = await SimpleCalendar().process_selection(
        callback_query, callback_data)
    if selected:
        async with state.proxy() as data:
            data['time'] = date
            db_session = callback_query.message.bot.get('db')
            async with db_session() as session:
                student = await get_student(session,
                                            callback_query.message.chat.id)
                group = student.grp
                sql = select(Lesson).where(
                    and_(Lesson.grp == group,
                         Lesson.day == datetime.datetime.weekday(date)))
                request = await session.execute(sql)
                lessons = request.scalars()
                keyboard = ReplyKeyboardMarkup()
                keyboard.insert(InlineKeyboardButton('Другое'))
                for lesson in lessons:
                    keyboard.insert(InlineKeyboardButton(str(lesson.name)))
                keyboard.insert(InlineKeyboardButton('Отмена'))
                await callback_query.message.answer("Ок. А какая пара?",
                                                    reply_markup=keyboard)
                await TaskState.task_name.set()
Пример #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)
Пример #6
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)
Пример #7
0
async def start(message: Message, state: FSMContext):

    async with state.proxy() as data:
        if 'id' not in data:
            await message.reply("Не выбран id задачи. Пришлите его в ответ")
            return
        data['path'] = '/'

    await message.reply("Введите адрес объекта", reply_markup=keyboard['/'])
    await message.reply("init", reply_markup=ReplyKeyboardMarkup([['/start'], ['Назад'], ['Не заполнено'], ['Сохранить'], ['Выход']]))
Пример #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()
Пример #9
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()
Пример #10
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()
Пример #11
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()
Пример #12
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()
Пример #13
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()
Пример #14
0
async def value_saver(message: Message, state: FSMContext):
    async with state.proxy() as data:
        if 'id' not in data:
            if message.text.isdigit():
                res = con.execute(f'SELECT * FROM jobs WHERE id = {message.text}').fetchone()
                if res:
                    data['id'] = message.text
                    if not os.path.exists(os.path.join(BASEDIR, message.text)):
                        os.mkdir(os.path.join(BASEDIR, message.text))
                        os.mkdir(os.path.join(BASEDIR, message.text, 'photo'))
                    else:
                        path = os.path.join(BASEDIR, data['id'], 'data.json')
                        if os.path.exists(path):
                            with open(path, 'r') as f:
                                ldata = json.load(f)
                                for key in ldata:
                                    data[key] = ldata[key]
                    data['path'] = '/'
                    if 'photo' not in data:
                        data['photo'] = {}
                    await message.reply(f"Выбран id задачи {message.text}")
                    await message.reply("init", reply_markup=ReplyKeyboardMarkup([['/start'], ['Назад'], ['Не заполнено'], ['Сохранить'], ['Выход']]))
                    return
                else:
                    await message.reply("Выбранного id не существует")
                    return
            else:
                await message.reply("Не выбран id задачи. Пришлите его в ответ")
                return

        for i in range(-3, 0):
            key = '/'.join(data['path'][:-1].split('/')[i:])
            if key in answer:
                put_key_json(data['path'], data, message.text)
                data['path'] = prev_path(data['path'])
                await message.reply(f'Значение сохраненно {message.text}')
                await message.reply(data['path'], reply_markup=keyboard[data['path']])
                return

    await message.reply(data['path'], reply_markup=keyboard[data['path']])
Пример #15
0
 def get_cancel_waiting_opponent_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.CANCEL_WAITING_OPPONENT_BTN)))
     return markup
Пример #16
0
def settings_btn():
    keyboard = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
    keyboard.add(_('Сменить язык'))
    return keyboard
Пример #17
0
 def get_end_conversation_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.COMPLETE_CONVERSATION_BTN)))
     return markup
Пример #18
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}
Пример #19
0
 def get_menu_keyboard(cls):
     markup = ReplyKeyboardMarkup(row_width=1)
     markup.add(KeyboardButton(str(cls.START_CONVERSATION_BTN)))
     return markup
Пример #20
0
def start_help_keyboard():
    return ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text='start')],
                                         [KeyboardButton(text='help')]],
                               resize_keyboard=True,
                               one_time_keyboard=True)
Пример #21
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)