You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bot should be able to track flights based on their flight number.
Example command:
/flight DY611
The bot should then update the chat for information about this flight. E.g. send a message when the flight departs / arrives.
Might also make sense to tag the passenger, like:
/flight DY611 @heinz
This could result in messages like:
DY611 from Vienna to Oslo will depart in 5 minutes. Have a pleasant flight @heinz!
flightradar24 might be a good API to retrieve flight information.
Here's a code snippet to retrieve the next upcoming flight data of a given flight id:
import flightradar24
import time
flight_id = 'DY1632' # Turkish Airlines' Istanbul - New York flight
fr = flightradar24.Api()
flight = fr.get_flight(flight_id)
if 'result' in flight and 'response' in flight['result']:
response = flight['result']['response']
upcoming_flight = None
current_timestamp = time.time()
for item in response['data']:
departure_time = item['time']['scheduled']['departure']
if departure_time > current_timestamp:
if upcoming_flight is None or departure_time < upcoming_flight['time']['scheduled']['departure']:
upcoming_flight = item
The text was updated successfully, but these errors were encountered:
The bot should be able to track flights based on their flight number.
Example command:
/flight DY611
The bot should then update the chat for information about this flight. E.g. send a message when the flight departs / arrives.
Might also make sense to tag the passenger, like:
/flight DY611 @heinz
This could result in messages like:
flightradar24 might be a good API to retrieve flight information.
Here's a code snippet to retrieve the next upcoming flight data of a given flight id:
The text was updated successfully, but these errors were encountered: