diff --git a/README.org b/README.org new file mode 100644 index 0000000..7eba344 --- /dev/null +++ b/README.org @@ -0,0 +1,190 @@ +* Squad Whitelist Management + + +** Discord Bot + + +*** Commands + + - */link* + - Example: ~/link 7312312312395~ + - Links user's discord ID with their provided steam64 + - If linked to another discord id, reject + - Use the user's discord username for their username in the API + + - */group-link* + - Example: ~/group-link @Odin {group-uuid}~ + - Links a Group on the API with a given discord ID for the role + - If the Discord ID already exists, inform about it but allow + + - */list-groups* + - Example: ~/list-groups~ + - Outputs: + - Groups with Associated Discord Role + - Example: ~@Odin | https://my-api.com/org/asgard/group-uuid~ + +*** Events + + - ~on-member-update~ + - For each member, look at the change in discord roles + - If they had a role added to them that's a linked group, add them to the Group + - If they don't have a linked Steam64, ping them in a channel to do so + + - ~on-startup~ + - Hit up API for all members of linked roles + - Check if the members are in those roles and modify as needed + +** API + + +*** Functionality + + +**** Generate Remote Admin List + + - Capability to export as remote admin list + - Can be applied to an entire Org + - Example: ~https://api-url.com/org/asgard?reserved~ + - Example: ~https://api-url.com/group/group-uuid?startvote&changemap&pause~ + - Query params + - startvote + - changemap + - pause + - cheat + - private + - balance + - chat + - kick + - ban + - config + - cameraman + - immune + - manageserver + - featuretest + - reserve + - demos + - clientdemos + - debug + - teamchange + - forceteamchange + - canseeadminchat + + - Example: + - Query: ~https://api-url.com/org/{org-name}/{group-uuid}~ + - Output: ~Group={group-uuid}:{query-params} // {group-name}~ + +** Data + + +*** Users + + - Table Name: ~USERS~ + | Key | Type | Constraints | Description | + |============|=============|=============|=========================================================================| + | id | Primary Key | | Steam64 | + | username | String | | | + | password | String? | | Salted Hash, don't allow login if null. Owning tenant can set Password. | + | discord_id | Int? | | | + | superuser | bool | | | + +*** Organizations + + - Table Name: ~ORGS~ + | Key | Type | Constraints | Description | + |===================|============|=============|=============| + | id | UUID4 | | | + | name | String | Unique | | + | owner_id | ~USERS.ID~ | | | + | discord_server_id | Int? | | | + +*** Group Members + + - Table Name: ~GROUP_MEMBERS~ + | Key | Type | Constraints | Description | + |====================|=======================|=============|================================================================| + | user | ~ORG_MEMBERS.user_id~ | | | + | org_id | ~ORGS.ID~ | | | + | group | ~GROUPS.ID~ | | | + | nick_name | String | | | + | member | bool | | | + | owner | bool | | | + | perm_manage_mods | bool | | | + | perm_manage_perms | bool | | | + | perm_manage_users | bool | | | + | perm_manage_tags | bool | | | + | perm_manage_import | bool | | Allow user to specify a remote admin list to use for the Group | + +*** Group Squad Perms + + - Table Name: ~GROUP_SQUAD_PERMS~ + | Key | Type | Constraints | Description | + |======================|============|=============|====================================================================================| + | group_id | ~GROUP.ID~ | Primary Key | | + | perm_changemap | bool | | Allowed to change the current map | + | perm_pause | bool | | Allowed to pause server gameplay | + | perm_cheat | bool | | Allowed to use server cheat commands | + | perm_private | bool | | Allowed to password protect the server | + | perm_balance | bool | | Allowed to ignore team balance | + | perm_chat | bool | | Allowed to access admin chat and make server broadcasts | + | perm_kick | bool | | Allowed to kick players | + | perm_ban | bool | | Allowed to ban players | + | perm_config | bool | | Allowed to change server config | + | perm_cameraman | bool | | Allowed to admin spectate mode | + | perm_immune | bool | | Allowed to cannot be kicked / banned | + | perm_manageserver | bool | | Allowed to shutdown server | + | perm_featuretest | bool | | Allowed to any features added for testing by dev team | + | perm_reserve | bool | | Allowed to reserve slot | + | perm_demos | bool | | Allowed to record Demos on the server side via admin commands | + | perm_clientdemos | bool | | Allowed to record Demos on the client side via commands or the replay UI | + | perm_debug | bool | | Allowed to Show admin stats command and other debugging info | + | perm_teamchange | bool | | Allowed to no timer limits on team change | + | perm_forceteamchange | bool | | Allowed to can issue the ForceTeamChange command | + | perm_canseeadminchat | bool | | Allowed to this group can see the admin chat and teamkill/admin-join notifications | + +*** TAGS + + - Table Name: ~TAGS~ + | Key | Type | Constraints | Description | + |========|==========|============================================|=============| + | id | UUID4 | Primary Key | | + | name | String | Must be unique when combined with ~org_id~ | | + | org_id | ~ORG.ID~ | Must be unique when combined with ~name~ | | + + - Both ~Org~ & ~Name~ together must be unique, the combo of them is unique + +*** Group Tags + + - Table Name: ~GROUP_TAGS~ + | Key | Type | Constraints | Description | + |==========|============|===========================================|=============| + | id | UUID4 | Primary Key | | + | group_id | ~GROUP.ID~ | Must be unique when combined with ~tag~ | | + | tag_id | ~TAGS.ID~ | Must be unique when combined with ~group~ | | + + - Together both ~GROUP~ & ~TAG~ create primary key + - ~SELECT * FROM GROUP_TAGS WHERE GROUP = "GROUP.ID" AND TAG = "TAG.ID"~ + + - Org + - Single Owner + - Groups + - Group: whitelist-{group-id} + - Tags: vanilla + - Single Owner + - Perms + - Group + - Manage Users (Add or Remove Users) + - Manage Moderators (Allow other users to manage the group) + - Manage Remote Import (Allowed to set a remote import) + - Manage Tags (Allowed to manage tags) + - Squad + - Reserve + - Demos + - Kick + - Ban + - Etc. + + - Accessing URLs + ~https://api-url.com/export/squad-admin-list/org/asgard/groups/group-uuid~ + ~https://api-url.com/export/squad-admin-list/org/asgard~ + ~https://api-url.com/export/squad-admin-list/org/asgard?tag=tactical~ + ~https://api-url.com/export/squad-admin-list/org/asgard?tag=tactical&tag=vanilla~ diff --git a/SPEC.md b/SPEC.md deleted file mode 100644 index 8dc1a7a..0000000 --- a/SPEC.md +++ /dev/null @@ -1,209 +0,0 @@ -# Squad Whitelist Management - - -## Discord Bot - -### Commands - -- **/link** - - Example: `/link 7312312312395` - - Links user's discord ID with their provided steam64 - - If linked to another discord id, reject - - Use the user's discord username for their username in the API - -- **/group-link** - - Example: `/group-link @Odin {group-uuid}` - - Links a Group on the API with a given discord ID for the role - - If the Discord ID already exists, inform about it but allow - -- **/list-groups** - - Example: `/list-groups` - - Outputs: - - Groups with Associated Discord Role - - Example: `@Odin | https://my-api.com/org/asgard/group-uuid` -### Events - -- `on-member-update` - - For each member, look at the change in discord roles - - If they had a role added to them that's a linked group, add them to the Group - - If they don't have a linked Steam64, ping them in a channel to do so - -- `on-startup` - - Hit up API for all members of linked roles - - Check if the members are in those roles and modify as needed - -## API - - -### Functionality - - -#### Generate Remote Admin List - -- Capability to export as remote admin list -- Can be applied to an entire Org -- Example: `https://api-url.com/org/asgard?reserved` -- Example: https://api-url.com/group/group-uuid?startvote&changemap&pause -- Query params - - startvote - - changemap - - pause - - cheat - - private - - balance - - chat - - kick - - ban - - config - - cameraman - - immune - - manageserver - - featuretest - - reserve - - demos - - clientdemos - - debug - - teamchange - - forceteamchange - - canseeadminchat - -- Example: - - Query: `https://api-url.com/org/{org-name}/{group-uuid}` - - Output: `Group={group-uuid}:{query-params} // {group-name}` - -## Data - -### Users - -- Table Name: `USERS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | id | Primary Key | | Steam64 | - | username | String | | | - | password | String? | | Salted Hash, don't allow login if null. Owning tenant can set Password. | - | discord_id | Int? | | | - | superuser | bool | | | - -### Organizations - -- Table Name: `ORGS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | id | UUID4 | | | - | name | String | Unique | | - | owner_id | `USERS.ID` | | | - | discord_server_id | Int? | | | - -### Organization Members - -- Table Name: `ORG_MEMBERS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | org_id | `ORGS.ID` | | | - | user_id | `USERS.ID` | | | - | discord_server_id | Int? | | | - - Primary key is composite key of `org_id` + `user_id` - -### Groups - -- Table Name: `GROUPS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | id | UUID4 | Primary Key | | - | name | String | | Group Name | - | remote_import_url | String? | | The remote url to a remote admin list hosted elsewhere | - | owner_id | `USERS.ID` | | | - | max_members | Int? | | Max number of members allowed as part of this group. If null, unlimited members | - | org_id | `ORGS.ID` | | | - | discord_role_id | Int? | | | - -### Group Members - -- Table Name: `GROUP_MEMBERS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | user | `ORG_MEMBERS.user_id` | | | - | org_id | `ORGS.ID` | | | - | group | `GROUPS.ID` | | | - | nick_name | String | | | - | member | bool | | | - | owner | bool | | | - | perm_manage_mods | bool | | | - | perm_manage_perms | bool | | | - | perm_manage_users | bool | | | - | perm_manage_tags | bool | | | - | perm_manage_import | bool | | Allow user to specify a remote admin list to use for the Group | - -### Group Squad Perms - -- Table Name: `GROUP_SQUAD_PERMS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | group_id | `GROUP.ID` | Primary Key | | - | perm_changemap | bool | | Allowed to change the current map | - | perm_pause | bool | | Allowed to pause server gameplay | - | perm_cheat | bool | | Allowed to use server cheat commands | - | perm_private | bool | | Allowed to password protect the server | - | perm_balance | bool | | Allowed to ignore team balance | - | perm_chat | bool | | Allowed to access admin chat and make server broadcasts | - | perm_kick | bool | | Allowed to kick players | - | perm_ban | bool | | Allowed to ban players | - | perm_config | bool | | Allowed to change server config | - | perm_cameraman | bool | | Allowed to admin spectate mode | - | perm_immune | bool | | Allowed to cannot be kicked / banned | - | perm_manageserver | bool | | Allowed to shutdown server | - | perm_featuretest | bool | | Allowed to any features added for testing by dev team | - | perm_reserve | bool | | Allowed to reserve slot | - | perm_demos | bool | | Allowed to record Demos on the server side via admin commands | - | perm_clientdemos | bool | | Allowed to record Demos on the client side via commands or the replay UI | - | perm_debug | bool | | Allowed to Show admin stats command and other debugging info | - | perm_teamchange | bool | | Allowed to no timer limits on team change | - | perm_forceteamchange | bool | | Allowed to can issue the ForceTeamChange command | - | perm_canseeadminchat | bool | | Allowed to this group can see the admin chat and teamkill/admin-join notifications | - -### TAGS - -- Table Name: `TAGS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | name | String | Must be unique when combined with `org_id` | | - | org_id | `ORG.ID` | Must be unique when combined with `name` | | - - - Both `Org` & `Name` together must be unique, the combo of them is unique - -### Group Tags - -- Table Name: `GROUP_TAGS` - | Key | Type | Constraints | Description | - | - | - | - | - | - | id | UUID4 | Primary Key | | - | group_id | `GROUP.ID` | Must be unique when combined with `tag` | | - | tag_id | `TAGS.ID` | Must be unique when combined with `group` | | - -- Together both `GROUP` & `TAG` create primary key -- `SELECT * FROM GROUP_TAGS WHERE GROUP = "GROUP.ID" AND TAG = "TAG.ID"` - -- Org - - Single Owner - - Groups - - Group: whitelist-{group-id} - - Tags: vanilla - - Single Owner - - Perms - - Group - - Manage Users (Add or Remove Users) - - Manage Moderators (Allow other users to manage the group) - - Manage Remote Import (Allowed to set a remote import) - - Manage Tags (Allowed to manage tags) - - Squad - - Reserve - - Demos - - Kick - - Ban - - Etc. - -`https://api-url.com/export/squad-admin-list/org/asgard/groups/group-uuid` -`https://api-url.com/export/squad-admin-list/org/asgard` -`https://api-url.com/export/squad-admin-list/org/asgard?tag=tactical` -`https://api-url.com/export/squad-admin-list/org/asgard?tag=tactical&tag=vanilla`