diff --git a/constants.py b/constants.py index a9f95ba..dec1cfc 100644 --- a/constants.py +++ b/constants.py @@ -135,4 +135,4 @@ def resetLimits(self): REQUEST_LIMITS = requestLimits() # Version number -VERSION = "v2.0.2" +VERSION = "v2.0.3" diff --git a/main.py b/main.py index 5aec77d..3fef8f7 100644 --- a/main.py +++ b/main.py @@ -27,6 +27,7 @@ from modules import short_comms from modules import saimaa from modules import message_listener +from modules import mood # Main bot class class CoraBot(commands.Bot): @@ -49,6 +50,7 @@ def __cogsetup__(self): short_comms.setup(self) insult.setup(self) message_listener.setup(self) + mood.setup(self) nitro.setup(self) poll.setup(self) pop.setup(self) diff --git a/modules/mood.py b/modules/mood.py new file mode 100644 index 0000000..23b3600 --- /dev/null +++ b/modules/mood.py @@ -0,0 +1,54 @@ +import random +import discord +from discord.ext import commands +from modules.common import get_hex_colour, check_if_channel, check_if_bot + + +class MOOD(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.moods = { + 0: "happy", + 1: "sad", + 2: "alone", + 3: "scared", + 4: "horny", + 5: "depressed", + 6: "angry", + 7: "anxious", + 8: "friendly", + 9: "optimistic", + 10: "romantic", + 11: "mischievous" + } + + @commands.command() + @commands.check(check_if_channel) + @commands.check(check_if_bot) + async def mood(self, ctx, *arg): + happy = random.randint(0, 100) + sad = random.randint(0, 100) + alone = random.randint(0, 100) + scared = random.randint(0, 100) + horny = random.randint(0, 100) + depressed = random.randint(0, 100) + angry = random.randint(0, 100) + anxious = random.randint(0, 100) + friendly = random.randint(0, 100) + optimistic = random.randint(0, 100) + romantic = random.randint(0, 100) + mischievous = random.randint(0, 100) + + mood_list = [happy, sad, alone, scared, horny, depressed, angry, anxious, friendly, optimistic, romantic, mischievous] + mood = random.randint(0, len(mood_list)-1) + mood_p = mood_list[mood] + mood_name = self.moods[mood] + + msg = f"{ctx.author.mention}** you are {mood_p}% {mood_name}.**" + + + await ctx.send(msg) + + +def setup(client): + client.add_cog(MOOD(client)) \ No newline at end of file diff --git a/modules/short_comms.py b/modules/short_comms.py index 3af1218..854d6a8 100644 --- a/modules/short_comms.py +++ b/modules/short_comms.py @@ -36,16 +36,16 @@ async def status(self, ctx): except Forbidden: await forbiddenErrorHandler(ctx.message) - @commands.command() - @commands.check(check_if_channel) - @commands.check(check_if_bot) - async def mood(self, ctx): - try: - await ctx.send( - "https://cdn.discordapp.com/attachments/816694548457324544/830847194142605403/hui_saakeli_tata_elamaa.mp4" - ) - except Forbidden: - await forbiddenErrorHandler(ctx.message) + # @commands.command() + # @commands.check(check_if_channel) + # @commands.check(check_if_bot) + # async def mood(self, ctx): + # try: + # await ctx.send( + # "https://cdn.discordapp.com/attachments/816694548457324544/830847194142605403/hui_saakeli_tata_elamaa.mp4" + # ) + # except Forbidden: + # await forbiddenErrorHandler(ctx.message) def setup(client): diff --git a/modules/vaccine.py b/modules/vaccine.py index b0108e9..a103e0b 100644 --- a/modules/vaccine.py +++ b/modules/vaccine.py @@ -105,11 +105,12 @@ class VACC_DATA(): - def __init__(self, oneDose, twoDoses, threeDoses, populationData): + def __init__(self, oneDose, twoDoses, threeDoses, populationData, area): self.oneDose = oneDose self.twoDoses = twoDoses self.threeDoses = threeDoses self.populationData = populationData + self.area = area class Vaccine(commands.Cog): @@ -162,7 +163,7 @@ def getVaccineInfo(self, param): for keypair in vacc_data: three_doses = keypair[1] - ResultData = VACC_DATA(one_dose, two_doses, three_doses, pop_data) + ResultData = VACC_DATA(one_dose, two_doses, three_doses, pop_data, param) return ResultData else: @@ -177,15 +178,16 @@ def getVaccineInfo(self, param): logging.error(response3.content) return (msg, msg2) - def makeEmbed(self, emb, vaccData = None, error_msg = "", areaCode="Finland"): + def makeEmbed(self, emb, vaccData = None, error_msg = ""): + if vaccData.area == "518362": + area = "Finland" + else: + area = ALUEET[vaccData.area] + if error_msg != "": emb.description = error_msg emb.color = get_hex_colour(error=True) else: - if areaCode != "Finland": - area = ALUEET[areaCode] - else: - area = "Finland" emb.title = f"Current number of COVID-19 vaccinated people in {area}:" emb.description = f"One dose: {vaccData.oneDose} ({round((int(vaccData.oneDose)/int(vaccData.populationData))*100)}% of area population)\n\ Two doses: {vaccData.twoDoses} ({round((int(vaccData.twoDoses)/int(vaccData.populationData))*100)}% of area population)\n\ diff --git a/webhook/versions.txt b/webhook/versions.txt index 07a76da..92da08d 100644 --- a/webhook/versions.txt +++ b/webhook/versions.txt @@ -1,3 +1,7 @@ +v2.0.3 +- Fix area name in vaccine command +- Rework `!c mood` command +### v2.0.2 - Add third dose to vaccine command ###