diff --git a/bot.py b/bot.py index 18a41f8..af6972a 100644 --- a/bot.py +++ b/bot.py @@ -14,6 +14,8 @@ dispatcher = updater.dispatcher logging.basicConfig(format='%(acstime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) +sent_multiple_station_message_ids = dict() + class Query: station_id = -1 @@ -61,7 +63,8 @@ def reply_multiple_stations(message, message_text, queried_station, station_list callback_data="/vvs " + message_text .replace(queried_station, station['stationId']))) reply_markup = InlineKeyboardMarkup(build_menu(button_list, n_cols=2)) - message.reply_text("Multiple stations found:", reply_markup=reply_markup) + sent_multiple_station_message_ids[message.chat_id] = message.reply_text("Multiple stations found:", + reply_markup=reply_markup).message_id def handle_multiple_stations_reply(update, context): @@ -69,6 +72,9 @@ def handle_multiple_stations_reply(update, context): departures = get_vvs_departures(query) for reply in departures: context.bot.send_message(update.effective_chat['id'], reply) + context.bot.delete_message(chat_id=update.effective_chat['id'], + message_id=sent_multiple_station_message_ids[update.effective_chat['id']]) + del sent_multiple_station_message_ids[update.effective_chat['id']] def search_station(query):