Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flight #123

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 20 additions & 18 deletions src/honeybot/plugins/downloaded/flight/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
>>> .flight <<flight callsign>>
"""

from datetime import datetime
import flightradar24 as fr24


Expand All @@ -39,7 +38,8 @@ def run(self, incoming, methods, info, bot_info):
if "errors" in flight: # check for api error
methods["send"](
info["address"],
"Invalid input! Callsign should not be more than 10 characters!",
"Invalid input! Callsign " +
"should not be more than 10 characters!",
)

else:
Expand All @@ -61,30 +61,32 @@ def run(self, incoming, methods, info, bot_info):
]["destination"]["position"]["region"]["city"]
methods["send"](
info["address"],
"Flight "
+ id
+ " is from "
+ origin
+ " to "
+ destination
+ ".",
"Flight " +
id +
" is from " +
origin +
" to " +
destination +
".",
)

total = 0
count = 0
for f in flight["result"]["response"][
"data"
]: # flight["result"]["response"]["data"] will hold a week long history of flights
]: # flight["result"]["response"]["data"]
# will hold a week long history of flights
if f["status"]["live"]:
methods["send"](
info["address"],
"This flight is currently in the air. The following information is available:",
"This flight is currently in the air. " +
"The following information is available:",
)
methods["send"](
info["address"], f["status"]["text"]
)

if f["time"]["other"]["duration"] != None:
if f["time"]["other"]["duration"] is not None:
total += f["time"]["other"]["duration"]
count += 1

Expand All @@ -93,17 +95,17 @@ def run(self, incoming, methods, info, bot_info):
5 * round(float(avgDuration) / 5)
) # round to nearest five
hours = 0
while avg >= 60:
while avgDuration >= 60:
mins -= 60
hours += 1

methods["send"](
info["address"],
"The flight has an average duration of "
+ str(hours)
+ ":"
+ str(mins)
+ ".",
"The flight has an average duration of " +
str(hours) +
":" +
str(mins) +
".",
)

except Exception as e:
Expand Down