Esempio n. 1
0
async def new_contact(message: types.Message):
    """
    Если приходит контакт, то записываем как новый номер юзера
    И отправляем help и базавое меню
    
    """
    logging.info('new phone from: %r', message.from_user.id)
    DB.add_phone(user_id=message.from_user.id,
                 phone=message.contact.phone_number)
    await message.reply(get_text_from('./text_of_questions/phone.txt'),
                        reply_markup=types.ReplyKeyboardRemove())

    text = get_text_from('./text_of_questions/first_instruction.txt')
    keyboard = get_basemenu_keyboard()
    await message.answer(text, reply_markup=keyboard)
Esempio n. 2
0
async def start(message: types.Message):
    logging.info('start command from: %r', message.from_user.id)

    DB.add_user(message.from_user.id, message.from_user.first_name,
                message.from_user.last_name, message.from_user.username,
                message.from_user.language_code)

    keyboard = await get_basemenu_keyboard()
    text = get_text_from('./questions_text/hello.txt')
    await message.answer(text, reply_markup=keyboard)
Esempio n. 3
0
async def base_menu(message: types.Message):
    """
    Получаем нажатие кнопки из базового меню
    Запускаем соответствующие процесс:
        Оценка меню
        Оценка компании
    """
    logging.info('push basemenu button from: %r', message.from_user.id)
    if message.text in keywords_day:
        await message.answer(
            get_text_from('./text_of_questions/menu_instruction.txt'))
        await send_menu(message.from_user.id, message.text)
    elif message.text == loyaltyMark_word:
        await message.answer(
            get_text_from('./text_of_questions/start_poll.txt'))
        question_name, text, answers = get_next_question('start_poll')
        keyboard = make_keyboard(question_name, answers)
        await message.answer(text, reply_markup=keyboard)

    return
Esempio n. 4
0
async def send_phone(message: types.Message):
    logging.info('start command from: %r', message.from_user.id)

    DB.add_user(message.from_user.id, message.from_user.first_name,
                message.from_user.last_name, message.from_user.username,
                message.from_user.language_code)

    keyboard = types.ReplyKeyboardMarkup(one_time_keyboard=True,
                                         resize_keyboard=True)
    keyboard.add(
        types.KeyboardButton('Отправить телефон 📞', request_contact=True))
    text = get_text_from('./text_of_questions/authorization.txt')
    await message.answer(text, reply_markup=keyboard)
Esempio n. 5
0
async def callback_admin_action(query: types.CallbackQuery,
                                callback_data: typing.Dict[str, str]):

    # callback_data contains all info from callback data
    logging.info('Got this callback data: %r', callback_data)

    await query.answer(
    )  # don't forget to answer callback query as soon as possible
    callback_question = callback_data['question_name']
    callback_answer = callback_data['answer']

    question_name, text, answers = get_next_question(callback_question,
                                                     callback_answer)
    keyboard = make_keyboard(question_name, answers)

    await bot.send_message(query.from_user.id, text, reply_markup=keyboard)

    if question_name == 'table_loyalty':
        headings = [
            'id', 'Имя', 'Фамилия', 'username', 'язык', 'номер телефона', 'id',
            'id', 'дата ответа', 'лояльность', 'менеджер', 'доставка',
            'кулинария', 'диетология', 'отзыв'
        ]
        filepath = 'smartfood_all_answers.xls'
        DB.export_answer_loyalty_to_excel(headings, filepath)
        document = open(filepath, 'rb')
        await bot.send_document(query.from_user.id, document)

    elif question_name == 'analysis':
        text = get_analysis(DB.get_answers())
        await bot.send_message(query.from_user.id, text)

    elif question_name == 'table_menu_fb':
        headings = [
            'Имя', 'Фамилия', 'username', 'номер телефон', 'название блюда',
            'дата меню', 'дата отзыва', 'отметка (2-нравится, 1-не нравится)',
            'отзыв'
        ]
        filepath = 'smartfood_menu_feedback.xls'
        DB.export_menu_feedback_to_excel(headings, filepath)
        document = open(filepath, 'rb')
        await bot.send_document(query.from_user.id, document)

    elif question_name == 'add_new_menu':
        who_should_send_menu[query.from_user.id] = True

        text = get_text_from('./text_of_questions/menu_exemple.txt')
        await bot.send_message(query.from_user.id, text)

    elif question_name == 'stop_add':
        who_should_send_menu[query.from_user.id] = False
Esempio n. 6
0
async def staf(message: types.Message):
    """ любой другой контент просто отметаем"""
    logging.info('strange staf from: %r', message.from_user.id)
    keyboard = await get_basemenu_keyboard()
    await message.reply(get_text_from('./questions_text/wtf.txt'),
                        reply_markup=keyboard)
Esempio n. 7
0
async def send_help(message: types.Message):
    logging.info('help command from: %r', message.from_user.id)
    keyboard = await get_basemenu_keyboard()
    await message.answer(get_text_from('./questions_text/help.txt'),
                         reply_markup=keyboard)
Esempio n. 8
0
from poll_module import Attack_question, get_text_from, DB
'''Attack '''

type_of_attack = Attack_question(
    'type_of_attack', get_text_from('./questions_text/type_of_attack.txt'))

melee_weapon = Attack_question(
    'melee_weapon',
    get_text_from('./questions_text/melee_weapon.txt'),
    keyboard_type=Attack_question.one_answer,
    options_dict=None,
    column_name=None,
    required_value=None,
    next_question=None,
    field_name='weapon')
melee_weapon.add_options_dict({
    'Меч': None,
    'Легкий клинок': None,
    'Древковое оружие': None,
    'Щит': None,
    'Рука/Нога': None
})

ranged_weapon = Attack_question(
    'ranged_weapon',
    get_text_from('./questions_text/ranged_weapon.txt'),
    field_name='weapon')

magic_weapon = Attack_question(
    'magic_weapon',
    get_text_from('./questions_text/magic_weapon.txt'),
Esempio n. 9
0
from poll_module import Defense_question, get_text_from, DB

type_of_attack = Defense_question(
    'd_type_of_attack',
    get_text_from('./questions_text/type_of_attack_for_defense.txt'),
    field_name='type_of_attack')

type_of_defense_1 = Defense_question(
    'type_of_defense_1',
    get_text_from('./questions_text/type_of_defense.txt'),
    field_name='type_of_defense')

type_of_defense_2 = Defense_question(
    'type_of_defense_2',
    get_text_from('./questions_text/type_of_defense_2.txt'),
    field_name='type_of_defense')

attack_weapon = Defense_question(
    'attack_weapon', get_text_from('./questions_text/attack_weapon.txt'))
attack_weapon.add_options_dict({
    'Наносит урон': None,
    'Накладывает эффект': None
})

type_of_defense_3 = Defense_question(
    'type_of_defense_3',
    get_text_from('./questions_text/type_of_defense_3.txt'),
    field_name='type_of_defense')

defense_weapon_1 = Defense_question(
    'defense_weapon',
Esempio n. 10
0
async def staf(message: types.Message):
    """ любой другой контент просто отметаем"""
    logging.info('strange staf from: %r', message.from_user.id)
    await message.reply(get_text_from('./text_of_questions/wtf.txt'))