AuroraDiscordBot/auroraBot.py

54 lines
1.4 KiB
Python
Raw Normal View History

2023-03-20 18:54:38 +00:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import discord
from discord.ext import commands
import config
2023-03-20 19:27:40 +00:00
import random
2023-03-20 19:43:40 +00:00
import requests
2023-03-20 18:54:38 +00:00
TOKEN = config.token
ID = config.channel_id
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command(name='sky', help='Shows the latest image from the All Sky Camera in Kiruna')
async def ASC(ctx):
2023-03-20 19:27:40 +00:00
num = random.randint(1,100000)
message = f'https://www.irf.se/alis/allsky/krn/latest.jpeg?{num}'
2023-03-20 18:54:38 +00:00
if ctx.channel.id != ID:
2023-03-20 19:08:14 +00:00
await ctx.send(f"Please keep this stuff in <#{ID}>")
2023-03-20 18:54:38 +00:00
return
else:
await ctx.send(message)
return
2023-03-20 19:43:40 +00:00
@bot.command(name='kp', help='Shows the current Kp index')
async def kp(ctx):
response = requests.get('https://services.swpc.noaa.gov/products/noaa-planetary-k-index.json')
data = response.json()
kp = data[-1][1]
message = f'The current Kp index is {kp}'
if ctx.channel.id != ID:
await ctx.send(f"Please keep this stuff in <#{ID}>")
return
else:
await ctx.send(message)
return
2023-03-20 22:07:37 +00:00
@bot.command(name='solarWind', help='Shows graph with solar wind and magnetic field info')
async def ASC(ctx):
num = random.randint(1,100000)
message = f'https://www.spaceweather.se/content/irf-kp.png?{num}'
if ctx.channel.id != ID:
await ctx.send(f"Please keep this stuff in <#{ID}>")
return
else:
await ctx.send(message)
return
2023-03-20 18:54:38 +00:00
bot.run(TOKEN)