The buttons do not work in the bot, although the libraries are installed and the types are imported. After adding Inline and reply buttons, it began to crash.
Here is the code:
import telebot
from telebot import types
import logging
import requests
bot = telebot.TeleBot('ТОКЕН')
keyboard1 = telebot.types.(resize_keyboard = True)
keyboard1.add('Заказать', 'Доставка', 'Скидки и акции', 'Отзыв', 'Support', 'Подарок', 'Мы в Instagram')
#Start
@bot.message_handler(commands=['start'])
def send_welcome(message):
name = message.from_user.first_name
print(name)
bot.reply_to(message, 'Привет,' + name + '!', parse_mode= "Markdown")
#Помощь
@bot.message_handler(commands=['help'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
#Заказать
@bot.message_handler(commands=['zakaz'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
#Инстаграм
@bot.message_handler(commands=['Instagram'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text == 'Заказать':
bot.send_message(message.chat.id, 'Привет, мой создатель')
elif message.text == 'Доставка':
bot.send_message(message.chat.id, 'Прощай, создатель')
@bot.message_handler(commands = ['get_info'])
def get_user_info(message):
markup_inline = types.InlineKeyboardMarkup()
item_yes = types.InlineKeyboardButton(text = 'ДА', callback_data = 'yes')
item_no = types.InlineKeyboardButton(text = 'НЕТ', callback_data= 'no')
markup_inline.add(item_yes, item_no)
bot.send_message(message.chat.id, 'Проверьте правильно ли указана информация?'
reply_markup = markup_inline
)
@bot.callback_query_handler(func = lambda call: True)
def answer(call):
if call.data == 'yes':
markup_reply = types.ReplyKeyboardMarkup(resize_keyboard = True)
item_zakaz = types.KeyboardButton('Заказать')
item_otzuv = types.KeyboardButton ('Отзыв')
markup_reply.add(item_zakaz, item_otzuv)
bot.send_message(call.message.chat.id, 'Выберите что хотите сделать'
reply_markup = markup_reply
)
elif call.data == 'no'
pass
@bot.message_handler(content_types = ['text'])
def get_text(message):
if message.text == 'Заказать':
bot.send_message(message.chat.id, f'Хорошо:'message.from_user.first_name)
elif message.text == 'Заказать':
bot.send_message(message.chat.id, f'Найс:'message.from_user.last_name)
bot.polling(none_stop= True)
import telebot
from telebot import types
import logging
import requests
bot = telebot.TeleBot('TOKEN')
keyboard1 = telebot.types.(resize_keyboard = True)
keyboard1.add('Заказать', 'Доставка', 'Скидки и акции', 'Отзыв', 'Support', 'Подарок', 'Мы в Instagram')
#Start
@bot.message_handler(commands=['start'])
def send_welcome(message):
name = message.from_user.first_name
print(name)
bot.reply_to(message, 'Привет,' + name + '!', parse_mode= "Markdown")
#Помощь
@bot.message_handler(commands=['help'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
#Заказать
@bot.message_handler(commands=['zakaz'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
#Инстаграм
@bot.message_handler(commands=['Instagram'])
def start_message(message):
bot.send_message(message.chat.id, 'написать')
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text == 'Заказать':
bot.send_message(message.chat.id, 'Привет, мой создатель')
elif message.text == 'Доставка':
bot.send_message(message.chat.id, 'Прощай, создатель')
@bot.message_handler(commands = ['get_info'])
def get_user_info(message):
markup_inline = types.InlineKeyboardMarkup()
item_yes = types.InlineKeyboardButton(text = 'ДА', callback_data = 'yes')
item_no = types.InlineKeyboardButton(text = 'НЕТ', callback_data= 'no')
markup_inline.add(item_yes, item_no)
bot.send_message(message.chat.id, 'Проверьте правильно ли указана информация?'
reply_markup = markup_inline
)
@bot.callback_query_handler(func = lambda call: True)
def answer(call):
if call.data == 'yes':
markup_reply = types.ReplyKeyboardMarkup(resize_keyboard = True)
item_zakaz = types.KeyboardButton('Заказать')
item_otzuv = types.KeyboardButton ('Отзыв')
markup_reply.add(item_zakaz, item_otzuv)
bot.send_message(call.message.chat.id, 'Выберите что хотите сделать'
reply_markup = markup_reply
)
elif call.data == 'no'
pass
@bot.message_handler(content_types = ['text'])
def get_text(message):
if message.text == 'Заказать':
bot.send_message(message.chat.id, f'Хорошо:'message.from_user.first_name)
elif message.text == 'Заказать':
bot.send_message(message.chat.id, f'Найс:'message.from_user.last_name)
bot.polling(none_stop= True)
What I have tried:
The buttons do not work in the bot, although the libraries are installed and the types are imported. After adding Inline and reply buttons, it began to crash.