nieuw muzak eindpunt
This commit is contained in:
+24
-5
@@ -5,6 +5,7 @@ import random
|
|||||||
import re
|
import re
|
||||||
import json, requests
|
import json, requests
|
||||||
import warnings
|
import warnings
|
||||||
|
from datetime import date, timedelta
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
class General(commands.Cog):
|
class General(commands.Cog):
|
||||||
@@ -12,7 +13,7 @@ class General(commands.Cog):
|
|||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
self.muzak_url = 'https://muzak.hoekveen.net'
|
||||||
self.r = praw.Reddit(
|
self.r = praw.Reddit(
|
||||||
user_agent='StroopwafelBot',
|
user_agent='StroopwafelBot',
|
||||||
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
||||||
@@ -92,11 +93,29 @@ class General(commands.Cog):
|
|||||||
return requests.get(self.muzak_url + '/stroopwafel')
|
return requests.get(self.muzak_url + '/stroopwafel')
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def playlist(self, ctx):
|
async def muzak(self, ctx):
|
||||||
"""HDcon2021 playlist"""
|
"""HD muzak playlist"""
|
||||||
data = json.loads(self.get_playlist_json().content)
|
data = json.loads(self.get_playlist_json().content)
|
||||||
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
msg = ""
|
||||||
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
open = date.fromisoformat(data['openDate'])
|
||||||
|
nom = date.fromisoformat(data['deadlineNominations'])
|
||||||
|
vote = date.fromisoformat(data['deadlineVoting'])
|
||||||
|
today = date.today()
|
||||||
|
if open > today:
|
||||||
|
msg += "Het stemmen is nog niet geopend voor dit jaar.\n"
|
||||||
|
msg += f"Nog even geduld; Vanaf {open} is de muzak open en kun je naar hartelust stemmen en nomineren.\n"
|
||||||
|
elif today > nom and today > vote and (today - vote) < timedelta(days=8):
|
||||||
|
msg += "Het nomineren en stemmen is alweer voorbij.\n"
|
||||||
|
msg += "Je zult nog even geduld moeten hebben tot de lijst klaar is.\n"
|
||||||
|
elif today > nom and today > vote:
|
||||||
|
msg += "De lijst is al helemaal klaar. Goed gedaan jongens. Applausje voor jezelf."
|
||||||
|
else:
|
||||||
|
if open == today:
|
||||||
|
msg += "Jawel mensen! Vanaf vandaag mag het stemmen beginnen!\n"
|
||||||
|
msg += f"Stemmen en nomineren kan hier: {self.muzak_url}\n"
|
||||||
|
msg += f"*Er zijn al {data['stemCount']} nummers genomineerd!*\n"
|
||||||
|
msg += f"Nomineren kan tot {nom}, stemmen kan tot {vote}.\n"
|
||||||
|
msg += "\nIk hoop dat jullie allemaal je beste nummers insturen!"
|
||||||
await ctx.channel.send(msg)
|
await ctx.channel.send(msg)
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ import discord
|
|||||||
#import Music
|
#import Music
|
||||||
import Shitpost
|
import Shitpost
|
||||||
import General
|
import General
|
||||||
import Cryptocoin
|
#import Cryptocoin
|
||||||
import Chatbot
|
import Chatbot
|
||||||
import Points
|
import Points
|
||||||
import logging
|
import logging
|
||||||
@@ -19,7 +19,7 @@ dotenv.load_dotenv()
|
|||||||
async def add_cogs(bot):
|
async def add_cogs(bot):
|
||||||
await bot.add_cog(Shitpost.Shitpost(bot))
|
await bot.add_cog(Shitpost.Shitpost(bot))
|
||||||
await bot.add_cog(General.General(bot))
|
await bot.add_cog(General.General(bot))
|
||||||
await bot.add_cog(Cryptocoin.Cryptocoin(bot))
|
#await bot.add_cog(Cryptocoin.Cryptocoin(bot))
|
||||||
await bot.add_cog(Chatbot.Chatbot(bot))
|
await bot.add_cog(Chatbot.Chatbot(bot))
|
||||||
await bot.add_cog(Points.Points(bot))
|
await bot.add_cog(Points.Points(bot))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user