AuroraDiscordBot/auroraBot.py
2023-03-20 23:07:37 +01:00

54 lines
1.4 KiB
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import discord
from discord.ext import commands
import config
import random
import requests
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):
num = random.randint(1,100000)
message = f'https://www.irf.se/alis/allsky/krn/latest.jpeg?{num}'
if ctx.channel.id != ID:
await ctx.send(f"Please keep this stuff in <#{ID}>")
return
else:
await ctx.send(message)
return
@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
@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
bot.run(TOKEN)