aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Icebluewolf <[email protected]>2021-05-19 17:21:55 -0500
committerGravatar GitHub <[email protected]>2021-05-19 17:21:55 -0500
commit4a7ced4d36c061256fe19b0ee3e8baef3bfc24fe (patch)
treec83c50f3342c1cb6141915c455ce1963e837bf5e
parentremove unnecessary check (diff)
parentMerge pull request #744 from python-discord/remove-superfluous-dependencies (diff)
Merge branch 'main' into http_status_command_randomness
-rw-r--r--bot/exts/christmas/advent_of_code/_cog.py7
-rw-r--r--bot/exts/christmas/advent_of_code/_helpers.py22
-rw-r--r--bot/exts/evergreen/source.py11
-rw-r--r--bot/exts/evergreen/trivia_quiz.py30
-rw-r--r--poetry.lock88
-rw-r--r--pyproject.toml4
6 files changed, 66 insertions, 96 deletions
diff --git a/bot/exts/christmas/advent_of_code/_cog.py b/bot/exts/christmas/advent_of_code/_cog.py
index ead84544..3d61753b 100644
--- a/bot/exts/christmas/advent_of_code/_cog.py
+++ b/bot/exts/christmas/advent_of_code/_cog.py
@@ -3,6 +3,7 @@ import logging
from datetime import datetime, timedelta
from pathlib import Path
+import arrow
import discord
from discord.ext import commands
@@ -100,11 +101,11 @@ class AdventOfCode(commands.Cog):
async def aoc_countdown(self, ctx: commands.Context) -> None:
"""Return time left until next day."""
if not _helpers.is_in_advent():
- datetime_now = datetime.now(_helpers.EST)
+ datetime_now = arrow.now(_helpers.EST)
# Calculate the delta to this & next year's December 1st to see which one is closest and not in the past
- this_year = datetime(datetime_now.year, 12, 1, tzinfo=_helpers.EST)
- next_year = datetime(datetime_now.year + 1, 12, 1, tzinfo=_helpers.EST)
+ this_year = arrow.get(datetime(datetime_now.year, 12, 1), _helpers.EST)
+ next_year = arrow.get(datetime(datetime_now.year + 1, 12, 1), _helpers.EST)
deltas = (dec_first - datetime_now for dec_first in (this_year, next_year))
delta = min(delta for delta in deltas if delta >= timedelta()) # timedelta() gives 0 duration delta
diff --git a/bot/exts/christmas/advent_of_code/_helpers.py b/bot/exts/christmas/advent_of_code/_helpers.py
index f4a258c0..96de90c4 100644
--- a/bot/exts/christmas/advent_of_code/_helpers.py
+++ b/bot/exts/christmas/advent_of_code/_helpers.py
@@ -9,8 +9,8 @@ import typing
from typing import Tuple
import aiohttp
+import arrow
import discord
-import pytz
from bot.bot import Bot
from bot.constants import AdventOfCode, Channels, Colours
@@ -48,7 +48,7 @@ AOC_EMBED_THUMBNAIL = (
)
# Create an easy constant for the EST timezone
-EST = pytz.timezone("EST")
+EST = "America/New_York"
# Step size for the challenge countdown status
COUNTDOWN_STEP = 60 * 5
@@ -395,13 +395,13 @@ def is_in_advent() -> bool:
something for the next Advent of Code challenge should run. As the puzzle
published on the 25th is the last puzzle, this check excludes that date.
"""
- return datetime.datetime.now(EST).day in range(1, 25) and datetime.datetime.now(EST).month == 12
+ return arrow.now(EST).day in range(1, 25) and arrow.now(EST).month == 12
def time_left_to_est_midnight() -> Tuple[datetime.datetime, datetime.timedelta]:
"""Calculate the amount of time left until midnight EST/UTC-5."""
# Change all time properties back to 00:00
- todays_midnight = datetime.datetime.now(EST).replace(
+ todays_midnight = arrow.now(EST).replace(
microsecond=0,
second=0,
minute=0,
@@ -412,7 +412,7 @@ def time_left_to_est_midnight() -> Tuple[datetime.datetime, datetime.timedelta]:
tomorrow = todays_midnight + datetime.timedelta(days=1)
# Calculate the timedelta between the current time and midnight
- return tomorrow, tomorrow - datetime.datetime.now(EST)
+ return tomorrow, tomorrow - arrow.now(EST)
async def wait_for_advent_of_code(*, hours_before: int = 1) -> None:
@@ -430,9 +430,9 @@ async def wait_for_advent_of_code(*, hours_before: int = 1) -> None:
if we're already past the Advent of Code edition the bot is currently
configured for.
"""
- start = datetime.datetime(AdventOfCode.year, 12, 1, 0, 0, 0, tzinfo=EST)
+ start = arrow.get(datetime.datetime(AdventOfCode.year, 12, 1), EST)
target = start - datetime.timedelta(hours=hours_before)
- now = datetime.datetime.now(EST)
+ now = arrow.now(EST)
# If we've already reached or passed to target, we
# simply return immediately.
@@ -474,10 +474,10 @@ async def countdown_status(bot: Bot) -> None:
# sleeping for the entire year, it will only wait in the currently
# configured year. This means that the task will only start hibernating once
# we start preparing the next event by changing environment variables.
- last_challenge = datetime.datetime(AdventOfCode.year, 12, 25, 0, 0, 0, tzinfo=EST)
+ last_challenge = arrow.get(datetime.datetime(AdventOfCode.year, 12, 25), EST)
end = last_challenge + datetime.timedelta(hours=1)
- while datetime.datetime.now(EST) < end:
+ while arrow.now(EST) < end:
_, time_left = time_left_to_est_midnight()
aligned_seconds = int(math.ceil(time_left.seconds / COUNTDOWN_STEP)) * COUNTDOWN_STEP
@@ -534,8 +534,8 @@ async def new_puzzle_notification(bot: Bot) -> None:
# The last event day is 25 December, so we only have to schedule
# a reminder if the current day is before 25 December.
- end = datetime.datetime(AdventOfCode.year, 12, 25, tzinfo=EST)
- while datetime.datetime.now(EST) < end:
+ end = arrow.get(datetime.datetime(AdventOfCode.year, 12, 25), EST)
+ while arrow.now(EST) < end:
log.trace("Started puzzle notification loop.")
tomorrow, time_left = time_left_to_est_midnight()
diff --git a/bot/exts/evergreen/source.py b/bot/exts/evergreen/source.py
index 8fb72143..fc209bc3 100644
--- a/bot/exts/evergreen/source.py
+++ b/bot/exts/evergreen/source.py
@@ -33,7 +33,8 @@ class BotSource(commands.Cog):
Raise BadArgument if `source_item` is a dynamically-created object (e.g. via internal eval).
"""
if isinstance(source_item, commands.Command):
- src = source_item.callback.__code__
+ callback = inspect.unwrap(source_item.callback)
+ src = callback.__code__
filename = src.co_filename
else:
src = type(source_item)
@@ -64,12 +65,8 @@ class BotSource(commands.Cog):
url, location, first_line = self.get_source_link(source_object)
if isinstance(source_object, commands.Command):
- if source_object.cog_name == "Help":
- title = "Help Command"
- description = source_object.__doc__.splitlines()[1]
- else:
- description = source_object.short_doc
- title = f"Command: {source_object.qualified_name}"
+ description = source_object.short_doc
+ title = f"Command: {source_object.qualified_name}"
else:
title = f"Cog: {source_object.qualified_name}"
description = source_object.description.splitlines()[0]
diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/evergreen/trivia_quiz.py
index 419126dc..a8d10afd 100644
--- a/bot/exts/evergreen/trivia_quiz.py
+++ b/bot/exts/evergreen/trivia_quiz.py
@@ -465,22 +465,24 @@ class TriviaQuiz(commands.Cog):
Note: Only mods or the owner of the quiz can stop it.
"""
- if self.game_status[ctx.channel.id] is True:
- # Check if the author is the game starter or a moderator.
- if ctx.author == self.game_owners[ctx.channel.id] or any(
- Roles.moderator == role.id for role in ctx.author.roles
- ):
-
- await ctx.send("Quiz stopped.")
- await self.declare_winner(ctx.channel, self.game_player_scores[ctx.channel.id])
-
- self.game_status[ctx.channel.id] = False
- del self.game_owners[ctx.channel.id]
- self.game_player_scores[ctx.channel.id] = {}
+ try:
+ if self.game_status[ctx.channel.id]:
+ # Check if the author is the game starter or a moderator.
+ if ctx.author == self.game_owners[ctx.channel.id] or any(
+ Roles.moderator == role.id for role in ctx.author.roles
+ ):
+ self.game_status[ctx.channel.id] = False
+ del self.game_owners[ctx.channel.id]
+ self.game_player_scores[ctx.channel.id] = {}
+
+ await ctx.send("Quiz stopped.")
+ await self.declare_winner(ctx.channel, self.game_player_scores[ctx.channel.id])
+ else:
+ await ctx.send(f"{ctx.author.mention}, you are not authorised to stop this game :ghost:!")
else:
- await ctx.send(f"{ctx.author.mention}, you are not authorised to stop this game :ghost:!")
- else:
+ await ctx.send("No quiz running.")
+ except KeyError:
await ctx.send("No quiz running.")
@quiz_game.command(name="leaderboard")
diff --git a/poetry.lock b/poetry.lock
index f70d0328..b6581b1b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -50,11 +50,11 @@ python-versions = "*"
[[package]]
name = "arrow"
-version = "0.17.0"
+version = "1.1.0"
description = "Better dates & times for Python"
category = "main"
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+python-versions = ">=3.6"
[package.dependencies]
python-dateutil = ">=2.7.0"
@@ -97,21 +97,6 @@ tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)"
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins"]
[[package]]
-name = "beautifulsoup4"
-version = "4.9.3"
-description = "Screen-scraping library"
-category = "main"
-optional = false
-python-versions = "*"
-
-[package.dependencies]
-soupsieve = {version = ">1.2", markers = "python_version >= \"3.0\""}
-
-[package.extras]
-html5lib = ["html5lib"]
-lxml = ["lxml"]
-
-[[package]]
name = "certifi"
version = "2020.12.5"
description = "Python package for providing Mozilla's CA Bundle."
@@ -147,6 +132,14 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
+name = "colorama"
+version = "0.4.4"
+description = "Cross-platform colored terminal text."
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[[package]]
name = "cycler"
version = "0.10.0"
description = "Composable style cycles"
@@ -499,7 +492,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "pydocstyle"
-version = "6.0.0"
+version = "6.1.1"
description = "Python docstring style checker"
category = "dev"
optional = false
@@ -508,6 +501,9 @@ python-versions = ">=3.6"
[package.dependencies]
snowballstemmer = "*"
+[package.extras]
+toml = ["toml"]
+
[[package]]
name = "pyflakes"
version = "2.3.1"
@@ -547,14 +543,6 @@ python-versions = "*"
cli = ["click (>=5.0)"]
[[package]]
-name = "pytz"
-version = "2019.3"
-description = "World timezone definitions, modern and historical"
-category = "main"
-optional = false
-python-versions = "*"
-
-[[package]]
name = "pyyaml"
version = "5.4.1"
description = "YAML parser and emitter for Python"
@@ -619,29 +607,22 @@ python-versions = "*"
[[package]]
name = "sortedcontainers"
-version = "2.3.0"
+version = "2.4.0"
description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set"
category = "main"
optional = false
python-versions = "*"
[[package]]
-name = "soupsieve"
-version = "2.2.1"
-description = "A modern CSS selector implementation for Beautiful Soup."
-category = "main"
-optional = false
-python-versions = ">=3.6"
-
-[[package]]
name = "taskipy"
-version = "1.7.0"
+version = "1.8.1"
description = "tasks runner for python projects"
category = "dev"
optional = false
python-versions = ">=3.6,<4.0"
[package.dependencies]
+colorama = ">=0.4.4,<0.5.0"
mslex = ">=0.3.0,<0.4.0"
psutil = ">=5.7.2,<6.0.0"
toml = ">=0.10.0,<0.11.0"
@@ -708,7 +689,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
-content-hash = "d0003b8cc4caac9d6eb0c14e4c4085191907d7fa0803888eddae4259446eada7"
+content-hash = "14c54d898cad74073a3f8f83283be3ea3c32fbb8558149284c1475677b99bd59"
[metadata.files]
aiodns = [
@@ -763,8 +744,8 @@ appdirs = [
{file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"},
]
arrow = [
- {file = "arrow-0.17.0-py2.py3-none-any.whl", hash = "sha256:e098abbd9af3665aea81bdd6c869e93af4feb078e98468dd351c383af187aac5"},
- {file = "arrow-0.17.0.tar.gz", hash = "sha256:ff08d10cda1d36c68657d6ad20d74fbea493d980f8b2d45344e00d6ed2bf6ed4"},
+ {file = "arrow-1.1.0-py3-none-any.whl", hash = "sha256:8cbe6a629b1c54ae11b52d6d9e70890089241958f63bc59467e277e34b7a5378"},
+ {file = "arrow-1.1.0.tar.gz", hash = "sha256:b8fe13abf3517abab315e09350c903902d1447bd311afbc17547ba1cb3ff5bd8"},
]
async-rediscache = [
{file = "async-rediscache-0.1.4.tar.gz", hash = "sha256:6be8a657d724ccbcfb1946d29a80c3478c5f9ecd2f78a0a26d2f4013a622258f"},
@@ -778,11 +759,6 @@ attrs = [
{file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"},
{file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"},
]
-beautifulsoup4 = [
- {file = "beautifulsoup4-4.9.3-py2-none-any.whl", hash = "sha256:4c98143716ef1cb40bf7f39a8e3eec8f8b009509e74904ba3a7b315431577e35"},
- {file = "beautifulsoup4-4.9.3-py3-none-any.whl", hash = "sha256:fff47e031e34ec82bf17e00da8f592fe7de69aeea38be00523c04623c04fb666"},
- {file = "beautifulsoup4-4.9.3.tar.gz", hash = "sha256:84729e322ad1d5b4d25f805bfa05b902dd96450f43842c4e99067d5e1369eb25"},
-]
certifi = [
{file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"},
{file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"},
@@ -834,6 +810,10 @@ chardet = [
{file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"},
{file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"},
]
+colorama = [
+ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
+ {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
+]
cycler = [
{file = "cycler-0.10.0-py2.py3-none-any.whl", hash = "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d"},
{file = "cycler-0.10.0.tar.gz", hash = "sha256:cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8"},
@@ -1197,8 +1177,8 @@ pycparser = [
{file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"},
]
pydocstyle = [
- {file = "pydocstyle-6.0.0-py3-none-any.whl", hash = "sha256:d4449cf16d7e6709f63192146706933c7a334af7c0f083904799ccb851c50f6d"},
- {file = "pydocstyle-6.0.0.tar.gz", hash = "sha256:164befb520d851dbcf0e029681b91f4f599c62c5cd8933fd54b1bfbd50e89e1f"},
+ {file = "pydocstyle-6.1.1-py3-none-any.whl", hash = "sha256:6987826d6775056839940041beef5c08cc7e3d71d63149b48e36727f70144dc4"},
+ {file = "pydocstyle-6.1.1.tar.gz", hash = "sha256:1d41b7c459ba0ee6c345f2eb9ae827cab14a7533a88c5c6f7e94923f72df92dc"},
]
pyflakes = [
{file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"},
@@ -1216,10 +1196,6 @@ python-dotenv = [
{file = "python-dotenv-0.15.0.tar.gz", hash = "sha256:587825ed60b1711daea4832cf37524dfd404325b7db5e25ebe88c495c9f807a0"},
{file = "python_dotenv-0.15.0-py2.py3-none-any.whl", hash = "sha256:0c8d1b80d1a1e91717ea7d526178e3882732420b03f08afea0406db6402e220e"},
]
-pytz = [
- {file = "pytz-2019.3-py2.py3-none-any.whl", hash = "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d"},
- {file = "pytz-2019.3.tar.gz", hash = "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"},
-]
pyyaml = [
{file = "PyYAML-5.4.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:3b2b1824fe7112845700f815ff6a489360226a5609b96ec2190a45e62a9fc922"},
{file = "PyYAML-5.4.1-cp27-cp27m-win32.whl", hash = "sha256:129def1b7c1bf22faffd67b8f3724645203b79d8f4cc81f674654d9902cb4393"},
@@ -1268,16 +1244,12 @@ snowballstemmer = [
{file = "snowballstemmer-2.1.0.tar.gz", hash = "sha256:e997baa4f2e9139951b6f4c631bad912dfd3c792467e2f03d7239464af90e914"},
]
sortedcontainers = [
- {file = "sortedcontainers-2.3.0-py2.py3-none-any.whl", hash = "sha256:37257a32add0a3ee490bb170b599e93095eed89a55da91fa9f48753ea12fd73f"},
- {file = "sortedcontainers-2.3.0.tar.gz", hash = "sha256:59cc937650cf60d677c16775597c89a960658a09cf7c1a668f86e1e4464b10a1"},
-]
-soupsieve = [
- {file = "soupsieve-2.2.1-py3-none-any.whl", hash = "sha256:c2c1c2d44f158cdbddab7824a9af8c4f83c76b1e23e049479aa432feb6c4c23b"},
- {file = "soupsieve-2.2.1.tar.gz", hash = "sha256:052774848f448cf19c7e959adf5566904d525f33a3f8b6ba6f6f8f26ec7de0cc"},
+ {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"},
+ {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"},
]
taskipy = [
- {file = "taskipy-1.7.0-py3-none-any.whl", hash = "sha256:9e284c10898e9dee01a3e72220b94b192b1daa0f560271503a6df1da53d03844"},
- {file = "taskipy-1.7.0.tar.gz", hash = "sha256:960e480b1004971e76454ecd1a0484e640744a30073a1069894a311467f85ed8"},
+ {file = "taskipy-1.8.1-py3-none-any.whl", hash = "sha256:2b98f499966e40175d1f1306a64587f49dfa41b90d0d86c8f28b067cc58d0a56"},
+ {file = "taskipy-1.8.1.tar.gz", hash = "sha256:7a2404125817e45d80e13fa663cae35da6e8ba590230094e815633653e25f98f"},
]
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
diff --git a/pyproject.toml b/pyproject.toml
index 2528511e..de7fb2eb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,11 +8,9 @@ license = "MIT"
[tool.poetry.dependencies]
python = "^3.9"
aiodns = "~=2.0"
-arrow = "~=0.14"
-beautifulsoup4 = "~=4.8"
+arrow = "~=1.1.0"
fuzzywuzzy = "~=0.17"
pillow = "~=8.1"
-pytz = "~=2019.2"
sentry-sdk = "~=0.19"
PyYAML = "~=5.4"
"discord.py" = "~=1.7.2"