コード例 #1
0
def request_registration_name_handler(message: Message, **kwargs):
    chat_id = message.chat.id
    language = kwargs.get('language')

    def error():
        if message.text == '/start':
            welcome(message)
            return
        error_msg = strings.get_string('registration.request.welcome',
                                       language)
        telegram_bot.send_message(chat_id, error_msg)
        telegram_bot.register_next_step_handler_by_chat_id(
            chat_id, request_registration_name_handler, language=language)

    if not message.text:
        error()
        return
    name = message.text
    phone_number_message = strings.get_string(
        'registration.request.phone_number', language)
    phone_number_keyboard = keyboards.from_user_phone_number(language,
                                                             go_back=False)
    telegram_bot.send_message(chat_id,
                              phone_number_message,
                              parse_mode='HTML',
                              reply_markup=phone_number_keyboard)
    telegram_bot.register_next_step_handler_by_chat_id(
        chat_id,
        request_registration_phone_number_handler,
        name=name,
        language=language)
コード例 #2
0
def process_user_language(message: Message):
    chat_id = message.chat.id

    def error():
        error_msg = strings.get_string('welcome.say_me_language')
        telegram_bot.send_message(chat_id, error_msg)
        telegram_bot.register_next_step_handler_by_chat_id(
            chat_id, process_user_language)

    if not message.text:
        error()
        return
    if message.text.startswith('/'):
        error()
        return
    if strings.get_string('language.russian') in message.text:
        language = 'ru'
    elif strings.get_string('language.uzbek') in message.text:
        language = 'uz'
    else:
        error()
        return
    next_message = strings.get_string('welcome.phone_number', language)
    phone_keyboard = keyboards.from_user_phone_number(language)
    telegram_bot.send_message(chat_id,
                              next_message,
                              reply_markup=phone_keyboard,
                              parse_mode='HTML')
    telegram_bot.register_next_step_handler_by_chat_id(chat_id,
                                                       process_phone_number,
                                                       language=language)
コード例 #3
0
ファイル: orders.py プロジェクト: maxwell882000/CosmeticBot
def _to_the_phone_number(chat_id, language, user):
    phone_number_message = strings.get_string('order.phone_number', language)
    phone_number_keyboard = keyboards.from_user_phone_number(
        language, user.phone_number)
    bot.send_message(chat_id,
                     phone_number_message,
                     reply_markup=phone_number_keyboard,
                     parse_mode='HTML')
    bot.register_next_step_handler_by_chat_id(chat_id, phone_number_processor)