~robin_jadoul/organizers-bot

Small fix from #10
Merge pull request #8 from 0rganizers/feature/stats

Add stats command
16700d0c — Victor 9 months ago
Bump some dependencies
ebad5e66 — Victor 9 months ago
Enable ctfnote registration even without active ctf
dd8ef638 — Leonardo Galli 1 year, 5 months ago
Add stats command (only semi tested lol)
8c038895 — Matteo Rizzo 1 year, 10 months ago
Don't recreate the S3 client for every file
7aa82e44 — Matteo Rizzo 1 year, 10 months ago
Don't use a persistent client for S3 (fixes broken exports)
Replace datetime with dateutil for isostring parsing of datetime.

I tested my changes, had a few typos but now everything seems to run solidly. However, I got this
```
RROR:discord_slash:An exception has occurred while executing command `chal`:
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/organizers-bot-9TtSrW0h-py3.9/lib/python3.9/site-packages/discord_slash/client.py", line 872, in invoke_command
    await func.invoke(ctx, args)
  File "/root/.cache/pypoetry/virtualenvs/organizers-bot-9TtSrW0h-py3.9/lib/python3.9/site-packages/discord_slash/model.py", line 168, in invoke
    return await coro
  File "/app/organizers_bot/bot.py", line 31, in wrapper
    return await f(ctx, *args, **kw)
  File "/app/organizers_bot/bot.py", line 88, in create_challenge_channel
    await ctfnote.add_task(ctx, created, challenge, category, solved_prefix = "✓-", ctfid = ctfid)
  File "/app/organizers_bot/ctfnote.py", line 592, in add_task
    current_ctf = await refresh_ctf(ctx, ctfid = ctfid)
  File "/app/organizers_bot/ctfnote.py", line 516, in refresh_ctf
    current_ctfs = await ctfnote.getActiveCtfs()
  File "/app/organizers_bot/ctfnote.py", line 438, in getActiveCtfs
    ctfs = list(filter(lambda ctf:
  File "/app/organizers_bot/ctfnote.py", line 439, in <lambda>
    datetime.fromisoformat(ctf["startTime"]) < now and
ValueError: Invalid isoformat string: '2022-07-04T17:44:11.17+00:00'

```
and I'm not sure why that would happen. Because the string looks to me like it matches the format they specify in https://docs.python.org/3.9/library/datetime.html#datetime.datetime.fromisoformat

But the docs say
> A more full-featured ISO 8601 parser, dateutil.parser.isoparse is available in the third-party package dateutil.
So I'm replacing that code with this.
Fix Typos. Tested:

assigning player to chall creates ctfnote account if not yet exists. If exists, no creation happens. The creation message is now hidden if the user assigned themselves - so only they see it.

Spaces, Dashes, Caps, in challenge names used to be a problem because discord channels don't have these. So the channel name does not map directly to the ctfnote name. Fixed by saving the ctfnote ctfid in the pinned message and using that as an identifier instead.

When there is exactly one current ctf, it is used (if there is no pinned message or optional argument overriding that choice). When there are multiple, none are used and the fixup command has to be used with the optional argument.

Users can now register themselves on ctfnote with a command and get a hidden response. The password can be specified or autogenerated. Both code paths tested.
untested: a command to register more easily to ctfnote - no more preshared secret required for people with the CTFPlayer role
Hide password of created ctfnote account when a user assigns himself
Hopefully, this fixes the issue that some challenges were not found with /solved and /assign.

We now use the pinned message to retrieve the challenge id instead of filtering by name and hoping the channel name matches the ctfnote task name.
Hopefully, this fixes the issue we had that the bot did not automatically choose the only active CTF
better messages
minor description improvement
the Fixup command
this is working pretty robustly
that's enough for today
upgrade dependencies

this fixes the command-double-called bug.

also, importing a ctftime ctf is almost working... I am just not receiving the query reply like I want to
change a few interactions to be clearer / less clutter
Next