aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-08-03 13:33:17 +0200
committerGravatar Leon Sandøy <[email protected]>2020-08-03 13:33:17 +0200
commit134ea0e449005a771c8184189a8d319e5d4b26a0 (patch)
treee43e8525f16a336b28146c5af55e4a700d9d00be
parentMerge pull request #1058 from python-discord/whitelist_system (diff)
Move function params to 4-space indentation.
-rw-r--r--bot/bot.py4
-rw-r--r--bot/cogs/filter_lists.py15
2 files changed, 17 insertions, 2 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 4492feaa9..756449293 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -51,7 +51,7 @@ class Bot(commands.Bot):
self.stats = AsyncStatsClient(self.loop, statsd_url, 8125, prefix="bot")
- async def _cache_filter_list_data(self) -> None:
+ async def cache_filter_list_data(self) -> None:
"""Cache all the data in the FilterList on the site."""
full_cache = await self.api_client.get('bot/filter-lists')
@@ -123,7 +123,7 @@ class Bot(commands.Bot):
self.api_client.recreate(force=True, connector=self._connector)
# Build the FilterList cache
- self.loop.create_task(self._cache_filter_list_data())
+ self.loop.create_task(self.cache_filter_list_data())
def add_cog(self, cog: commands.Cog) -> None:
"""Adds a "cog" to the bot and logs the operation."""
diff --git a/bot/cogs/filter_lists.py b/bot/cogs/filter_lists.py
index 8aa5a0a08..6249774bb 100644
--- a/bot/cogs/filter_lists.py
+++ b/bot/cogs/filter_lists.py
@@ -168,6 +168,11 @@ class FilterLists(Cog):
await ctx.send(embed=embed)
await ctx.message.add_reaction("❌")
+ async def _sync_data(self) -> None:
+ """Syncs the filterlists with the API."""
+ log.trace("Synchronizing FilterList cache with data from the API.")
+ await self.bot.cache_filter_list_data()
+
@staticmethod
async def _validate_guild_invite(ctx: Context, invite: str) -> dict:
"""
@@ -240,6 +245,16 @@ class FilterLists(Cog):
"""Get the contents of a specified denylist."""
await self._list_all_data(ctx, False, list_type)
+ @whitelist.command(name="sync", aliases=("s",))
+ async def allow_sync(self, _: Context) -> None:
+ """Syncs both allowlists and denylists with the API."""
+ await self._sync_data()
+
+ @blacklist.command(name="sync", aliases=("s",))
+ async def deny_sync(self, _: Context) -> None:
+ """Syncs both allowlists and denylists with the API."""
+ await self._sync_data()
+
def cog_check(self, ctx: Context) -> bool:
"""Only allow moderators to invoke the commands in this cog."""
return with_role_check(ctx, *constants.MODERATION_ROLES)