コード例 #1
0
ファイル: commands.py プロジェクト: eleangelo0717/jackal-game
def edit(bot, update):
    u = user.User(update.message.from_user)
    u.step = update.message.text[6:]
    request, _ = declaration.checkDeclaration(u)
    _, item = declaration.getRequestItem(u.step, request)
    if item is None:
        return
    u = db.saveDeclaration(update.message.from_user, request, u.step)
    step_request(bot, update, user, request, u['step'])
コード例 #2
0
ファイル: commands.py プロジェクト: eleangelo0717/jackal-game
def step_request(bot, update, user, request, step):
    if step == '':
        user = db.saveDeclaration(update.message.from_user, request, step,
                                  'ready')
        status(bot, update)
    else:
        user = db.saveDeclaration(update.message.from_user, request, step)
        field = declaration.getField(step)
        field_name = field_display(field)
        if field.get('required', False):
            field_name = field_name + ' *'
        values = field.get('values')
        txt = []

        if values is None:
            txt.append(f'Введите "{field_name}"')
        else:
            txt.append(f'Введите код для "{field_name}":')
            if field.get('multiple', False):
                txt.append(f'Можно ввести несколько значений через запятую.')
            for val in values:
                txt.append(f'{val.get("key")} - {val.get("text")}')
        text = '\n'.join(txt)
        update.message.reply_text(text)
コード例 #3
0
ファイル: commands.py プロジェクト: eleangelo0717/jackal-game
def text_input(bot, update):
    user = db.saveUser(update.message.from_user)
    request, step = declaration.checkDeclaration(user)
    text = update.message.text.strip()
    if text == '-':
        text = ""
    if step is not None:
        if step in [key for key in declaration.docFields]:
            field = declaration.docFields.get(step) or {}
            if text == '' and field.get('required', False):
                update.message.reply_text(
                    f'''Поле обязательно для заполнения.''')
            else:
                if field.get('multiple', False):
                    request['doc'][step] = re.split(r'\W+', text)
                else:
                    request['doc'][step] = text
                update.message.reply_text(
                    f'''_Сохранено "{step}": {request['doc'][step]}_''',
                    parse_mode='Markdown')
        else:
            dt = request['dt']

            text, result = utils.checkDate(text)
            if result is not None:
                update.message.reply_text(result)
                next_step(bot, update, user)
                return

            if step.get('key') == 'date_from':
                dt['from'] = text
            if step.get('key') == 'date_to':
                dt['to'] = text
            request['dt'] = dt
        _, step = declaration.checkDeclaration(user)
        user = db.saveDeclaration(update.message.from_user, request, step)
        next_step(bot, update, user)
コード例 #4
0
ファイル: commands.py プロジェクト: eleangelo0717/jackal-game
def clear(bot, update):
    _ = user.User(update.message.from_user)
    db.saveDeclaration(update.message.from_user, {}, None, '')
    update.message.reply_text(f'''Ваша заявка удалена.
Заполнить новую заявку: /declaration''')
コード例 #5
0
ファイル: commands.py プロジェクト: eleangelo0717/jackal-game
def stop(bot, update):
    _ = user.User(update.message.from_user)
    db.saveDeclaration(update.message.from_user, {}, None, 'stop')
    update.message.reply_text(f'Ваши данные удалены')