aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/__init__.py
diff options
context:
space:
mode:
authorGravatar Eivind Teig <[email protected]>2020-04-02 14:39:24 +0200
committerGravatar GitHub <[email protected]>2020-04-02 14:39:24 +0200
commitd77a2bbc50305d05371197f4cfe3354cfca4c627 (patch)
treebe1eed54972d9843f66114311f93b68b579046ac /bot/utils/__init__.py
parentMerge pull request #382 from ks129/game-fuzzy (diff)
parentMerge master: adjust `Space` cog location (diff)
Merge pull request #329 from python-discord/seasonal-purge
Deseasonify: Make all cogs available year-round, and manage only branding by season.
Diffstat (limited to 'bot/utils/__init__.py')
-rw-r--r--bot/utils/__init__.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py
index 25fd4b96..35ef0a7b 100644
--- a/bot/utils/__init__.py
+++ b/bot/utils/__init__.py
@@ -2,12 +2,32 @@ import asyncio
import contextlib
import re
import string
-from typing import List
+from datetime import datetime
+from typing import Iterable, List
import discord
from discord.ext.commands import BadArgument, Context
-from bot.pagination import LinePaginator
+from bot.constants import Client, Month
+from bot.utils.pagination import LinePaginator
+
+
+def human_months(months: Iterable[Month]) -> str:
+ """Build a comma separated list of `months`."""
+ return ", ".join(str(m) for m in months)
+
+
+def resolve_current_month() -> Month:
+ """
+ Determine current month w.r.t. `Client.month_override` env var.
+
+ If the env variable was set, current month always resolves to the configured value.
+ Otherwise, the current UTC month is given.
+ """
+ if Client.month_override is not None:
+ return Month(Client.month_override)
+ else:
+ return Month(datetime.utcnow().month)
async def disambiguate(