Skip to content

Commit

Permalink
Merge pull request #84 from Appelsiini1/scheduler-dev
Browse files Browse the repository at this point in the history
v2.0.3
  • Loading branch information
Appelsiini1 authored Jan 18, 2022
2 parents 26c96a2 + 88345d3 commit 7aeee64
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 18 deletions.
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ def resetLimits(self):
REQUEST_LIMITS = requestLimits()

# Version number
VERSION = "v2.0.2"
VERSION = "v2.0.3"
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
54 changes: 54 additions & 0 deletions modules/mood.py
Original file line number Diff line number Diff line change
@@ -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))
20 changes: 10 additions & 10 deletions modules/short_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 9 additions & 7 deletions modules/vaccine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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\
Expand Down
4 changes: 4 additions & 0 deletions webhook/versions.txt
Original file line number Diff line number Diff line change
@@ -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
###
Expand Down

0 comments on commit 7aeee64

Please sign in to comment.