A Discord bot that provides tools for collaboration in CTFs. Inspired by fiskebot
PsyBot adds a number of slash commands for easy and effective CTF management and collaboration:
/ctf create <name> [ctftime_link] [private]: Create a new CTF- Creates a new CTF channel and provides access for team members
/invite <user>: Add a new player to the CTF channels/inviterole <role>: Add all members with a specific role to the CTF channels/remove <user>: Remove a current player - players can leave manually with/leave
- When a CTFtime link is supplied, most CTF information is automatically retrieved
- Manually update info such as team credentials and Discord link with
/ctf update <field> <value>
- Manually update info such as team credentials and Discord link with
- When
privateis set, only the admin running this command will be added to the CTF channels /ctf rename <name>: Rename CTF if needed - very short names recommended to fit in channel list
- Creates a new CTF channel and provides access for team members
/add <category> <name>: Create new challenge- Creates a new channel under
INCOMPLETE CHALLENGES categoryis a selection list, create new with/category create <category>, delete with/category delete <category>
- Creates a new channel under
/note [note_type]: Create challenge note- Lets all team members edit the same embedded note
- Notes can be pinned/unpinned and moved to the bottom of the chat
- Default
note_typeismodal, allows edits within Discord through a modal- Simultaneous changes are merged with diff-match-patch
- Use
note_type:docfor an external HedgeDoc markdown note- NOTE: HedgeDoc has disabled anonymous demo notes, this now requires a custom instance
- Custom HedgeDoc URL can be set with
/psybot set key:hedgedoc_url value:<URL>
/working set <status>: Set working status (/wshort for/working set Working)- Or simply click the
Set Workingbutton in the challenge channel - Get an overview with
/working table
- Or simply click the
/done [contributors]: Mark a challenge as done- Moves the challenge to
COMPLETE CHALLENGESand sends a notification mentioning all contributors - Use
/undoneto move the challenge back if wrongly marked
- Moves the challenge to
/ctf invite: Create a CTF invitation message ininvite_channel.- Requests will be sent to
admin_channelfor an admin to accept.
- Requests will be sent to
/ctf archive: Archive a CTF- Unarchive if needed with
/ctf unarchive
- Unarchive if needed with
/ctf export: Export a CTF- Exports all CTF channels to JSON format, files are not currently exported
- Both running and archived CTFs can be exported
/ctf delete [security]: Delete a CTF- Asks for CTF name as a sanity check if not input as
security
- Asks for CTF name as a sanity check if not input as
/ctftime team [team] [year]: See a team's top 10 CTFs- Defaults to current year and your team
- Set team with
/psybot set key:ctftime_team value:kalmarunionen
/ctftime top [country] [year]: See the top CTFtime teams- Defaults to this year, globally
/ctftime calc <weight> <best_points> <team_points> <team_place> [team]- Use CTFtime's rating formula to compute points for a CTF
- Shows how this would affect your team's total points
First, you need to create a bot on https://discord.com/developers/applications.
Then invite it with the following link, replacing CLIENT_ID with your actual id:
https://discord.com/api/oauth2/authorize?client_id=CLIENT_ID&permissions=8&scope=bot%20applications.commands
Create a .env file like this:
BOT_TOKEN=token
GUILD_ID=optional_guild_id
Create the backups directory
mkdir ./backups
chown +1000:+1000 ./backupsThen run docker-compose up -d
Install dependencies with pip
python3 -m pip install -r requirements.txtInstall MongoDB and set it up.
Set up BOT_TOKEN and optionally GUILD_ID environment variables.
Run the script
./bot.pyThe bot has a number of settings that can be modified to match your server's needs.
Use /psybot info to see all the current value for all settings and /psybot set <key> <value> to modify these.
Only bot admins can view and change settings, this role is created when the bot is run (Team Admin by default) and set as admin_role.
To change settings, you must first give yourself this bot admin role.
Afterward, the admin and team roles can optionally be set to some of your existing server roles and the auto-generated roles can be deleted.
Settings:
team_role: ID of CTF team role, auto-generated by default as@Team Member- By default, all users with this role get access to new CTFs, unless marked with
private:True
- By default, all users with this role get access to new CTFs, unless marked with
admin_role: ID of CTF admin role- Only admins can create, archive, export, and delete CTFs, create and delete categories, and view and modify settings
inactive_role: ID of inactive role- When
use_team_role_as_aclis set to True, team members can temporarily get this role by typing/leave - Users with this role do not have access to CTF channels, but can get the team role at any time by running
/rejoin
- When
ctfs_category: Discord category for created CTFs, defaultCTFSincomplete_category: Discord category for incomplete challenges, defaultINCOMPLETE CHALLENGEScomplete_category: Discord category for complete challenges, defaultCOMPLETE CHALLENGESarchive_category: Discord category for archived challenges, defaultARCHIVEctf_archive_category: Discord category for archived CTF main channels, defaultARCHIVED CTFSvoice_category: Discord category for per-ctf voice channels, defaultVoice Channelsexport_channel: Channel ID for JSON export uploadsinvite_channel: Channel ID for per-ctf invitations. Access requests will be sent toadmin_channel. Optionaladmin_channel: Channel ID for admin-only logs. Required together withinvite_channel. Otherwise, optionalper_ctf_voice_channels: Number of voice channels to create invoice_categorywhen creating a CTF, default 0enforce_categories (default True): Players must choose a category from the existing list- New categories can be created by team admins
- If false, players get the selection options but can type any category they want
- Custom categories are then automatically added to the option list
send_work_message (default True): Send a message in each new challenge channel with a "Set Working" buttonuse_team_role_as_acl (default False): Useteam_roledirectly as access control for public CTFs- If true, team members running
/leavewill be moved to the inactive role - If false, a new role is created per CTF for fine-grained access control
- This role is automatically given to every player with
team_rolefor immediate access - New players can be invited with
/inviteand can manually leave with/leaveor be removed by an admin with/remove
- This role is automatically given to every player with
- The setting has no effect on private CTFs, a new role is always created for these
- But all players must be manually invited, team members do not get the new role automatically
- If true, team members running
invite_admin_only (default False): Only team admins are allowed to invite players to a CTFhedgedoc_url: URL for HedgeDoc notes, defaults to https://demo.hedgedoc.org/- NOTE: The default demo URL no longer works, HedgeDoc has disabled anonymous demo notes
ctftime_team: CTFtime team name, used by default by/ctftimecommands if set