Message for selecting stations is now deleted after choice

this makes the chat shorter if a first query matched many possible
stations
This commit is contained in:
JuliusFreudenberger 2019-10-18 12:35:58 +02:00
parent c11d324588
commit 9f19440f9b

8
bot.py
View file

@ -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):