Answer the question
In order to leave comments, you need to log in
Trouble with a Python bot?
import telebot #библиотеки
from telebot import types
d='@dusenkot'#Подставить сюда свой ник
bot=telebot.TeleBot('') #токен
@bot.message_handler(commands=['start'])#1блок
def welcome(message):
#keyboard
markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
item1=types.KeyboardButton('Тернополь')
item2=types.KeyboardButton('Киев')
item3=types.KeyboardButton('Харьков')
item4=types.KeyboardButton('Ивано-Франковск')
item5=types.KeyboardButton('Ужгород')
markup.add(item1,item2,item3,item4,item5)
bot.send_message(message.chat.id,'Тебя приветсвует магазин"UaStaff",Выбери свой город ниже ',reply_markup=markup)
#конец keyboard
#Сорти
markup1=types.ReplyKeyboardMarkup(resize_keyboard=True)
item6=types.KeyboardButton('rr3')#200
item7=types.KeyboardButton('rr2')#220
item8=types.KeyboardButton('rr1')#210
markup1.add(item6,item7,item8)
#ціна
markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
item10=types.KeyboardButton('213')
item11=types.KeyboardButton('123')
item12=types.KeyboardButton('123')
@bot.message_handler(content_types=['text'])#2блок
def pizda(message):
if message.text=='Ужгород':
bot.send_message(message.chat.id,'')
if message.text=='Ивано-Франковск':
bot.send_message(message.chat.id,'')
def zina(message):
if message.text=='rr3':
bot.send_message(message.chat.id,'')
if message.text=='rr2':
bot.send_message(message.chat.id,'')
if message.text=='rr1':
bot.send_message(message.chat.id,'')
bot.send_message(message.chat.id,'',reply_markup=markup1)
if message.text=='Тернополь':
bot.send_message(message.chat.id,'')
if message.text=='Киев':
bot.send_message(message.chat.id,'')
if message.text=='Харьков':
bot.send_message(message.chat.id,'')
bot.polling(none_stop=True)#run
Запускаеться всё нормально но при выбирании города краш
<code\>
Answer the question
In order to leave comments, you need to log in
import telebot # библиотеки
from telebot import types
d = '@dusenkot' # Подставить сюда свой ник
bot = telebot.TeleBot('') # токен
@bot.message_handler(commands=['start']) # 1блок
def welcome(message):
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Тернополь')
item2 = types.KeyboardButton('Киев')
item3 = types.KeyboardButton('Харьков')
item4 = types.KeyboardButton('Ивано-Франковск')
item5 = types.KeyboardButton('Ужгород')
markup.add(item1, item2, item3, item4, item5)
bot.send_message(message.chat.id, 'Тебя приветсвует магазин"UaStaff",Выбери свой город ниже ', reply_markup=markup)
# конец keyboard
# Сорти
# ціна
@bot.message_handler(content_types=['text']) # 2блок
def pizda(message):
if message.text == 'Ужгород':
bot.send_message(message.chat.id, '')
if message.text == 'Ивано-Франковск':
markup1 = types.ReplyKeyboardMarkup(resize_keyboard=True)
item6 = types.KeyboardButton('rr3') # 200
item7 = types.KeyboardButton('rr2') # 220
item8 = types.KeyboardButton('rr1') # 210
markup1.add(item6, item7, item8)
var = bot.send_message(message.chat.id, 'хорошо', reply_markup=markup1)
bot.register_next_step_handler(var, new_zina)
if message.text == 'Тернополь':
bot.send_message(message.chat.id, '')
if message.text == 'Киев':
bot.send_message(message.chat.id, '')
if message.text == 'Харьков':
bot.send_message(message.chat.id, '')
def new_zina(message):
if message.text == 'rr3':
markup2 = types.ReplyKeyboardMarkup(resize_keyboard=True)
item10 = types.KeyboardButton('213')
item11 = types.KeyboardButton('123')
item12 = types.KeyboardButton('123')
markup2.add(item10, item11, item12)
bot.send_message(message.chat.id, 'ok', reply_markup=markup2)
if message.text == 'rr2':
bot.send_message(message.chat.id, '')
if message.text == 'rr1':
bot.send_message(message.chat.id, '')
bot.polling(none_stop=True) # run
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question