Example #1
0
def ask_password():
    val = get_text_val(
        'Введите пароль для доступа к этой группе')
    if val:
        if group.password == val:
            return 1
        else:
            bot.send_message(message.chat.id, 'Неверный пароль', reply_markup=standard.cancel_keyboard())
            return ask_password()
    return 0
Example #2
0
def ask_name():
    val = get_text_val(
        'Введите название вашей группы участников Тайного Санты (не менее 3х символов).'
    )
    if val:
        if len(val) < 3:
            bot.send_message(
                message.chat.id,
                'Название должно состоять не менее, чем из 3х символов',
                reply_markup=standard.cancel_keyboard())
            return ask_name()
        elif session.query(Group).filter(Group.name_lower == val.lower(),
                                         Group.active == True).first():
            bot.send_message(
                message.chat.id,
                'Группа с таким названием уже существует. Придумайте новое',
                reply_markup=standard.cancel_keyboard())
            return ask_name()
        else:
            group.name = val
            group.name_lower = val.lower()
            return 1
    return 0
Example #3
0
def ask_date():
    msg = '''Введите дату окончания приёма заявок. В этот день генератор случайных чисел распределит отправителей и получателей и вышлет участникам их адресатов.
Дату необходимо воодить в формате дд.мм.гггг т.е. 15 декабря 2016 года это 15.12.2016 '''
    val = get_text_val(msg)
    if val:
        try:
            to_date = datetime.datetime.strptime(val, '%d.%m.%Y').date()
        except:
            to_date = 0
        if to_date:
            if to_date <= datetime.datetime.now().date():
                bot.send_message(
                    message.chat.id,
                    'Это было давно... Выберите число из будущего',
                    reply_markup=standard.cancel_keyboard())
                return ask_date()
            group.date_shuffle = to_date
            return 1
        else:
            bot.send_message(message.chat.id,
                             'Неверный формат даты',
                             reply_markup=standard.cancel_keyboard())
            return ask_date()
    return 0
Example #4
0
 def ask(ask_msg=''):
     user.operation.additional_info[
         key_ad_info_step] = val_ad_info_need_answer
     bot.send_message(message.chat.id,
                      ask_msg + ask_text,
                      reply_markup=standard.cancel_keyboard())
Example #5
0
 def do_select():
     if message.content_type == 'text':
         group_id = user.operation.additional_info.get(key_ad_info_buttons, dict()).get(message.text)
         group = session.query(Group).filter(Group.id == group_id).first()
         if key_ad_info_buttons in user.operation.additional_info: user.operation.additional_info.pop(key_ad_info_buttons)
         if group:
             user.operation.additional_info['group_id'] = group.id
             text = 'Выбрана группа <b>{}</b> от автора {}. Дата распределения: {}.'.format(group.name, group.owner, group.date_shuffle.strftime('%d.%m.%Y'))
             bot.send_message(message.chat.id, text, parse_mode='HTML', reply_markup=standard.cancel_keyboard())
             member = session.query(Member).filter(Member.group == group, Member.user == user).first()
             if member:
                 db_connector.put_user_operation(session, user)
                 bot.send_message(message.chat.id,
                                  'Вы уже участвуете в этой группе. Ваши пожелания: "{}"'.format(member.suggestions),
                                  reply_markup=standard.standard_keyboard())
                 return 0
             return 1
         else:
             return ask_name('Выбор нужно делать кнопкой\n')
     else:
         return ask_name('Выбор нужно делать кнопкой\n')
Example #6
0
 def ask_name(ask_msg=''):
     ask_text = 'Введите название или часть названия группы, которую вы ищете. Не менее 3х символов.'
     user.operation.additional_info[key_ad_info_step] = val_ad_info_need_name
     bot.send_message(message.chat.id, ask_msg+ask_text,
                      reply_markup=standard.cancel_keyboard())
     return 0