aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/valentines
diff options
context:
space:
mode:
Diffstat (limited to 'bot/seasons/valentines')
-rw-r--r--bot/seasons/valentines/be_my_valentine.py13
-rw-r--r--bot/seasons/valentines/lovecalculator.py21
-rw-r--r--bot/seasons/valentines/movie_generator.py12
-rw-r--r--bot/seasons/valentines/myvalenstate.py3
-rw-r--r--bot/seasons/valentines/pickuplines.py2
-rw-r--r--bot/seasons/valentines/savethedate.py2
-rw-r--r--bot/seasons/valentines/valentine_zodiac.py9
-rw-r--r--bot/seasons/valentines/whoisvalentine.py3
8 files changed, 17 insertions, 48 deletions
diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py
index 55c4adb1..90e4d5db 100644
--- a/bot/seasons/valentines/be_my_valentine.py
+++ b/bot/seasons/valentines/be_my_valentine.py
@@ -25,7 +25,6 @@ class BeMyValentine(commands.Cog):
@staticmethod
def load_json():
"""Load Valentines messages from the static resources."""
-
p = Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json')
with p.open() as json_data:
valentines = load(json_data)
@@ -41,13 +40,11 @@ class BeMyValentine(commands.Cog):
1) use the command \".lovefest sub\" to get the lovefest role.
2) use the command \".lovefest unsub\" to get rid of the lovefest role.
"""
-
await ctx.invoke(self.bot.get_command("help"), "lovefest")
@lovefest_role.command(name="sub")
async def add_role(self, ctx):
"""Adds the lovefest role."""
-
user = ctx.author
role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id)
if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]:
@@ -59,7 +56,6 @@ class BeMyValentine(commands.Cog):
@lovefest_role.command(name="unsub")
async def remove_role(self, ctx):
"""Removes the lovefest role."""
-
user = ctx.author
role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id)
if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]:
@@ -82,7 +78,6 @@ class BeMyValentine(commands.Cog):
example: .bemyvalentine Iceman Hey I love you, wanna hang around ? (sends the custom message to Iceman)
NOTE : AVOID TAGGING THE USER MOST OF THE TIMES.JUST TRIM THE '@' when using this command.
"""
-
if ctx.guild is None:
# This command should only be used in the server
msg = "You are supposed to use this command in the server."
@@ -132,7 +127,6 @@ class BeMyValentine(commands.Cog):
example : .bemyvalentine secret Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to
Iceman in DM making you anonymous)
"""
-
if ctx.guild is not None:
# This command is only DM specific
msg = "You are not supposed to use this command in the server, DM the command to the bot."
@@ -172,7 +166,6 @@ class BeMyValentine(commands.Cog):
def valentine_check(self, valentine_type):
"""Return the appropriate Valentine type & title based on the invoking user's input."""
-
if valentine_type is None:
valentine, title = self.random_valentine()
@@ -200,7 +193,6 @@ class BeMyValentine(commands.Cog):
:param author: member who invoked the command
:param members: list of discord.Member objects
"""
-
if author in members:
members.remove(author)
@@ -209,14 +201,12 @@ class BeMyValentine(commands.Cog):
@staticmethod
def random_emoji():
"""Return two random emoji from the module-defined constants."""
-
EMOJI_1 = random.choice(HEART_EMOJIS)
EMOJI_2 = random.choice(HEART_EMOJIS)
return EMOJI_1, EMOJI_2
def random_valentine(self):
"""Grabs a random poem or a compliment (any message)."""
-
valentine_poem = random.choice(self.valentines['valentine_poems'])
valentine_compliment = random.choice(self.valentines['valentine_compliments'])
random_valentine = random.choice([valentine_compliment, valentine_poem])
@@ -228,19 +218,16 @@ class BeMyValentine(commands.Cog):
def valentine_poem(self):
"""Grabs a random poem."""
-
valentine_poem = random.choice(self.valentines['valentine_poems'])
return valentine_poem
def valentine_compliment(self):
"""Grabs a random compliment."""
-
valentine_compliment = random.choice(self.valentines['valentine_compliments'])
return valentine_compliment
def setup(bot):
"""Be my Valentine Cog load."""
-
bot.add_cog(BeMyValentine(bot))
log.info("BeMyValentine cog loaded")
diff --git a/bot/seasons/valentines/lovecalculator.py b/bot/seasons/valentines/lovecalculator.py
index cd684f9d..ca8eaaf6 100644
--- a/bot/seasons/valentines/lovecalculator.py
+++ b/bot/seasons/valentines/lovecalculator.py
@@ -49,41 +49,39 @@ class LoveCalculator(Cog):
If only one argument is provided, the subject will become one of the helpers at random.
"""
-
if whom is None:
staff = ctx.guild.get_role(Roles.helpers).members
whom = random.choice(staff)
def normalize(arg):
if isinstance(arg, Member):
- # if we are given a member, return name#discrim without any extra changes
+ # If we are given a member, return name#discrim without any extra changes
arg = str(arg)
else:
- # otherwise normalise case and remove any leading/trailing whitespace
+ # Otherwise normalise case and remove any leading/trailing whitespace
arg = arg.strip().title()
- # this has to be done manually to be applied to usernames
+ # This has to be done manually to be applied to usernames
return clean_content(escape_markdown=True).convert(ctx, arg)
who, whom = [await normalize(arg) for arg in (who, whom)]
- # make sure user didn't provide something silly such as 10 spaces
+ # Make sure user didn't provide something silly such as 10 spaces
if not (who and whom):
raise BadArgument('Arguments be non-empty strings.')
- # hash inputs to guarantee consistent results (hashing algorithm choice arbitrary)
+ # Hash inputs to guarantee consistent results (hashing algorithm choice arbitrary)
#
- # hashlib is used over the builtin hash() function
- # to guarantee same result over multiple runtimes
+ # hashlib is used over the builtin hash() to guarantee same result over multiple runtimes
m = hashlib.sha256(who.encode() + whom.encode())
- # mod 101 for [0, 100]
+ # Mod 101 for [0, 100]
love_percent = sum(m.digest()) % 101
# We need the -1 due to how bisect returns the point
# see the documentation for further detail
# https://docs.python.org/3/library/bisect.html#bisect.bisect
index = bisect.bisect(LOVE_DATA, (love_percent,)) - 1
- # we already have the nearest "fit" love level
- # we only need the dict, so we can ditch the first element
+ # We already have the nearest "fit" love level
+ # We only need the dict, so we can ditch the first element
_, data = LOVE_DATA[index]
status = random.choice(data['titles'])
@@ -102,6 +100,5 @@ class LoveCalculator(Cog):
def setup(bot):
"""Love calculator Cog load."""
-
bot.add_cog(LoveCalculator(bot))
log.info("LoveCalculator cog loaded")
diff --git a/bot/seasons/valentines/movie_generator.py b/bot/seasons/valentines/movie_generator.py
index a09a563f..fa5f236a 100644
--- a/bot/seasons/valentines/movie_generator.py
+++ b/bot/seasons/valentines/movie_generator.py
@@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
class RomanceMovieFinder(commands.Cog):
- """A cog that returns a random romance movie suggestion to a user."""
+ """A Cog that returns a random romance movie suggestion to a user."""
def __init__(self, bot):
self.bot = bot
@@ -20,8 +20,7 @@ class RomanceMovieFinder(commands.Cog):
@commands.command(name="romancemovie")
async def romance_movie(self, ctx):
"""Randomly selects a romance movie and displays information about it."""
-
- # selecting a random int to parse it to the page parameter
+ # Selecting a random int to parse it to the page parameter
random_page = random.randint(0, 20)
# TMDB api params
params = {
@@ -33,13 +32,13 @@ class RomanceMovieFinder(commands.Cog):
"page": random_page,
"with_genres": "10749"
}
- # the api request url
+ # The api request url
request_url = "https://api.themoviedb.org/3/discover/movie?" + parse.urlencode(params)
async with self.bot.http_session.get(request_url) as resp:
- # trying to load the json file returned from the api
+ # Trying to load the json file returned from the api
try:
data = await resp.json()
- # selecting random result from results object in the json file
+ # Selecting random result from results object in the json file
selected_movie = random.choice(data["results"])
embed = discord.Embed(
@@ -60,6 +59,5 @@ class RomanceMovieFinder(commands.Cog):
def setup(bot):
"""Romance movie Cog load."""
-
bot.add_cog(RomanceMovieFinder(bot))
log.info("RomanceMovieFinder cog loaded")
diff --git a/bot/seasons/valentines/myvalenstate.py b/bot/seasons/valentines/myvalenstate.py
index 344f52f6..6a8d8b1d 100644
--- a/bot/seasons/valentines/myvalenstate.py
+++ b/bot/seasons/valentines/myvalenstate.py
@@ -23,7 +23,6 @@ class MyValenstate(commands.Cog):
def levenshtein(self, source, goal):
"""Calculates the Levenshtein Distance between source and goal."""
-
if len(source) < len(goal):
return self.levenshtein(goal, source)
if len(source) == 0:
@@ -45,7 +44,6 @@ class MyValenstate(commands.Cog):
@commands.command()
async def myvalenstate(self, ctx, *, name=None):
"""Find the vacation spot(s) with the most matching characters to the invoking user."""
-
eq_chars = collections.defaultdict(int)
if name is None:
author = ctx.message.author.name.lower().replace(' ', '')
@@ -85,6 +83,5 @@ class MyValenstate(commands.Cog):
def setup(bot):
"""Valenstate Cog load."""
-
bot.add_cog(MyValenstate(bot))
log.info("MyValenstate cog loaded")
diff --git a/bot/seasons/valentines/pickuplines.py b/bot/seasons/valentines/pickuplines.py
index ad75c93f..00ed5453 100644
--- a/bot/seasons/valentines/pickuplines.py
+++ b/bot/seasons/valentines/pickuplines.py
@@ -27,7 +27,6 @@ class PickupLine(commands.Cog):
Note that most of them are very cheesy.
"""
-
random_line = random.choice(pickup_lines['lines'])
embed = discord.Embed(
title=':cheese: Your pickup line :cheese:',
@@ -42,6 +41,5 @@ class PickupLine(commands.Cog):
def setup(bot):
"""Pickup lines Cog load."""
-
bot.add_cog(PickupLine(bot))
log.info('PickupLine cog loaded')
diff --git a/bot/seasons/valentines/savethedate.py b/bot/seasons/valentines/savethedate.py
index 281625a4..a2d9a22d 100644
--- a/bot/seasons/valentines/savethedate.py
+++ b/bot/seasons/valentines/savethedate.py
@@ -25,7 +25,6 @@ class SaveTheDate(commands.Cog):
@commands.command()
async def savethedate(self, ctx):
"""Gives you ideas for what to do on a date with your valentine."""
-
random_date = random.choice(VALENTINES_DATES['ideas'])
emoji_1 = random.choice(HEART_EMOJIS)
emoji_2 = random.choice(HEART_EMOJIS)
@@ -39,6 +38,5 @@ class SaveTheDate(commands.Cog):
def setup(bot):
"""Save the date Cog Load."""
-
bot.add_cog(SaveTheDate(bot))
log.info("SaveTheDate cog loaded")
diff --git a/bot/seasons/valentines/valentine_zodiac.py b/bot/seasons/valentines/valentine_zodiac.py
index 1700260e..7f78d3bc 100644
--- a/bot/seasons/valentines/valentine_zodiac.py
+++ b/bot/seasons/valentines/valentine_zodiac.py
@@ -15,7 +15,7 @@ HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_hea
class ValentineZodiac(commands.Cog):
- """A cog that returns a counter compatible zodiac sign to the given user's zodiac sign."""
+ """A Cog that returns a counter compatible zodiac sign to the given user's zodiac sign."""
def __init__(self, bot):
self.bot = bot
@@ -23,8 +23,7 @@ class ValentineZodiac(commands.Cog):
@staticmethod
def load_json():
- """Load Zodiac compatibility from static JSON resource."""
-
+ """Load zodiac compatibility from static JSON resource."""
p = Path('bot', 'resources', 'valentines', 'zodiac_compatibility.json')
with p.open() as json_data:
zodiacs = load(json_data)
@@ -33,7 +32,6 @@ class ValentineZodiac(commands.Cog):
@commands.command(name="partnerzodiac")
async def counter_zodiac(self, ctx, zodiac_sign):
"""Provides a counter compatible zodiac sign to the given user's zodiac sign."""
-
try:
compatible_zodiac = random.choice(self.zodiacs[zodiac_sign.lower()])
except KeyError:
@@ -55,7 +53,6 @@ class ValentineZodiac(commands.Cog):
def setup(bot):
- """Valentine Zodiac Cog load."""
-
+ """Valentine zodiac Cog load."""
bot.add_cog(ValentineZodiac(bot))
log.info("ValentineZodiac cog loaded")
diff --git a/bot/seasons/valentines/whoisvalentine.py b/bot/seasons/valentines/whoisvalentine.py
index 96d97e22..0a868fe6 100644
--- a/bot/seasons/valentines/whoisvalentine.py
+++ b/bot/seasons/valentines/whoisvalentine.py
@@ -23,7 +23,6 @@ class ValentineFacts(commands.Cog):
@commands.command(aliases=('whoisvalentine', 'saint_valentine'))
async def who_is_valentine(self, ctx):
"""Displays info about Saint Valentine."""
-
embed = discord.Embed(
title="Who is Saint Valentine?",
description=FACTS['whois'],
@@ -39,7 +38,6 @@ class ValentineFacts(commands.Cog):
@commands.command()
async def valentine_fact(self, ctx):
"""Shows a random fact about Valentine's Day."""
-
embed = discord.Embed(
title=choice(FACTS['titles']),
description=choice(FACTS['text']),
@@ -51,6 +49,5 @@ class ValentineFacts(commands.Cog):
def setup(bot):
"""Who is Valentine Cog load."""
-
bot.add_cog(ValentineFacts(bot))
log.info("ValentineFacts cog loaded")