@Stockho1m

Как сделать так, чтобы после нажатия 2-ой по счету кнопки бот выдавал сообщение?

Проблема в 82 строчке, я Python вообще не изучал, пишу бота лично для себя.
В чем суть: Даже не знаю, как сформулировать. после команды старт высвечиваются кнопки(сейчас мы работаем только с первой из них, тк прописал последующие шаги только для нее),после нажатия на нее высчечиваются еще кнопки и вот тут уже и происходит проблема. После нажатия на кнопку "Any", бот не отправляет сообщение, хотя должен. Подскажите, пожалуйста

import telebot
from telebot import types
bot=telebot.TeleBot('6942015306:AAGKjOO6CyEeaSoCzhN6hYejinwhK9dz2HE')

@bot.message_handler(commands=['start'])
def start_message(message):
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width = 3)
    DHW13 = types.KeyboardButton("DreamHack Winter 2013 \U0001F1F8\U0001F1EA")
    Katowice14 = types.KeyboardButton("EMS One Katowice 2014 \U0001F1F5\U0001F1F1")
    Cologne14 = types.KeyboardButton("ESL One Cologne 2014 \U0001F1E9\U0001F1EA")
    DHW14 = types.KeyboardButton("DreamHack Winter 2014 \U0001F1F8\U0001F1EA")
    Katowice15 = types.KeyboardButton("ESL One Katowice 2015 \U0001F1F5\U0001F1F1")
    Cologne15 = types.KeyboardButton("ESL One Cologne 2015 \U0001F1E9\U0001F1EA")
    ClujNapoca15 = types.KeyboardButton("DreamHack Cluj-Napoca 2015 \U0001F1F7\U0001F1F4")
    Columbus16 = types.KeyboardButton("MLG Columbus 2016 \U0001F1FA\U0001F1F8")
    Cologne16 = types.KeyboardButton("ESL One: Cologne 2016 \U0001F1E9\U0001F1EA")
    Atlanta17 = types.KeyboardButton("ELEAGUE Atlanta 2017 \U0001F1FA\U0001F1F8")
    Krakow17 =  types.KeyboardButton("PGL Major Krakow 2017 \U0001F1F5\U0001F1F1")
    Boston18 = types.KeyboardButton("ELEAGUE Boston 2018 \U0001F1F5\U0001F1F1")
    London18 = types.KeyboardButton("FACEIT Major: London 2018 \U0001F1EC\U0001F1E7")
    Katowice19 = types.KeyboardButton("IEM Katowice 2019 \U0001F1F5\U0001F1F1")
    Berlin19 = types.KeyboardButton("StarLadder Berlin Major 2019 \U0001F1E9\U0001F1EA")
    RMR20 = types.KeyboardButton("RMR 2020 \U0001F1EA\U0001F1FA")
    Stockholm21 = types.KeyboardButton("PGL Major Stockholm 2021 \U0001F1F8\U0001F1EA")
    Antwerp22 = types.KeyboardButton("PGL Antwerp 2022 \U0001F1F3\U0001F1F1")
    Rio22 = types.KeyboardButton("IEM Rio Major 2022 \U0001F1E7\U0001F1F7")
    Paris23 = types.KeyboardButton("Blast Paris Major 2023 \U0001F1EB\U0001F1F7")
    menu = types.KeyboardButton("Menu")

    markup.add(DHW13, Katowice14, Cologne14, DHW14, Katowice15, Cologne15, ClujNapoca15, Columbus16, Cologne16, Atlanta17, Krakow17, Boston18, London18, Katowice19, Berlin19, RMR20,
               Stockholm21, Antwerp22, Rio22, Paris23, menu)
    bot.send_message(message.chat.id, "Пожалуйста, выберите интересующий Вас турнир", reply_markup = markup )

@bot.message_handler(content_types=['text'])
def second (message):
    if (message.text == "DreamHack Winter 2013 \U0001F1F8\U0001F1EA"):
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width = 3)
        AK47 = types.KeyboardButton("AK-47")
        AWP = types.KeyboardButton("AWP")
        Deagle = types.KeyboardButton("Desert Eagle")
        M4A4 = types.KeyboardButton("M4A4")
        M4A1S = types.KeyboardButton("M4A1-S")
        USP = types.KeyboardButton("USP-S")
        Glock = types.KeyboardButton("Glock-18")
        Famas = types.KeyboardButton("Famas")
        Galil = types.KeyboardButton("Galil AR")
        AUG = types.KeyboardButton("AUG")
        SG553 = types.KeyboardButton("SG 553")
        SSG08 = types.KeyboardButton("SGG 08")
        P250 = types.KeyboardButton("P250")
        CZ75 = types.KeyboardButton("CZ75-Auto")
        Tec = types.KeyboardButton("TEC-9")
        R8 = types.KeyboardButton("R8 Revolver")
        FS = types.KeyboardButton("Five-SeveN")
        Berettas = types.KeyboardButton("Dual Berettas")
        P2000 = types.KeyboardButton("P2000")
        MP9 = types.KeyboardButton("MP9")
        MAC10 = types.KeyboardButton("MAC-10")
        MP7 = types.KeyboardButton("MP7")
        P90 = types.KeyboardButton("P90")
        UMP = types.KeyboardButton("UMP-45")
        MP5 = types.KeyboardButton("MP5-SD")
        Bizon = types.KeyboardButton("PP-Bizon")
        MAG = types.KeyboardButton("MAG-7")
        XM = types.KeyboardButton("XM1014")
        Nova = types.KeyboardButton("Nova")
        SawedOff = types.KeyboardButton("Sawed-Off")
        Negev = types.KeyboardButton("Negev")
        M249 = types.KeyboardButton("M249")
        SCAR = types.KeyboardButton("SCAR-20")
        G3SG1 = types.KeyboardButton("G3SG1")
        any = types.KeyboardButton("Any")
        back = types.KeyboardButton("Back")
        menu = types.KeyboardButton("Menu")
        markup.add(AK47, AWP, Deagle, M4A4, M4A1S, USP, Glock, Famas, Galil, AUG, SG553, SSG08, P250, CZ75, Tec, R8, FS,
                   Berettas, P2000, MP9, MAC10, MP7, P90, UMP, MP5, Bizon, MAG, XM, Nova, SawedOff, Negev, M249, SCAR, G3SG1, any, back, menu)
        bot.send_message(message.chat.id, "Пожалуйста, выберите интересующее Вас оружие", reply_markup = markup)
        
            if (message.text == "Any"):
                bot.send_message(message.chat.id, "https://steamcommunity.com/market/search?descriptions=1&category_730_ItemSet%5B%5D=any&category_730_ProPlayer%5B%5D=any&category_730_StickerCapsule%5B%5D=any&category_730_TournamentTeam%5B%5D=any&category_730_Weapon%5B%5D=any&appid=730&q=%22DreamHack+Winter%22")
            else:
                bot.send_message(message.chat.id, "lol")



    elif(message.text == "EMS One Katowice 2014 \U0001F1F5\U0001F1F1"):
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=3)
        AK47 = types.KeyboardButton("AK-47")
        AWP = types.KeyboardButton("AWP")
        Deagle = types.KeyboardButton("Desert Eagle")
        M4A4 = types.KeyboardButton("M4A4")
        M4A1S = types.KeyboardButton("M4A1-S")
        USP = types.KeyboardButton("USP-S")
        Glock = types.KeyboardButton("Glock-18")
        Famas = types.KeyboardButton("Famas")
        Galil = types.KeyboardButton("Galil AR")
        AUG = types.KeyboardButton("AUG")
        SG553 = types.KeyboardButton("SG 553")
        SSG08 = types.KeyboardButton("SGG 08")
        P250 = types.KeyboardButton("P250")
        CZ75 = types.KeyboardButton("CZ75-Auto")
        Tec = types.KeyboardButton("TEC-9")
        R8 = types.KeyboardButton("R8 Revolver")
        FS = types.KeyboardButton("Five-SeveN")
        Berettas = types.KeyboardButton("Dual Berettas")
        P2000 = types.KeyboardButton("P2000")
        MP9 = types.KeyboardButton("MP9")
        MAC10 = types.KeyboardButton("MAC-10")
        MP7 = types.KeyboardButton("MP7")
        P90 = types.KeyboardButton("P90")
        UMP = types.KeyboardButton("UMP-45")
        MP5 = types.KeyboardButton("MP5-SD")
        Bizon = types.KeyboardButton("PP-Bizon")
        MAG = types.KeyboardButton("MAG-7")
        XM = types.KeyboardButton("XM1014")
        Nova = types.KeyboardButton("Nova")
        SawedOff = types.KeyboardButton("Sawed-Off")
        Negev = types.KeyboardButton("Negev")
        M249 = types.KeyboardButton("M249")
        SCAR = types.KeyboardButton("SCAR-20")
        G3SG1 = types.KeyboardButton("G3SG1")
        any = types.KeyboardButton("Any")
        back = types.KeyboardButton("Back")
        menu = types.KeyboardButton("Menu")
        markup.add(AK47, AWP, Deagle, M4A4, M4A1S, USP, Glock, Famas, Galil, AUG, SG553, SSG08, P250, CZ75, Tec, R8, FS,
                   Berettas, P2000, MP9, MAC10, MP7, P90, UMP, MP5, Bizon, MAG, XM, Nova, SawedOff, Negev, M249, SCAR,
                   G3SG1, any, back, menu)
        bot.send_message(message.chat.id, "Пожалуйста, выберите интересующее Вас оружие", reply_markup=markup)
##код не вмещается, но дальше он и не нужен
  • Вопрос задан
  • 81 просмотр
Пригласить эксперта
Ответы на вопрос 1
@SawaPlayGO
Делов в том что при получении любого текста происходит изначально проверка условия:

if message.text == "DreamHack Winter 2013 \U0001F1F8\U0001F1EA" :


Если текст не равен этому то дальше код не выполняется, для решения проблемы, используете elif message.text == "Any".

Вот как примерно должно выглядеть:

@bot.message_handler(content_types=['text'])
def second(message):
    if (message.text == "DreamHack Winter 2013 \U0001F1F8\U0001F1EA"):
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width = 3)
        any = types.KeyboardButton("Any")
        markup.add(any)
        bot.send_message(message.chat.id, "Пожалуйста, выберите интересующее Вас оружие", reply_markup = markup)
        
    elif (message.text == "Any"):
        bot.send_message(message.chat.id, "https://steamcommunity.com/market/search?descriptions=1&category_730_ItemSet%5B%5D=any&category_730_ProPlayer%5B%5D=any&category_730_StickerCapsule%5B%5D=any&category_730_TournamentTeam%5B%5D=any&category_730_Weapon%5B%5D=any&appid=730&q=%22DreamHack+Winter%22")
    else:
        bot.send_message(message.chat.id, "lol")
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
16 мая 2024, в 23:36
200000 руб./за проект
16 мая 2024, в 23:10
12000 руб./за проект