Exemplo n.º 1
0
def cancel_all():
    if group:
        session.delete(group)
    db_connector.put_user_operation(session, user)
    bot.send_message(message.chat.id,
                     'Создание группы отменено',
                     reply_markup=standard.standard_keyboard())
Exemplo n.º 2
0
def show_quest_list():
    """Отображение списка квестов.

    @Написано, тестируется
    В   additional_info['buttons-quest_id'] пишет текст кнопки - id квеста"""
    global status, additional_info
    quest_list = db_connector.get_quest_list()
    if not quest_list:
        bot.send_message(message.chat.id,
                         'Нет квестов',
                         reply_markup=standard.standard_keyboard(
                             message.from_user.id))
        return
    text = 'Список доступных квестов:\n'
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True,
                                       one_time_keyboard=True)
    additional_info['buttons-quest_id'] = {}
    for i in range(len(quest_list)):
        #структура id, Name, description
        text += '{}) <b>{}</b>: {}\n'.format(i + 1, quest_list[i][1],
                                             quest_list[i][2])
        markup.row('{}) {}'.format(i + 1, quest_list[i][1]))
        additional_info['buttons-quest_id']['{}) {}'.format(
            i + 1, quest_list[i][1])] = quest_list[i][0]
    text += '\nВыберите свой квеcт кнопкой ниже.'
    bot.send_message(message.chat.id,
                     text,
                     parse_mode='HTML',
                     reply_markup=markup)
    status = 'neead_quest_choice'
    put_operations()
Exemplo n.º 3
0
def finish_quest():
    global status, additional_info
    db_connector.put_user_operation(message.from_user.id)
    bot.send_message(message.chat.id,
                     "Вы победили! Поздравляю!",
                     reply_markup=standard.standard_keyboard(
                         message.from_user.id))
Exemplo n.º 4
0
def finish():
    quest_id = additional_info.get('quest_id')
    db_connector.activate_quest(quest_id)
    db_connector.put_user_operation(message.from_user.id)
    bot.send_message(message.chat.id,
                     "Квест добавлен. Спасибо.",
                     reply_markup=standard.standard_keyboard(
                         message.from_user.id))
Exemplo n.º 5
0
def finish():
    msg = '''Ваша группа "{}" создана. Пароль группы: {}\n Дата распределения: {}. Приглашайте участников.
    Обратите внимание! Вы сами пока не считаетесь участником своей группы. Для участия Вам надо выбрать группу и зарегистрироваться в ней.'''.format(
        group.name, group.password, group.date_shuffle.strftime('%d.%m.%Y'))
    group.active = True
    db_connector.put_user_operation(session, user)
    bot.send_message(message.chat.id,
                     msg,
                     reply_markup=standard.standard_keyboard())
Exemplo n.º 6
0
def not_found(message):
    """Обработка всего, что не попало под остальные обработчики.

    В идеале сюда ничего не должно попадать.
    Предполагается изменение.
    Можно использовать как шаблон.
    """
    bot.send_message(message.chat.id,
                     'Рад с тобой пообщаться.',
                     reply_markup=standard.standard_keyboard())
Exemplo n.º 7
0
def msg(message):
    """Обработка всего, что не попало под остальные обработчики.

    В идеале сюда ничего не должно попадать.
    Предполагается изменение.
    Можно использовать как шаблон.
    """
    db_connector.save_to_log(
        'user', message)  #Сохранение входящего сообщения в БД. Для статистики.
    bot.send_message(message.chat.id,
                     'Рад с тобой пообщаться.',
                     reply_markup=standard.standard_keyboard(
                         message.from_user.id))
Exemplo n.º 8
0
def finish():
    member = session.query(Member).filter(Member.group == group, Member.user == user).first()
    if member:
        msg = '''Ваше участие в группе {} зарегистрировано. Дата распределения: {}
Подарок будет выслан получателю "{}" по адресу {} {}.
Ваши пожелания к подарку: {}'''.format(group.name, group.date_shuffle.strftime('%d.%m.%Y'),
                                      user.fio, user.index, user.address,
                                      member.suggestions)
    else:
        msg = 'Что-то пошло не так. Попробуйте ещё раз'
    db_connector.put_user_operation(session, user)
    bot.send_message(message.chat.id,
                     msg, reply_markup=standard.standard_keyboard())
Exemplo n.º 9
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')
Exemplo n.º 10
0
def cancel_adding():
    db_connector.put_user_operation(message.from_user.id)
    bot.send_message(message.chat.id,
                     "Ввод квеста отменён",
                     reply_markup=standard.standard_keyboard(
                         message.from_user.id))
Exemplo n.º 11
0
def finish_reg():
    user.registrationDone = 1
    user.registrationDate = datetime.datetime.now()
    db_connector.put_user_operation(session, user)
    bot.send_message(message.chat.id,
                     'Регистрация завершена. Теперь введите название группы, в которой вы участвуете, или создайте свою.', reply_markup = standard.standard_keyboard())
Exemplo n.º 12
0
def finish_reg(bot, message):
    db_connector.register_user(message.from_user.id, registrationDone=1)
    db_connector.put_user_operation(message.from_user.id)
    bot.send_message(message.chat.id, 'Регистрация завершена', reply_markup=standard.standard_keyboard(message.from_user.id))
Exemplo n.º 13
0
def cancel_all():
    db_connector.put_user_operation(session, user)
    bot.send_message(message.chat.id,
                     'Отменено', reply_markup=standard.standard_keyboard())