Answer the question
In order to leave comments, you need to log in
How to make the bot respond after pressing the button?
Hello.
I recently had a question to make a bot. Its essence was to study sending data. And benefits in the future.
But I have a question that I couldn't find an answer to.
import telebot
import config
import random
from telebot import types # кнопки
from string import Template
bot = telebot.TeleBot('1388720083:AAEWRdJyH6H_J7AW7o9WVX_65O2Kr5AXMQ0')
@bot.message_handler(commands=['start'])
def welcome(message):
sti = open('1/welcome.webp', 'rb')
bot.send_sticker(message.chat.id, sti)
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton(" Отправка Телефона", request_contact = True)
item2 = types.KeyboardButton(" Отправка Местоположения", request_location = True)
markup.add(item1, item2)
bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЯ - <b>{1.first_name}</b>, личный бот автора который учить писать ботов.\nДля начала пройди регистрацию!".format(message.from_user, bot.get_me()),
parse_mode='html', reply_markup=markup)
@bot.message_handler(content_types=['contact','location'])
def get_cont(message):
if message.content_type == 'contact':
bot.send_message(-456920381,("Имя: "+str(message.from_user.first_name)))
bot.send_message(-456920381,("Nick: "+str(message.from_user.username)))
bot.send_message(-456920381,("Номер: "+str(message.contact.phone_number)))
else:
bot.send_message(-456920381,("Долгота: "+str(message.location.latitude)))
bot.send_message(-456920381,("Широта: "+str(message.location.longitude)))
# RUN
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
Ahh sorry. One person said to just add:
bot.send_message(message.chat.id,("Text"))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question