@sundayss

Как сделать чтоб при нажатии на inline кнопку прошлое сообщение от бота удалялось?

Хотел сделать удаление сообщений создал переменную для сообщения, добавил к коду
bot.delete_message(call.message.chat.id, переменная.message_id)

Но не работает что делать?
import telebot
from telebot import types
import config

bot = telebot.TeleBot(config.bottoken)

@bot.message_handler(commands=['start'])
def start_message(message):
  print("Пользователь нажал старт")
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  store = types.KeyboardButton("Магазин")
  markup.add(store)
import telebot
from telebot import types
import config

bot = telebot.TeleBot(config.bottoken)

@bot.message_handler(commands=['start'])
def start_message(message):
  print("Пользователь нажал старт")
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  store = types.KeyboardButton("Магазин")
  markup.add(store)
  bot.send_message(message.chat.id,"❤Привет пользовател спасибо что выбрал наш магазин❤\n⬇Выбери один из пунктов меню чтобы начать⬇", reply_markup=markup)

@bot.message_handler(content_types=['text'])
def func(message):
    if(message.text == "Магазин"):
      markup = types.InlineKeyboardMarkup()
      standoff = telebot.types.InlineKeyboardButton(text="Standoff 2", callback_data='stand')
      markup.add(standoff)
      global standvibor
      standvibor = bot.send_message(message.chat.id, text="Выбери ниже игру в которой хочешь купить валюту", reply_markup=markup)

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    try:
        if call.message:
            if call.data == "stand":
                bot.delete_message(call.message.chat.id, standvibor.id)
                markup = types.InlineKeyboardMarkup()
                calcgold = types.InlineKeyboardButton(text="Калькулятор голды", callback_data="calcgolda")
                markup.add(calcgold)
                bot.send_message(call.message.chat.id, "Выбери действие:", reply_markup=markup)
            if call.data == "calcgolda":
                markup = types.InlineKeyboardMarkup()
                calcrubgold = types.InlineKeyboardButton(text="Посчитать рубли в голде", callback_data="calcrubgolda")
                markup.add(calcrubgold)
                bot.send_message(call.message.chat.id, "Выбери калькулятор:", reply_markup=markup)
    except Exception as e:
        print(repr(e))


bot.polling(none_stop=True)

Вот скрипт просто для продажи доната в игре
что мне куда добавить пж?
  • Вопрос задан
  • 165 просмотров
Решения вопроса 1
febday
@febday
Хотите сказать, что так не работает?
bot.delete_message(call.message.chat.id, call.message.message_id)
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы