aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-01-01 22:30:54 +0100
committerGravatar Johannes Christ <[email protected]>2019-01-01 22:30:54 +0100
commitabe2f0db3619f332bc6e0f817dcaffaecf10da0a (patch)
treeaffeeb0f0baf9d78adeb1df1c5e3f10ad7e67c70
parentFix another merge conflict that was leftover. (diff)
Factor out sync cog to package.
-rw-r--r--bot/cogs/sync/__init__.py10
-rw-r--r--bot/cogs/sync/cog.py29
-rw-r--r--bot/cogs/sync/syncers.py (renamed from bot/cogs/sync.py)33
3 files changed, 42 insertions, 30 deletions
diff --git a/bot/cogs/sync/__init__.py b/bot/cogs/sync/__init__.py
new file mode 100644
index 000000000..e4f960620
--- /dev/null
+++ b/bot/cogs/sync/__init__.py
@@ -0,0 +1,10 @@
+import logging
+
+from .cog import Sync
+
+log = logging.getLogger(__name__)
+
+
+def setup(bot):
+ bot.add_cog(Sync(bot))
+ log.info("Cog loaded: Sync")
diff --git a/bot/cogs/sync/cog.py b/bot/cogs/sync/cog.py
new file mode 100644
index 000000000..8ef45aa50
--- /dev/null
+++ b/bot/cogs/sync/cog.py
@@ -0,0 +1,29 @@
+from typing import Callable, Iterable
+
+from discord import Guild
+from discord.ext.commands import Bot
+
+from . import syncers
+
+
+class Sync:
+ """Captures relevant events and sends them to the site."""
+
+ # The server to synchronize events on.
+ # Note that setting this wrongly will result in things getting deleted
+ # that possibly shouldn't be.
+ SYNC_SERVER_ID = 267624335836053506
+
+ # An iterable of callables that are called when the bot is ready.
+ ON_READY_SYNCERS: Iterable[Callable[[Bot, Guild], None]] = (
+ syncers.sync_roles,
+ )
+
+ def __init__(self, bot):
+ self.bot = bot
+
+ async def on_ready(self):
+ guild = self.bot.get_guild(self.SYNC_SERVER_ID)
+ if guild is not None:
+ for syncer in self.ON_READY_SYNCERS:
+ await syncer(self.bot, guild)
diff --git a/bot/cogs/sync.py b/bot/cogs/sync/syncers.py
index cccaa7d28..e1e51aea0 100644
--- a/bot/cogs/sync.py
+++ b/bot/cogs/sync/syncers.py
@@ -1,11 +1,9 @@
import logging
from collections import namedtuple
-from typing import Callable, Iterable
-from discord import Guild, Role
+from discord import Guild
from discord.ext.commands import Bot
-
log = logging.getLogger(__name__)
Role = namedtuple('Role', ('id', 'name', 'colour', 'permissions'))
@@ -56,31 +54,6 @@ async def sync_members(bot: Bot, guild: Guild):
"""
current_members = await bot.api_client.get('bot/members')
+ site_members = {
+ }
-
-class Sync:
- """Captures relevant events and sends them to the site."""
-
- # The server to synchronize events on.
- # Note that setting this wrongly will result in things getting deleted
- # that possibly shouldn't be.
- SYNC_SERVER_ID = 267624335836053506
-
- # An iterable of callables that are called when the bot is ready.
- ON_READY_SYNCERS: Iterable[Callable[[Bot, Guild], None]] = (
- sync_roles,
- )
-
- def __init__(self, bot):
- self.bot = bot
-
- async def on_ready(self):
- guild = self.bot.get_guild(self.SYNC_SERVER_ID)
- if guild is not None:
- for syncer in self.ON_READY_SYNCERS:
- await syncer(self.bot, guild)
-
-
-def setup(bot):
- bot.add_cog(Sync(bot))
- log.info("Cog loaded: Sync")