Z
Z
Zamon2020-04-18 00:51:23
Telegram
Zamon, 2020-04-18 00:51:23

Can't send message after getting contact in telebot. Where is the mistake?

import telebot
from telebot import types

username = []


API_TOKEN = '1154777357:AAEDqyy1BQXUWuE#CTszbdU'


bot = telebot.TeleBot(API_TOKEN)

keyboard1 = types.ReplyKeyboardMarkup(True, True)
button_phone = types.KeyboardButton(text="Авторизоваться", request_contact=True)
keyboard1.add(button_phone)
keyboard = telebot.types.InlineKeyboardMarkup()
callback_button = telebot.types.InlineKeyboardButton(text="Принять", callback_data="accept")
keyboard.add(callback_button)
keyboard2 = telebot.types.InlineKeyboardMarkup()
callback1_button = telebot.types.InlineKeyboardButton(text="Да", callback_data="yes")
callback2_button = telebot.types.InlineKeyboardButton(text="Нет", callback_data="no")
keyboard2.add(callback1_button, callback2_button)



@bot.message_handler(commands=['start'])
def send_welcome(message):
    bot.send_message(chat_id=message.chat.id, text='Здравствуйте, вас приветствует VIP Bot. Пользовательское соглашение.', reply_markup=keyboard)
    print(message)
    @bot.callback_query_handler(func=lambda call: True)
    @bot.message_handler(commands=['number'])
    def callback_data(call):
        if call.data == "accept":
             bot.send_message(chat_id=call.message.chat.id, text='Запрос номера',reply_markup=keyboard1)


@bot.message_handler(content_types=['contact'])
def contact(message):
    if message.contact is not None:
        print(message.contact)
        @bot.message_handler(func=lambda message: True, content_types=['text'])
        def send_text(message):
            bot.send_message(chat_id=call.message.chat.id, text='Ответьте на несколько вопросов!')
            @bot.message_handler(func=lambda message: True, content_types=['text'])
            def username(message):
                global username
                username.append(message.text)
                bot.send_message(chat_id=call.message.chat.id, text='Вопрос 1', reply_markup=keyboard2)
                @bot.message_handler(func=lambda message: True, content_types=['text'])
                def username(message):
                    global username
                    username.append(message.text)
                    bot.send_message(chat_id=call.message.chat.id, text='Вопрос 2', reply_markup=keyboard2)

bot.polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question