示例#1
0
def main_keyboard(idx):
    cnt_meetings = db_meetings.find_one('tg_id', idx)
    if cnt_meetings is None:
        cnt_meetings = 0
    else:
        cnt_meetings = len(cnt_meetings['meetings'])
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True, selective=True)
    markup.add('Предложить собеседника')
    # markup.add(f'встречи({cnt_meetings})')
    markup.add('Посмотреть встречи')
    markup.add('Заполнить профиль')
    return markup, cnt_meetings
示例#2
0
async def button_media(message: types.Message, state: FSMContext):
    async with state.proxy() as user_data:
        select_user = user_data['select_user']
    user = db_meetings.find_one('tg_id', select_user)
    if user is None:
        db_meetings.push({
            'tg_id':
            select_user,
            'meetings': [{
                'target':
                message.from_user.id,
                'time':
                datetime.datetime.fromtimestamp(time.time() + 86400)
            }]
        })
    else:
        user['meetings'].append({
            'target':
            message.from_user.id,
            'time':
            datetime.datetime.fromtimestamp(time.time() + 86400)
        })
        db_meetings.update_one(user)
    await message.answer('Встреча записана!')