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:
		
							parent
							
								
									c11d324588
								
							
						
					
					
						commit
						9f19440f9b
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		
							
								
								
									
										8
									
								
								bot.py
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								bot.py
									
										
									
									
									
								
							| 
						 | 
					@ -14,6 +14,8 @@ dispatcher = updater.dispatcher
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logging.basicConfig(format='%(acstime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
 | 
					logging.basicConfig(format='%(acstime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sent_multiple_station_message_ids = dict()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Query:
 | 
					class Query:
 | 
				
			||||||
    station_id = -1
 | 
					    station_id = -1
 | 
				
			||||||
| 
						 | 
					@ -61,7 +63,8 @@ def reply_multiple_stations(message, message_text, queried_station, station_list
 | 
				
			||||||
                                                callback_data="/vvs " + message_text
 | 
					                                                callback_data="/vvs " + message_text
 | 
				
			||||||
                                                .replace(queried_station, station['stationId'])))
 | 
					                                                .replace(queried_station, station['stationId'])))
 | 
				
			||||||
    reply_markup = InlineKeyboardMarkup(build_menu(button_list, n_cols=2))
 | 
					    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):
 | 
					def handle_multiple_stations_reply(update, context):
 | 
				
			||||||
| 
						 | 
					@ -69,6 +72,9 @@ def handle_multiple_stations_reply(update, context):
 | 
				
			||||||
    departures = get_vvs_departures(query)
 | 
					    departures = get_vvs_departures(query)
 | 
				
			||||||
    for reply in departures:
 | 
					    for reply in departures:
 | 
				
			||||||
        context.bot.send_message(update.effective_chat['id'], reply)
 | 
					        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):
 | 
					def search_station(query):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue