Skip to content

Commit

Permalink
updated logging on event_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Mole1424 committed Oct 9, 2023
1 parent b71b845 commit ab8c502
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cogs/commands/event_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def __init__(self, bot: Bot):

@commands.hybrid_command(help=LONG_HELP_TEXT, brief=SHORT_HELP_TEXT)
@commands.check(is_compsoc_exec_in_guild)
async def event(self, ctx: Context, days: int = 7):
async def event(self, ctx: Context, days: int = 7, logging: bool = False):
now = datetime.datetime.now(timezone("Europe/London"))
# datetime's main module also being called datetime is annoying
before = now + datetime.timedelta(days=days)

await ctx.send(f"Syncing events from {now} to {before}")
Expand All @@ -53,18 +54,20 @@ async def event(self, ctx: Context, days: int = 7):
)
print(ev.get("summary"), t, before)
if t < now:
await ctx.send(
f"Skipping event {ev.get('summary')} as it is in the past"
)
self.log_event(ctx, ev, t, logging, "in the past")
continue
if t > before:
await ctx.send(
f"Breaking at {ev.get('summary')} at time {t} as it is after the sync period"
)
await self.log_event(ctx, ev, t, logging, "outside time frme")
continue
await self.update_event(ctx, ev, links, dc_events)
await ctx.send("Done :)")

async def log_event(self, ctx, ev, t, logging, reason):
if logging:
await ctx.send(
f"Skipping event {ev.get('summary')} at time {t} as it is {reason}"
)

async def update_event(self, ctx, ev, links, dc_events):
"""Check discord events for match, update if existing, otherwise create it"""
event_args = self.ical_event_to_dc_args(ev)
Expand Down

0 comments on commit ab8c502

Please sign in to comment.