Initial commit
This commit is contained in:
commit
1e174a0789
24 files changed
+5499
No files matched your search
@@ -0,0 +1,338 @@
|
||||
# Command System
|
||||
|
||||
## Overview
|
||||
|
||||
Echoion processes user commands from TeamSpeak chat messages. Commands are prefixed (default: `!`) and dispatched to appropriate handlers based on the command name.
|
||||
|
||||
## Command Architecture
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Command Flow"
|
||||
User[User Message] --> Plugin[PluginInterface]
|
||||
Plugin --> Core[EchoionCore]
|
||||
Core --> CM[CommandManager]
|
||||
|
||||
CM --> Parse[Parse Command]
|
||||
Parse --> Lookup[Lookup Handler]
|
||||
Lookup --> Check{Check<br/>Permissions}
|
||||
|
||||
Check -->|Denied| Deny[Permission Denied]
|
||||
Check -->|Allowed| Execute[Execute Handler]
|
||||
|
||||
Execute --> Reply[Send Reply]
|
||||
Deny --> Reply
|
||||
end
|
||||
|
||||
subgraph "Handler Registry"
|
||||
H1[play → PlayHandler]
|
||||
H2[pause → PauseHandler]
|
||||
H3[skip → SkipHandler]
|
||||
H4[volume → VolumeHandler]
|
||||
end
|
||||
|
||||
Lookup --> H1
|
||||
Lookup --> H2
|
||||
Lookup --> H3
|
||||
Lookup --> H4
|
||||
```
|
||||
|
||||
## Command Processing Flow
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
actor User
|
||||
participant TS as TeamSpeak
|
||||
participant PL as Plugin
|
||||
participant CO as Core
|
||||
participant CM as CommandManager
|
||||
|
||||
User->>TS: Type "!play song name"
|
||||
TS->>PL: onTextMessageReceived
|
||||
PL->>CO: onPluginEvent
|
||||
CO->>CM: dispatch
|
||||
|
||||
CM->>CM: Parse command
|
||||
CM->>CM: Extract arguments
|
||||
CM->>CM: Find handler
|
||||
CM->>CM: Check permissions
|
||||
|
||||
alt Permission Granted
|
||||
CM->>CM: Execute handler
|
||||
CM->>CO: Process result
|
||||
CO->>PL: sendTextMessage
|
||||
PL->>TS: Display result
|
||||
TS->>User: See response
|
||||
else Permission Denied
|
||||
CM->>CO: Permission error
|
||||
CO->>PL: send error
|
||||
PL->>TS: Display error
|
||||
end
|
||||
```
|
||||
|
||||
## Command Categories
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Command Categories"
|
||||
Music[Music Commands<br/>Search & Play]
|
||||
Playback[Playback Commands<br/>Control Audio]
|
||||
Queue[Queue Commands<br/>Manage Queue]
|
||||
Utility[Utility Commands<br/>Help & Info]
|
||||
Admin[Admin Commands<br/>System Control]
|
||||
end
|
||||
|
||||
Music --> Play[play, search]
|
||||
Playback --> Ctrl[pause, resume, skip, volume]
|
||||
Queue --> Q[queue, clear, shuffle, remove]
|
||||
Utility --> Util[help, nowplaying, subscribe]
|
||||
Admin --> Adm[reload, reloadconfig]
|
||||
```
|
||||
|
||||
### Category Permissions
|
||||
|
||||
| Category | Description | Who Can Use |
|
||||
|----------|-------------|-------------|
|
||||
| **Music** | Search and play songs | All users |
|
||||
| **Playback** | Control playback | All users |
|
||||
| **Queue** | Queue management | Admin, DJ |
|
||||
| **Utility** | General utilities | All users |
|
||||
| **Admin** | System operations | Admin only |
|
||||
|
||||
## Available Commands
|
||||
|
||||
### Music Commands
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph "Music"
|
||||
Play["!play <query><br/>Play or queue song"]
|
||||
Search["!search <query><br/>Search YouTube"]
|
||||
Select["!select <n><br/>Pick from search"]
|
||||
end
|
||||
|
||||
UserInput["User types..."] --> Play
|
||||
UserInput --> Search
|
||||
Search --> Results["Show results<br/>[1] Song A<br/>[2] Song B"]
|
||||
Results --> Select
|
||||
```
|
||||
|
||||
| Command | Aliases | Description | Permission |
|
||||
|---------|---------|-------------|------------|
|
||||
| `play <query>` | `p` | Play song or add to queue | User |
|
||||
| `search <query>` | - | Search YouTube for tracks | User |
|
||||
| `select <number>` | - | Select track from search | User |
|
||||
|
||||
### Playback Commands
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph "Playback Controls"
|
||||
Pause["!pause<br/>Pause playback"]
|
||||
Resume["!resume<br/>Continue playing"]
|
||||
Stop["!stop<br/>Stop & clear"]
|
||||
Skip["!skip [n]<br/>Skip track(s)"]
|
||||
Seek["!seek <pos><br/>Jump to position"]
|
||||
Vol["!volume <0-100><br/>Set volume"]
|
||||
end
|
||||
```
|
||||
|
||||
| Command | Aliases | Description | Permission |
|
||||
|---------|---------|-------------|------------|
|
||||
| `pause` | - | Pause current playback | User |
|
||||
| `resume` | `unpause`, `continue` | Resume paused playback | User |
|
||||
| `stop` | - | Stop and clear current | User |
|
||||
| `skip [count]` | `next`, `s` | Skip to next track | User |
|
||||
| `seek <position>` | `jump` | Seek to position (MM:SS) | User |
|
||||
| `volume <0-100>` | `vol`, `v` | Set playback volume | User |
|
||||
|
||||
### Queue Commands
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Queue Management"
|
||||
Show["!queue<br/>Show queue"]
|
||||
Clear["!clear<br/>Clear all"]
|
||||
Shuffle["!shuffle<br/>Toggle shuffle"]
|
||||
Repeat["!repeat<br/>Toggle repeat"]
|
||||
Remove["!remove <n><br/>Remove track"]
|
||||
Move["!move <from> <to><br/>Reorder"]
|
||||
end
|
||||
```
|
||||
|
||||
| Command | Aliases | Description | Permission |
|
||||
|---------|---------|-------------|------------|
|
||||
| `queue` | `q`, `list` | Display current queue | User |
|
||||
| `clear` | `empty` | Remove all tracks | Admin, DJ |
|
||||
| `shuffle` | `random` | Toggle shuffle mode | Admin, DJ |
|
||||
| `repeat` | `loop` | Toggle repeat mode | Admin, DJ |
|
||||
| `remove <position>` | `rm`, `delete` | Remove specific track | Admin, DJ |
|
||||
| `move <from> <to>` | - | Reorder tracks | Admin, DJ |
|
||||
|
||||
### Utility Commands
|
||||
|
||||
| Command | Aliases | Description | Permission |
|
||||
|---------|---------|-------------|------------|
|
||||
| `help [command]` | - | Show help information | User |
|
||||
| `nowplaying` | `np`, `current` | Show current track | User |
|
||||
| `subscribe` | `sub`, `join` | Subscribe to audio | User |
|
||||
| `unsubscribe` | `unsub`, `leave` | Unsubscribe from audio | User |
|
||||
|
||||
### Admin Commands
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph "Admin Only"
|
||||
Reload["!reload<br/>Hot reload core"]
|
||||
Config["!reloadconfig<br/>Reload config"]
|
||||
end
|
||||
|
||||
style Admin fill:#f96,stroke:#333
|
||||
```
|
||||
|
||||
| Command | Aliases | Description | Permission |
|
||||
|---------|---------|-------------|------------|
|
||||
| `reload` | `reloadcore` | Hot reload Core library | Admin |
|
||||
| `reloadconfig` | - | Reload configuration | Admin |
|
||||
|
||||
## Command Dispatch Flow
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
Input["Input: !play song name"] --> Prefix{Starts with<br/>prefix?}
|
||||
Prefix -->|No| Ignore[Ignore]
|
||||
Prefix -->|Yes| Extract
|
||||
|
||||
Extract["Extract: command='play'<br/>args='song name'"] --> Find{Handler<br/>found?}
|
||||
|
||||
Find -->|No| Unknown["Reply: Unknown command"]
|
||||
Find -->|Yes| Perm{Check<br/>permission}
|
||||
|
||||
Perm -->|Denied| NoPerm["Reply: No permission"]
|
||||
Perm -->|Allowed| Context["Create Context<br/>clientId, args, reply"]
|
||||
|
||||
Context --> Execute["Execute Handler"]
|
||||
Execute --> Result{Result}
|
||||
|
||||
Result -->|Success| SuccessReply["Reply: Success message"]
|
||||
Result -->|Error| ErrorReply["Reply: Error message"]
|
||||
```
|
||||
|
||||
## Permission Check Flow
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
Request[Command Request] --> Banned{Is Banned?}
|
||||
Banned -->|Yes| Deny1[Deny Access]
|
||||
Banned -->|No| AdminCmd{Admin<br/>Command?}
|
||||
|
||||
AdminCmd -->|Yes| IsAdmin{Is Admin?}
|
||||
IsAdmin -->|No| Deny2[Deny Access]
|
||||
IsAdmin -->|Yes| Allow1[Allow]
|
||||
|
||||
AdminCmd -->|No| QueueCmd{Queue<br/>Command?}
|
||||
QueueCmd -->|Yes| IsDJ{Is Admin/DJ?}
|
||||
IsDJ -->|No| Deny3[Deny Access]
|
||||
IsDJ -->|Yes| Allow2[Allow]
|
||||
|
||||
QueueCmd -->|No| Allow3[Allow<br/>Basic User]
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
Error{Error Type} --> NotFound["Command Not Found<br/>'Unknown command'"]
|
||||
Error --> NoPerm["Permission Denied<br/>'No permission'"]
|
||||
Error --> BadArgs["Invalid Arguments<br/>'Usage: !play <song>'"]
|
||||
Error --> NotAvail["Not Available<br/>'Music manager offline'"]
|
||||
|
||||
NotFound --> Reply
|
||||
NoPerm --> Reply
|
||||
BadArgs --> Reply
|
||||
NotAvail --> Reply
|
||||
|
||||
Reply[Send Reply to User]
|
||||
```
|
||||
|
||||
## Adding New Commands
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph "Adding a Command"
|
||||
Create[Create Handler Class]
|
||||
Impl[Implement execute]
|
||||
Meta[Define Metadata]
|
||||
Reg[Register in Manager]
|
||||
end
|
||||
|
||||
Create --> Impl
|
||||
Impl --> Meta
|
||||
Meta --> Reg
|
||||
Reg --> Test[Test]
|
||||
```
|
||||
|
||||
### Command Structure
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(context)
|
||||
+getDescription()
|
||||
+getUsage()
|
||||
+getCategory()
|
||||
+getAliases()
|
||||
+requiresAdmin()
|
||||
}
|
||||
|
||||
class PlayCommand {
|
||||
+execute()
|
||||
+getDescription() "Play a song"
|
||||
+getCategory() Music
|
||||
+getAliases() [p]
|
||||
}
|
||||
|
||||
class PauseCommand {
|
||||
+execute()
|
||||
+getDescription() "Pause playback"
|
||||
+getCategory() Playback
|
||||
}
|
||||
|
||||
Command <|-- PlayCommand
|
||||
Command <|-- PauseCommand
|
||||
```
|
||||
|
||||
## Reply Formatting
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Reply Types"
|
||||
Text["Plain Text<br/>'Track added'"]
|
||||
Rich["Rich Format<br/>'[b]Now Playing[/b]'"]
|
||||
Error["Error Message<br/>'[color=red]Error[/color]'"]
|
||||
Multi["Multi-line<br/>Track info"]
|
||||
end
|
||||
|
||||
Text --> TS[TeamSpeak Display]
|
||||
Rich --> TS
|
||||
Error --> TS
|
||||
Multi --> TS
|
||||
```
|
||||
|
||||
## Command Aliases
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph "Alias Resolution"
|
||||
A1["!p"] --> Play["!play"]
|
||||
A2["!q"] --> Queue["!queue"]
|
||||
A3["!np"] --> Now["!nowplaying"]
|
||||
A4["!vol"] --> Volume["!volume"]
|
||||
end
|
||||
|
||||
Play --> Handler[Same Handler]
|
||||
Queue --> Handler
|
||||
Now --> Handler
|
||||
Volume --> Handler
|
||||
```
|
||||
Reference in new issue
Block a user