1
0
mirror of https://gitlab.com/MisterBiggs/multi-bot-tutorial.git synced 2025-06-15 22:56:45 +00:00

made directory structure and functions

This commit is contained in:
Anson 2019-07-11 10:45:49 -07:00
parent 83d69a7502
commit dc844dd812
5 changed files with 42 additions and 0 deletions

0
discord/discord.py Normal file
View File

0
discord/requirements.txt Normal file
View File

28
functions.py Normal file
View File

@ -0,0 +1,28 @@
import requests
from datetime import datetime
def nextLaunch():
url = "https://launchlibrary.net/1.4/launch/next/1?mode=list"
response = requests.get(url)
if response.status_code is 200:
data = response.json()["launches"][0]
rocket, mission = data["name"].split("|")
date = data["net"]
countdown = datetime.strptime(date, "%B %d, %Y %H:%M:%S %Z") - datetime.today()
else:
print("error")
launch = {
"rocket": rocket,
"mission": mission,
"date": date,
"countdown": str(countdown),
"video": data["vidURLs"][0],
}
return launch

View File

14
telegram/telegram.py Normal file
View File

@ -0,0 +1,14 @@
import telegram
from telegram.ext import Updater, CommandHandler
def hello(bot, update):
update.message.reply_text("Hello {}".format(update.message.from_user.first_name))
updater = Updater("YOUR TOKEN HERE")
updater.dispatcher.add_handler(CommandHandler("hello", hello))
updater.start_polling()
updater.idle()