mirror of
https://gitlab.com/MisterBiggs/multi-bot-tutorial.git
synced 2025-06-16 07:06:51 +00:00
operational version of telegram bot
This commit is contained in:
parent
52c2a99f3a
commit
fe4ffba031
@ -11,7 +11,7 @@ def nextLaunch():
|
|||||||
"rocket": "Proton-M/Blok DM-03 ",
|
"rocket": "Proton-M/Blok DM-03 ",
|
||||||
"mission": " Spektr-RG",
|
"mission": " Spektr-RG",
|
||||||
"date": "July 12, 2019 12:31:00 UTC",
|
"date": "July 12, 2019 12:31:00 UTC",
|
||||||
"countdown": "The launch is in 14 hours and 48 minutes.",
|
"countdown": "14 hours and 48 minutes.",
|
||||||
"video": "https://www.youtube.com/watch?v=Dy1nkGghEVk",
|
"video": "https://www.youtube.com/watch?v=Dy1nkGghEVk",
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -29,7 +29,7 @@ def nextLaunch():
|
|||||||
countdown = str(
|
countdown = str(
|
||||||
datetime.strptime(date, "%B %d, %Y %H:%M:%S %Z") - datetime.today()
|
datetime.strptime(date, "%B %d, %Y %H:%M:%S %Z") - datetime.today()
|
||||||
).split(":")
|
).split(":")
|
||||||
countdown = f"The launch is in {countdown[0]} hours and {countdown[1]} minutes."
|
countdown = f"{countdown[0]} hours and {countdown[1]} minutes."
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
@ -24,11 +24,13 @@ def start(bot, update):
|
|||||||
update.message.reply_text("I am started and ready to go!")
|
update.message.reply_text("I am started and ready to go!")
|
||||||
|
|
||||||
|
|
||||||
def nextRocketLaunch():
|
def nextRocketLaunch(bot, update):
|
||||||
nextLaunch()
|
launch = nextLaunch()
|
||||||
|
|
||||||
|
|
||||||
|
message = f"The **{launch['mission']}** is in {launch['countdown']}\n\n"
|
||||||
|
message += f"The Mission is using the {launch['rocket']} and you can watch the mission live [here]({launch['video']})"
|
||||||
|
|
||||||
|
update.message.reply_text(text=message, parse_mode=telegram.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
|
|
||||||
def error(bot, update, error):
|
def error(bot, update, error):
|
||||||
@ -46,7 +48,7 @@ def main():
|
|||||||
|
|
||||||
# on different commands - answer in Telegram
|
# on different commands - answer in Telegram
|
||||||
dp.add_handler(CommandHandler("start", start))
|
dp.add_handler(CommandHandler("start", start))
|
||||||
dp.add_handler(CommandHandler("Launch", nextRocketLaunch))
|
dp.add_handler(CommandHandler("launch", nextRocketLaunch))
|
||||||
|
|
||||||
# log all errors
|
# log all errors
|
||||||
dp.add_error_handler(error)
|
dp.add_error_handler(error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user