-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparation to merge initial revision of sisbasekt
#3
Draft
alikindsys
wants to merge
44
commits into
master
Choose a base branch
from
sisbasekt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
40e39ce
[core] Add basic feature set
alikindsys d823034
Add starting API details
alikindsys 099d79e
Add information for systems
alikindsys e0ab065
Add `sisbase-commands` subproject
alikindsys 9919363
Add more design details for `sisbase-commands`
alikindsys 82c0a76
Clarify which overload
alikindsys d204545
Add goals section
alikindsys 86b93d2
Remove reduntant abstraction section
alikindsys 34a510b
Add explanation on "fat bot"
alikindsys 91039ec
Add `sisbase-types` shared dependency
alikindsys 0059861
Remove unecessary "Uses" section on project outline
alikindsys 86bab14
Add "Uses" section
alikindsys 2506190
Remove features related to commands
alikindsys ba3c173
Add note on prefix handling
alikindsys a3201e4
Add note on Discord Connection
alikindsys 38e234e
Add "Lifetime Description" section
alikindsys 48fbec5
Move "Commands" section to commands.md
alikindsys f257c3f
Move "System" section to core.md
alikindsys 6a3d630
Repurpose `sisbase-api`
alikindsys e61fa83
Remove reference to Kord
alikindsys 942a9e7
Update `sisbase-commands` description
alikindsys f600d0f
Merge branch 'sisbasekt-reordering' into sisbasekt
alikindsys b32551e
Add "Project Structure" section
alikindsys aabf536
Add "Usage" section
alikindsys 92b2067
Add missing packages to package structure
alikindsys fc33f85
Add "Other Types" section
alikindsys 2cedbb6
Add "Annotations" section
alikindsys 7966fd2
Add note on "Backend Agnostic"
alikindsys 8e74767
Add mod_json.md
alikindsys 4a332f2
Add "Configuration / Metadata" section
alikindsys cd5a2e9
Add Dependencies section
alikindsys 51699cb
Add Dependencies section
alikindsys 79033de
Add `api` to Uses section
alikindsys ee1f9d6
Rename Uses section to Dependencies
alikindsys 5eeaa0d
Move "Developing extensions" section to `core.md`
alikindsys 320644f
[Idea] Add "`RequireApiVersion` deriving automatically"
alikindsys 15cf55f
Make `Developing Extensions` a section
alikindsys b2fd1ac
Add `systems.md`
alikindsys 1243725
Move `Systems` section to `system.md`
alikindsys 154b271
Add "Dependency Management" section
alikindsys d1c2467
Move "Dependency Management" section to `core.md`
alikindsys feb4b41
Add `koin` dependency
alikindsys 3cc3b7a
Add "Metadata" section
alikindsys 8b6c0b3
Add "Discord API Version Compatibility" header
alikindsys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
# sisbase-api | ||
`Type: Subproject` | ||
Subproject of: [`SisbaseKT`](../sisbasekt.md) | ||
|
||
A collection of interfaces representing the Discord API Spec. | ||
Implemented by `Backends`. | ||
|
||
## Dependencies | ||
[types](types.md) | ||
|
||
## Project Structure | ||
`org.sisbase.sisbase-api` | ||
Base package | ||
|
||
`org.sisbase.sisbase-api.rest` | ||
High level wrapper for Discord's Rest API | ||
|
||
alikindsys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`org.sisbase.sisbase-api.gateway` | ||
High level wrapper for Discord's Gateway | ||
|
||
## Usage | ||
|
||
### Implementing a Backend | ||
Backends are the actual libraries that connect to discord. | ||
An example of a valid backend would be Discord4J. | ||
|
||
To implement a gateway backend, extend `GatewayBackend` | ||
To implement a rest backend, extend `RestBackend` | ||
To implement a backend that supports both, extend `AbstractBackend` | ||
|
||
```kt | ||
package org.siscode.sisbasekt-backends.discord4j | ||
class Discord4JBackend() : AbstractBackend { | ||
public restBackend = Discord4JRest(); | ||
public gatewaybackend = Discord4JGateway() | ||
} | ||
``` | ||
Comment on lines
+31
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code snippet is non-descriptive and only duplicates the text above it. |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# sisbase-commands | ||
`Type: Subproject` | ||
Subproject of: [`SisbaseKT`](../sisbasekt.md) | ||
|
||
Command library. | ||
|
||
Implemented as an extension. Users can use `sisbase-commands` optionally for command handling, but can also use their own command handling solutions if they so desire. | ||
|
||
## Dependencies | ||
[core](core.md) | ||
|
||
## Commands | ||
Simple interactions with the user caused by a direct call to them. | ||
|
||
Has the following attributes: | ||
|
||
| Field | Type | Description | | ||
|---------------|----------|---------------------------------------------------------------------------------| | ||
| `name` | String | Name of the command | | ||
| `description` | String? | A short description of the command | | ||
| `user` | User | The user that called the command | | ||
| `channel` | Channel | The channel on which the command was called | | ||
| `guild` | Guild? | The guild on which the command was called | | ||
|
||
### Text-based | ||
The third-party command system, based on detecting commands from messages sent on a given discord channel. | ||
Has an extensive permission system since the code is fully controlled by the library. | ||
Requires a system that checks every message for a valid command. | ||
|
||
Extends the base attributes with: | ||
|
||
| Field | Type | Description | | ||
|----------|----------------|-------------------------------------------------------------------------------------------------------------| | ||
| `checks` | [Precondition] | An array with all checks done to the text command by the permission engine, or an empty array if none exist | | ||
| `group` | Group? | The group the command is a part of | | ||
| `alias` | [String] | An array containing all aliases to the command, or an empty array if none exist | | ||
|
||
### Slash | ||
Discord's native command system, supercedes text-based commands but has a limit of how many commands can be registered and require modifying the application. | ||
Does not require a system since discord dispatches the command to the bot via the gateway. | ||
|
||
**Currently, support for slash commands isn't planned, this could change in the future** | ||
|
||
|
||
## Structure of the `sisbase-commands` extension | ||
|
||
### Persistent Data | ||
The extension must hold a `Registry` for commands during the bot lifetime. | ||
|
||
The `Registry` must safeguard against command conflicts, as **only one command** (including overloads) can be registered for a given `Identifier`. | ||
|
||
`Identifier`s are a way to uniquely identify a given command and they include the following fields: | ||
|
||
| Field | Type | Description | Observations | | ||
|----------------------|--------|----------------------------------------------------|----------------------------------------------------------| | ||
| `source` | String | The id of the extension that registers the command | Automatically set based on the extension's metadata file | | ||
| `fullyQualifiedName` | String | The full command path for a given command | Automatically set once the command is registered | | ||
|
||
An example of a `Identifier` is given below: | ||
|
||
Command is called as `/help` | ||
```yml | ||
source: "your-bot" | ||
command: "help" | ||
identifier: "your-bot::help" | ||
``` | ||
|
||
Command is called as `/group subcommand` | ||
```yml | ||
source: "your-bot" | ||
command: "group/subcommand" | ||
identifier: "your-bot::group/subcommand" | ||
``` | ||
|
||
Identifiers don't care about command overloads, this is handled internally by the library. | ||
Mismatches for commands with equal names registered by the same extension will cause the extension to be rejected. (DUPLICATE COMMAND) | ||
Mismatches for commands with equal names registered by different extensions are to be resolved manually on the `overrides.yml` file. (COMMAND MISMATCH) | ||
|
||
Example of a mismatch: | ||
|
||
`ext-a` registers a `help` command. -> `ext-a::help` | ||
`ext-b` also registers a `help` command. -> `ext-b::help` | ||
|
||
Console Output: | ||
``` | ||
[Sisbase-Commands] Command Mismatch Detected: | ||
|
||
The following commands will become unavailable until their mismatches are resolved. | ||
|
||
for `help`: | ||
|
||
`ext-a@version` registered `help` | ||
`ext-b@version` registered `help` | ||
|
||
Please resolve all command mismatches on `overrides.yaml.` | ||
|
||
[Sisbase-Commands] Disabled `ext-a::help` due to: COMMAND MISMATCH | ||
[Sisbase-Commands] Disabled `ext-b::help` due to: COMMAND MISMATCH | ||
``` | ||
|
||
Example of a duplicate command: | ||
|
||
`ext-a` registers a `help` command. -> `ext-a::help` | ||
`ext-a` later registers a `help` command. -> `ext-a::help` | ||
|
||
Console Output: | ||
``` | ||
[Sisbase-Commands] Duplicate Command Detected: | ||
|
||
The following extensions will become unavailable until their duplicate commands are removed. | ||
|
||
for `ext-a`: | ||
|
||
Duplicate `help` command registered. | ||
|
||
Please contact the extension authors to remove the duplicate commands. | ||
|
||
[Sisbase-Commands] Disabled `ext-a` due to: DUPLICATE COMMAND | ||
|
||
``` | ||
|
||
On the case of a critical failure that leads to the extension being shutdown (or on the case of it being disabled) | ||
all commands and hooks **must be unregistered** immediately. | ||
|
||
### Required hooks | ||
|
||
For command parsing: | ||
|
||
| Hook | Usage | | ||
|--------------------------|---------------------------------------------------------------------------------------------------------------| | ||
| `onMessageReceived` | Used for parsing the message contents, building the CommandContext, and forwarding the data to the call site. | | ||
| `onGuildMessageReceived` | Same as `onMessageReceived` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Systems | ||
`Type: Feature` | ||
Part of [`core`](../core.md) | ||
|
||
Long-term, usually lifelong background procedures. | ||
|
||
## Dependency Management | ||
Systems can depend on other systems using the `@DependsOn` annotation. | ||
Systems can add "soft dependencies" using the `@Extends` annotation. | ||
|
||
## Data Description | ||
Has the following attributes: | ||
|
||
| Field | Type | Description | | ||
|----------------------|---------------------|-------------------------------------------------------------------------------------------------------------------| | ||
| `name` | String | Name of the system | | ||
| `description` | String? | A short description of the system | | ||
| `expansions` | [Expansion] | An array of system expansions, or an empty array if none exist | | ||
| `OnInit` | suspend fun | A function that runs on the start of the system's lifetime | | ||
| `OnDisable` | suspend fun | A function that runs on the end of the system's lifetime | | ||
| `CheckPreconditions` | suspend fun -> Bool | A function that runs before `OnInit`, if it returns `true` the system is loaded, otherwise the system is skipped. | | ||
|
||
|
||
### Repeating | ||
Background procedures that repeat at a set interval given by the user. | ||
|
||
Implemented by a `Expansion` that has the following attributes: | ||
| Field | Type | Description | | ||
|-------------|-------------|-----------------------------------------------------------------| | ||
| `timeout` | Duration | The period of time that will be used for repeating the function | | ||
| `OnElapsed` | suspend fun | The function that will be repeated once `timeout` elapses | | ||
|
||
### Discord-linked | ||
Background procedures that reads/writes data to Discord. | ||
|
||
Implemented by a `Expansion` that has the following attributes: | ||
| Field | Type | Description | | ||
|-----------------|----------------------|----------------------------------------------------------------------| | ||
| `applyToClient` | suspend fun (Client) | A function that will be applied to the discord client after `OnInit` | | ||
|
||
### Single-instance | ||
Simple background procedures that are set once the bot loads and are used in other parts of the bot. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
Features
section