diff options
31 files changed, 113 insertions, 100 deletions
@@ -113,5 +113,5 @@ venv.bak/ .idea/ .DS_Store -# vscode +# vscode .vscode/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86035786..be57904e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,25 @@ repos: -- repo: local + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 hooks: - - id: flake8 + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.5.1 + hooks: + - id: python-check-blanket-noqa + - repo: local + hooks: + - id: flake8 name: Flake8 description: This hook runs flake8 within our project's pipenv environment. - entry: pipenv run lint + entry: pipenv run flake8 language: python types: [python] - require_serial: true
\ No newline at end of file + require_serial: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd0c048f..ced5df70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ Seasonalbot utilizes [Pipenv](https://pipenv.readthedocs.io/en/latest/) for inst When pulling down changes from GitHub, remember to sync your environment using `pipenv sync --dev` to ensure you're using the most up-to-date versions the project's dependencies. ### Type Hinting -[PEP 484](https://www.python.org/dev/peps/pep-0484/) formally specifies type hints for Python functions, added to the Python Standard Library in version 3.5. Type hints are recognized by most modern code editing tools and provide useful insight into both the input and output types of a function, preventing the user from having to go through the codebase to determine these types. +[PEP 484](https://www.python.org/dev/peps/pep-0484/) formally specifies type hints for Python functions, added to the Python Standard Library in version 3.5. Type hints are recognized by most modern code editing tools and provide useful insight into both the input and output types of a function, preventing the user from having to go through the codebase to determine these types. For example: @@ -86,7 +86,7 @@ def foo(bar: int, baz: dict=None) -> bool: Does some things with some stuff. This function takes an index, `bar` and checks for its presence in the database `baz`, passed as a dictionary. - + Returns `False` if `baz` is not passed. """ ``` @@ -29,5 +29,5 @@ python_version = "3.7" [scripts] start = "python -m bot" -lint = "flake8 bot" +lint = "pre-commit run --all-files" precommit = "pre-commit install" @@ -1,4 +1,4 @@ -# SeasonalBot +# SeasonalBot [)](https://dev.azure.com/python-discord/Python%20Discord/_build/latest?definitionId=3) [](https://discord.gg/2B963hn) diff --git a/bot/resources/advent_of_code/about.json b/bot/resources/advent_of_code/about.json index b1d16a93..91ae6813 100644 --- a/bot/resources/advent_of_code/about.json +++ b/bot/resources/advent_of_code/about.json @@ -24,4 +24,4 @@ "value": "In addition to the global leaderboard, AoC also offers private leaderboards, where you can compete against a smaller group of friends!\n\nGet the join code using `.aoc join` and head over to AoC's [private leaderboard page](https://adventofcode.com/leaderboard/private) to join the PyDis private leaderboard!", "inline": false } -]
\ No newline at end of file +] diff --git a/bot/resources/easter/april_fools_vids.json b/bot/resources/easter/april_fools_vids.json index dfc01b7b..5f0ba06e 100644 --- a/bot/resources/easter/april_fools_vids.json +++ b/bot/resources/easter/april_fools_vids.json @@ -122,4 +122,4 @@ } ] -}
\ No newline at end of file +} diff --git a/bot/resources/evergreen/game_recs/chrono_trigger.json b/bot/resources/evergreen/game_recs/chrono_trigger.json index 219c1e78..9720b977 100644 --- a/bot/resources/evergreen/game_recs/chrono_trigger.json +++ b/bot/resources/evergreen/game_recs/chrono_trigger.json @@ -4,4 +4,4 @@ "link": "https://rawg.io/games/chrono-trigger-1995", "image": "https://vignette.wikia.nocookie.net/chrono/images/2/24/Chrono_Trigger_cover.jpg", "author": "352635617709916161" -}
\ No newline at end of file +} diff --git a/bot/resources/evergreen/game_recs/digimon_world.json b/bot/resources/evergreen/game_recs/digimon_world.json index a2820f8e..c1cb4f37 100644 --- a/bot/resources/evergreen/game_recs/digimon_world.json +++ b/bot/resources/evergreen/game_recs/digimon_world.json @@ -4,4 +4,4 @@ "image": "https://www.mobygames.com/images/covers/l/437308-digimon-world-playstation-front-cover.jpg", "link": "https://rawg.io/games/digimon-world", "author": "352635617709916161" -}
\ No newline at end of file +} diff --git a/bot/resources/evergreen/game_recs/doom_2.json b/bot/resources/evergreen/game_recs/doom_2.json index e228e2b1..b60cc05f 100644 --- a/bot/resources/evergreen/game_recs/doom_2.json +++ b/bot/resources/evergreen/game_recs/doom_2.json @@ -4,4 +4,4 @@ "image": "https://upload.wikimedia.org/wikipedia/en/thumb/2/29/Doom_II_-_Hell_on_Earth_Coverart.png/220px-Doom_II_-_Hell_on_Earth_Coverart.png", "link": "https://rawg.io/games/doom-ii", "author": "352635617709916161" -}
\ No newline at end of file +} diff --git a/bot/resources/evergreen/game_recs/skyrim.json b/bot/resources/evergreen/game_recs/skyrim.json index 09f93563..ad86db31 100644 --- a/bot/resources/evergreen/game_recs/skyrim.json +++ b/bot/resources/evergreen/game_recs/skyrim.json @@ -4,4 +4,4 @@ "image": "https://upload.wikimedia.org/wikipedia/en/1/15/The_Elder_Scrolls_V_Skyrim_cover.png", "link": "https://rawg.io/games/the-elder-scrolls-v-skyrim", "author": "352635617709916161" -}
\ No newline at end of file +} diff --git a/bot/resources/evergreen/magic8ball.json b/bot/resources/evergreen/magic8ball.json index 6fe86950..f5f1df62 100644 --- a/bot/resources/evergreen/magic8ball.json +++ b/bot/resources/evergreen/magic8ball.json @@ -19,4 +19,4 @@ "My sources say no", "Outlook not so good", "Very doubtful" -]
\ No newline at end of file +] diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index 48ee2ce4..6100ca62 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -29,7 +29,7 @@ "hints": ["The game was released in 1990.", "It was released on the SNES."], "question": "What was the first game Yoshi appeared in?", "answer": "Super Mario World" - } + } ], "general":[ { diff --git a/bot/resources/halloween/candy_collection.json b/bot/resources/halloween/candy_collection.json index bebcd4fc..9aa78a5f 100644 --- a/bot/resources/halloween/candy_collection.json +++ b/bot/resources/halloween/candy_collection.json @@ -1 +1 @@ -{"msg_reacted": [{"reaction": "\ud83c\udf6c", "msg_id": 514442189359546375, "won": true, "user_reacted": 95872159741644800}, {"reaction": "\ud83c\udf6c", "msg_id": 514442502460276740, "won": true, "user_reacted": 178876748224659457}], "records": [{"userid": 95872159741644800, "record": 1}, {"userid": 178876748224659457, "record": 1}]}
\ No newline at end of file +{"msg_reacted": [{"reaction": "\ud83c\udf6c", "msg_id": 514442189359546375, "won": true, "user_reacted": 95872159741644800}, {"reaction": "\ud83c\udf6c", "msg_id": 514442502460276740, "won": true, "user_reacted": 178876748224659457}], "records": [{"userid": 95872159741644800, "record": 1}, {"userid": 178876748224659457, "record": 1}]} diff --git a/bot/resources/halloween/halloweenify.json b/bot/resources/halloween/halloweenify.json index 88c46bfc..af9204b2 100644 --- a/bot/resources/halloween/halloweenify.json +++ b/bot/resources/halloween/halloweenify.json @@ -79,4 +79,4 @@ "Pale Man": "https://i2.wp.com/macguff.in/wp-content/uploads/2016/10/Pans-Labyrinth-Movie-Header-Image.jpg?fit=630%2C400&ssl=1" } ] -}
\ No newline at end of file +} diff --git a/bot/resources/halloween/spooky_rating.json b/bot/resources/halloween/spooky_rating.json index 1815befc..d9c8dcb7 100644 --- a/bot/resources/halloween/spooky_rating.json +++ b/bot/resources/halloween/spooky_rating.json @@ -44,4 +44,4 @@ "text": "You are the evillest creature in existence to scare anyone and everyone humanly possible. The reason your underlings are called mortals is that they die. With your help, they die a lot quicker. With all the evil power in the universe, you know what to do.", "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/devil.jpeg" } -}
\ No newline at end of file +} diff --git a/bot/resources/pride/anthems.json b/bot/resources/pride/anthems.json index d80d7558..fd8e8b92 100644 --- a/bot/resources/pride/anthems.json +++ b/bot/resources/pride/anthems.json @@ -452,4 +452,4 @@ "pop" ] } -]
\ No newline at end of file +] diff --git a/bot/resources/pride/drag_queen_names.json b/bot/resources/pride/drag_queen_names.json index f63cdec3..023dff36 100644 --- a/bot/resources/pride/drag_queen_names.json +++ b/bot/resources/pride/drag_queen_names.json @@ -246,4 +246,4 @@ "Vivian Foxx", "Vye Vacius", "Zahara Dessert" -]
\ No newline at end of file +] diff --git a/bot/resources/pride/facts.json b/bot/resources/pride/facts.json index f6597201..2151f5ca 100644 --- a/bot/resources/pride/facts.json +++ b/bot/resources/pride/facts.json @@ -31,4 +31,4 @@ "As of 2019-10-02, there are 17 states in the United States of America where queer people can be fired for being queer. In most other states, there is minimal protection offered, often only for public employees.", "In 1985, an official Star Trek novel was published with scenes depicting Kirk and Spock as lovers. These parts were largely removed, which made the original into a collector's item." ] -}
\ No newline at end of file +} diff --git a/bot/resources/snakes/snake_idioms.json b/bot/resources/snakes/snake_idioms.json index 37148c42..ecbeb6ff 100644 --- a/bot/resources/snakes/snake_idioms.json +++ b/bot/resources/snakes/snake_idioms.json @@ -272,4 +272,4 @@ { "idiom": "photosnek" } -]
\ No newline at end of file +] diff --git a/bot/resources/snakes/snake_names.json b/bot/resources/snakes/snake_names.json index 8ba9dbd7..25832550 100644 --- a/bot/resources/snakes/snake_names.json +++ b/bot/resources/snakes/snake_names.json @@ -2167,4 +2167,4 @@ "name": "Titanboa", "scientific": "Titanoboa" } -]
\ No newline at end of file +] diff --git a/bot/resources/snakes/special_snakes.json b/bot/resources/snakes/special_snakes.json index 8159f914..46214f66 100644 --- a/bot/resources/snakes/special_snakes.json +++ b/bot/resources/snakes/special_snakes.json @@ -13,4 +13,4 @@ "https://img.thrfun.com/img/080/349/spaghetti_dinner_l1.jpg" ] } -]
\ No newline at end of file +] diff --git a/bot/resources/valentines/date_ideas.json b/bot/resources/valentines/date_ideas.json index 09d31067..995f14bb 100644 --- a/bot/resources/valentines/date_ideas.json +++ b/bot/resources/valentines/date_ideas.json @@ -123,5 +123,3 @@ } ] } - - diff --git a/bot/resources/valentines/love_matches.json b/bot/resources/valentines/love_matches.json index 8d50cd79..7df2dbda 100644 --- a/bot/resources/valentines/love_matches.json +++ b/bot/resources/valentines/love_matches.json @@ -55,4 +55,4 @@ ], "text": "You two will most likely have the perfect relationship. But don't think that this means you don't have to do anything for it to work. Talking to each other and spending time together is key, even in a seemingly perfect relationship." } -}
\ No newline at end of file +} diff --git a/bot/resources/valentines/pickup_lines.json b/bot/resources/valentines/pickup_lines.json index a18d0840..eb01290f 100644 --- a/bot/resources/valentines/pickup_lines.json +++ b/bot/resources/valentines/pickup_lines.json @@ -94,4 +94,4 @@ "image": "https://upload.wikimedia.org/wikipedia/en/thumb/0/0c/The_Genie_Aladdin.png/220px-The_Genie_Aladdin.png" } ] -}
\ No newline at end of file +} diff --git a/bot/resources/valentines/valenstates.json b/bot/resources/valentines/valenstates.json index 06cbb2e5..c58a5b7c 100644 --- a/bot/resources/valentines/valenstates.json +++ b/bot/resources/valentines/valenstates.json @@ -119,4 +119,4 @@ "text": "", "flag": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Flag_of_Wales_%281959%E2%80%93present%29.svg/1920px-Flag_of_Wales_%281959%E2%80%93present%29.svg.png" } -}
\ No newline at end of file +} diff --git a/bot/resources/valentines/valentine_facts.json b/bot/resources/valentines/valentine_facts.json index d2ffa980..e6f826c3 100644 --- a/bot/resources/valentines/valentine_facts.json +++ b/bot/resources/valentines/valentine_facts.json @@ -21,4 +21,4 @@ "There's a form of cryptological communication called 'Floriography', in which you communicate through flowers. Meaning has been attributed to flowers for thousands of years, and some form of floriography has been practiced in traditional cultures throughout Europe, Asia, and Africa. Here are some meanings for roses you might want to take a look at, if you plan on gifting your loved one a bouquet of roses on Valentine's Day:\n\u200b\nRed: eternal love\nPink: young, developing love\nWhite: innocence, fervor, loyalty\nOrange: happiness, security\nViolet: love at first sight\nBlue: unfulfilled longing, quiet desire\nYellow: friendship, jealousy, envy, infidelity\nBlack: unfulfilled longing, quiet desire, grief, hatred, misfortune, death", "Traditionally, young girls in the U.S. and the U.K. believed they could tell what type of man they would marry depending on the type of bird they saw first on Valentine's Day. If they saw a blackbird, they would marry a clergyman, a robin redbreast indicated a sailor, and a goldfinch indicated a rich man. A sparrow meant they would marry a farmer, a bluebird indicated a happy man, and a crossbill meant an argumentative man. If they saw a dove, they would marry a good man, but seeing a woodpecker meant they would not marry at all." ] -}
\ No newline at end of file +} diff --git a/bot/resources/valentines/zodiac_compatibility.json b/bot/resources/valentines/zodiac_compatibility.json index 4e337714..3971d40d 100644 --- a/bot/resources/valentines/zodiac_compatibility.json +++ b/bot/resources/valentines/zodiac_compatibility.json @@ -259,4 +259,4 @@ } ] -}
\ No newline at end of file +} diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index f2ec83df..8caf43bd 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -364,7 +364,7 @@ class AdventOfCode(commands.Cog): aoc_embed.set_footer(text="Last Updated") await ctx.send( - content=f"Here's the current global Top {number_of_people_to_display}! {Emojis.christmas_tree*3}\n\n{table}", # noqa + f"Here's the current global Top {number_of_people_to_display}! {Emojis.christmas_tree*3}\n\n{table}", embed=aoc_embed, ) diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 7bdd362c..bd7d5c11 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -1,65 +1,65 @@ -import logging
-import random
-
-import discord
-from discord.ext import commands
-
-from bot.constants import Colours, ERROR_REPLIES, Emojis, bookmark_icon_url
-
-log = logging.getLogger(__name__)
-
-
-class Bookmark(commands.Cog):
- """Creates personal bookmarks by relaying a message link to the user's DMs."""
-
- def __init__(self, bot: commands.Bot):
- self.bot = bot
-
- @commands.command(name="bookmark", aliases=("bm", "pin"))
- async def bookmark(
- self,
- ctx: commands.Context,
- target_message: discord.Message,
- *,
- title: str = "Bookmark"
- ) -> None:
- """Send the author a link to `target_message` via DMs."""
- # Prevent users from bookmarking a message in a channel they don't have access to
- permissions = ctx.author.permissions_in(target_message.channel)
- if not permissions.read_messages:
- log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions")
- embed = discord.Embed(
- title=random.choice(ERROR_REPLIES),
- color=Colours.soft_red,
- description="You don't have permission to view this channel."
- )
- await ctx.send(embed=embed)
- return
-
- embed = discord.Embed(
- title=title,
- colour=Colours.soft_green,
- description=target_message.content
- )
- embed.add_field(name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})")
- embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url)
- embed.set_thumbnail(url=bookmark_icon_url)
-
- try:
- await ctx.author.send(embed=embed)
- except discord.Forbidden:
- error_embed = discord.Embed(
- title=random.choice(ERROR_REPLIES),
- description=f"{ctx.author.mention}, please enable your DMs to receive the bookmark",
- colour=Colours.soft_red
- )
- await ctx.send(embed=error_embed)
- else:
- log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'")
- await ctx.message.add_reaction(Emojis.envelope)
-
-
-def setup(bot: commands.Bot) -> None:
- """Load the Bookmark cog."""
- bot.add_cog(Bookmark(bot))
- log.info("Bookmark cog loaded")
+import logging +import random + +import discord +from discord.ext import commands + +from bot.constants import Colours, ERROR_REPLIES, Emojis, bookmark_icon_url + +log = logging.getLogger(__name__) + + +class Bookmark(commands.Cog): + """Creates personal bookmarks by relaying a message link to the user's DMs.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(name="bookmark", aliases=("bm", "pin")) + async def bookmark( + self, + ctx: commands.Context, + target_message: discord.Message, + *, + title: str = "Bookmark" + ) -> None: + """Send the author a link to `target_message` via DMs.""" + # Prevent users from bookmarking a message in a channel they don't have access to + permissions = ctx.author.permissions_in(target_message.channel) + if not permissions.read_messages: + log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions") + embed = discord.Embed( + title=random.choice(ERROR_REPLIES), + color=Colours.soft_red, + description="You don't have permission to view this channel." + ) + await ctx.send(embed=embed) + return + + embed = discord.Embed( + title=title, + colour=Colours.soft_green, + description=target_message.content + ) + embed.add_field(name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})") + embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url) + embed.set_thumbnail(url=bookmark_icon_url) + + try: + await ctx.author.send(embed=embed) + except discord.Forbidden: + error_embed = discord.Embed( + title=random.choice(ERROR_REPLIES), + description=f"{ctx.author.mention}, please enable your DMs to receive the bookmark", + colour=Colours.soft_red + ) + await ctx.send(embed=error_embed) + else: + log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") + await ctx.message.add_reaction(Emojis.envelope) + + +def setup(bot: commands.Bot) -> None: + """Load the Bookmark cog.""" + bot.add_cog(Bookmark(bot)) + log.info("Bookmark cog loaded") diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py index fbadb7cc..d61e048b 100644 --- a/bot/seasons/halloween/hacktoberstats.py +++ b/bot/seasons/halloween/hacktoberstats.py @@ -334,7 +334,7 @@ class HacktoberStats(commands.Cog): return author_id, author_mention -def setup(bot): # Noqa +def setup(bot: commands.Bot) -> None: """Hacktoberstats Cog load.""" bot.add_cog(HacktoberStats(bot)) log.info("HacktoberStats cog loaded") |