diff options
Diffstat (limited to 'bot/seasons/valentines')
| -rw-r--r-- | bot/seasons/valentines/__init__.py | 1 | ||||
| -rw-r--r-- | bot/seasons/valentines/be_my_valentine.py | 53 | ||||
| -rw-r--r-- | bot/seasons/valentines/lovecalculator.py | 6 | ||||
| -rw-r--r-- | bot/seasons/valentines/movie_generator.py | 13 | ||||
| -rw-r--r-- | bot/seasons/valentines/myvalenstate.py | 13 | ||||
| -rw-r--r-- | bot/seasons/valentines/pickuplines.py | 13 | ||||
| -rw-r--r-- | bot/seasons/valentines/savethedate.py | 13 | ||||
| -rw-r--r-- | bot/seasons/valentines/valentine_zodiac.py | 16 | ||||
| -rw-r--r-- | bot/seasons/valentines/whoisvalentine.py | 16 |
9 files changed, 80 insertions, 64 deletions
diff --git a/bot/seasons/valentines/__init__.py b/bot/seasons/valentines/__init__.py index f1489cf9..e3e04421 100644 --- a/bot/seasons/valentines/__init__.py +++ b/bot/seasons/valentines/__init__.py @@ -8,6 +8,7 @@ class Valentines(SeasonBase): Get yourself into the bot-commands channel and check out the new features! """ + name = "valentines" bot_name = "Tenderbot" greeting = "Get loved-up!" diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 4e2182c3..d90e73aa 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -15,10 +15,8 @@ log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -class BeMyValentine(commands.Cog): - """ - A cog that sends valentines to other users ! - """ +class BeMyValentine: + """A cog that sends Valentines to other users!""" def __init__(self, bot): self.bot = bot @@ -26,6 +24,8 @@ 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) @@ -34,19 +34,20 @@ class BeMyValentine(commands.Cog): @commands.group(name="lovefest", invoke_without_command=True) async def lovefest_role(self, ctx): """ - You can have yourself the lovefest role or remove it. + Subscribe or unsubscribe from the lovefest role. + The lovefest role makes you eligible to receive anonymous valentines from other users. 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): - """ - This command adds the lovefest role. - """ + """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]: @@ -57,9 +58,8 @@ class BeMyValentine(commands.Cog): @lovefest_role.command(name="unsub") async def remove_role(self, ctx): - """ - This command removes the lovefest role. - """ + """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]: @@ -72,7 +72,7 @@ class BeMyValentine(commands.Cog): @commands.group(name='bemyvalentine', invoke_without_command=True) async def send_valentine(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): """ - This command sends valentine to user if specified or a random user having lovefest role. + Send a valentine to user, if specified, or to a random user with the lovefest role. syntax: .bemyvalentine [user](optional) [p/poem/c/compliment/or you can type your own valentine message] (optional) @@ -119,7 +119,7 @@ class BeMyValentine(commands.Cog): @send_valentine.command(name='secret') async def anonymous(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): """ - This command DMs a valentine to be given anonymous to a user if specified or a random user having lovefest role. + Send an anonymous Valentine via DM to to a user, if specified, or to a random with the lovefest role. **This command should be DMed to the bot.** @@ -171,6 +171,8 @@ class BeMyValentine(commands.Cog): await ctx.author.send(f"Your message has been sent to {user}") 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() @@ -191,12 +193,14 @@ class BeMyValentine(commands.Cog): @staticmethod def random_user(author, members): """ - Picks a random member from the list provided in `members`, ensuring - the author is not one of the options. + Picks a random member from the list provided in `members`. + + The invoking author is ignored. :param author: member who invoked the command :param members: list of discord.Member objects """ + if author in members: members.remove(author) @@ -204,14 +208,15 @@ 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). - """ + """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]) @@ -222,20 +227,20 @@ class BeMyValentine(commands.Cog): return random_valentine, title def valentine_poem(self): - """ - Grabs a random poem. - """ + """Grabs a random poem.""" + valentine_poem = random.choice(self.valentines['valentine_poems']) return valentine_poem def valentine_compliment(self): - """ - Grabs a random compliment. - """ + """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 0662cf5b..cd684f9d 100644 --- a/bot/seasons/valentines/lovecalculator.py +++ b/bot/seasons/valentines/lovecalculator.py @@ -21,9 +21,7 @@ with Path('bot', 'resources', 'valentines', 'love_matches.json').open() as file: class LoveCalculator(Cog): - """ - A cog for calculating the love between two people - """ + """A cog for calculating the love between two people.""" def __init__(self, bot): self.bot = bot @@ -103,5 +101,7 @@ 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 8fce011b..1b1a4a2d 100644 --- a/bot/seasons/valentines/movie_generator.py +++ b/bot/seasons/valentines/movie_generator.py @@ -11,19 +11,16 @@ TMDB_API_KEY = environ.get("TMDB_API_KEY") log = logging.getLogger(__name__) -class RomanceMovieFinder(commands.Cog): - """ - A cog that returns a random romance movie suggestion to a user - """ +class RomanceMovieFinder: + """A cog that returns a random romance movie suggestion to a user.""" def __init__(self, bot): self.bot = bot @commands.command(name="romancemovie") async def romance_movie(self, ctx): - """ - Randomly selects a romance movie and displays information about it - """ + """Randomly selects a romance movie and displays information about it.""" + # selecting a random int to parse it to the page parameter random_page = random.randint(0, 20) # TMDB api params @@ -62,5 +59,7 @@ 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 7d9f3a59..0ea8fbab 100644 --- a/bot/seasons/valentines/myvalenstate.py +++ b/bot/seasons/valentines/myvalenstate.py @@ -15,14 +15,15 @@ with open(Path('bot', 'resources', 'valentines', 'valenstates.json'), 'r') as fi STATES = json.load(file) -class MyValenstate(commands.Cog): +class MyValenstate: + """A Cog to find your most likely Valentine's vacation destination.""" + def __init__(self, bot): self.bot = bot def levenshtein(self, source, goal): - """ - Calculates the Levenshtein Distance between source and goal. - """ + """Calculates the Levenshtein Distance between source and goal.""" + if len(source) < len(goal): return self.levenshtein(goal, source) if len(source) == 0: @@ -43,6 +44,8 @@ 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(' ', '') @@ -81,5 +84,7 @@ 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 e1abb4e5..193eb788 100644 --- a/bot/seasons/valentines/pickuplines.py +++ b/bot/seasons/valentines/pickuplines.py @@ -14,10 +14,8 @@ with open(Path('bot', 'resources', 'valentines', 'pickup_lines.json'), 'r', enco pickup_lines = load(f) -class PickupLine(commands.Cog): - """ - A cog that gives random cheesy pickup lines. - """ +class PickupLine: + """A cog that gives random cheesy pickup lines.""" def __init__(self, bot): self.bot = bot @@ -25,8 +23,11 @@ class PickupLine(commands.Cog): @commands.command() async def pickupline(self, ctx): """ - Gives you a random pickup line. Note that most of them are very cheesy! + Gives you a random pickup line. + + Note that most of them are very cheesy. """ + random_line = random.choice(pickup_lines['lines']) embed = discord.Embed( title=':cheese: Your pickup line :cheese:', @@ -40,5 +41,7 @@ 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 fbc9eb82..76f418a2 100644 --- a/bot/seasons/valentines/savethedate.py +++ b/bot/seasons/valentines/savethedate.py @@ -16,19 +16,16 @@ with open(Path('bot', 'resources', 'valentines', 'date_ideas.json'), 'r', encodi VALENTINES_DATES = load(f) -class SaveTheDate(commands.Cog): - """ - A cog that gives random suggestion, for a valentines date ! - """ +class SaveTheDate: + """A cog that gives random suggestion for a Valentine's date.""" def __init__(self, bot): self.bot = bot @commands.command() async def savethedate(self, ctx): - """ - Gives you ideas for what to do on a date with your valentine. - """ + """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) @@ -41,5 +38,7 @@ 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 33fc739a..764c8ccc 100644 --- a/bot/seasons/valentines/valentine_zodiac.py +++ b/bot/seasons/valentines/valentine_zodiac.py @@ -14,16 +14,17 @@ LETTER_EMOJI = ':love_letter:' HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -class ValentineZodiac(commands.Cog): - """ - A cog that returns a counter compatible zodiac sign to the given user's zodiac sign. - """ +class ValentineZodiac: + """A cog that returns a counter compatible zodiac sign to the given user's zodiac sign.""" + def __init__(self, bot): self.bot = bot self.zodiacs = self.load_json() @staticmethod def load_json(): + """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) @@ -31,9 +32,8 @@ 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. - """ + """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,5 +55,7 @@ class ValentineZodiac(commands.Cog): def setup(bot): + """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 59a13ca3..b7c47121 100644 --- a/bot/seasons/valentines/whoisvalentine.py +++ b/bot/seasons/valentines/whoisvalentine.py @@ -14,15 +14,16 @@ with open(Path("bot", "resources", "valentines", "valentine_facts.json"), "r") a FACTS = json.load(file) -class ValentineFacts(commands.Cog): +class ValentineFacts: + """A Cog for displaying facts about Saint Valentine.""" + def __init__(self, bot): self.bot = bot @commands.command(aliases=('whoisvalentine', 'saint_valentine')) async def who_is_valentine(self, ctx): - """ - Displays info about Saint Valentine. - """ + """Displays info about Saint Valentine.""" + embed = discord.Embed( title="Who is Saint Valentine?", description=FACTS['whois'], @@ -37,9 +38,8 @@ class ValentineFacts(commands.Cog): @commands.command() async def valentine_fact(self, ctx): - """ - Shows a random fact about Valentine's Day. - """ + """Shows a random fact about Valentine's Day.""" + embed = discord.Embed( title=choice(FACTS['titles']), description=choice(FACTS['text']), @@ -50,5 +50,7 @@ class ValentineFacts(commands.Cog): def setup(bot): + """Who is Valentine Cog load.""" + bot.add_cog(ValentineFacts(bot)) log.info("ValentineFacts cog loaded") |