Add some docs

This commit is contained in:
Ash Keel 2021-12-02 12:20:20 +01:00
parent 19064ac2ca
commit 492335f2bf
No known key found for this signature in database
GPG Key ID: BAD8D93E7314ED3E
3 changed files with 102 additions and 1 deletions

View File

@ -29,7 +29,7 @@ Strimertül is a single executable app that provides the following:
At strimertul's core is [Kilovolt](https://github.com/strimertul/kilovolt), a pub/sub key-value store accessible via websocket. You can access every functionality of strimertul through the Kilovolt API. Check [this repository](https://github.com/strimertul/kilovolt-clients) for a list of officially supported kilovolt clients (or submit your own). You should be able to easily build a client yourself by just creating a websocket connection and using the [Kilovolt protocol](https://github.com/strimertul/kilovolt/blob/main/PROTOCOL.md).
Check out the [project's wiki](https://github.com/strimertul/strimertul/wiki) for more information on how to use the API to interact with strimertul.
Check out the [project's wiki](https://github.com/strimertul/strimertul/wiki) for more information on how to use the API to interact with strimertul, or the `docs` folder for more technical informations.
## Building

14
docs/modules.md Normal file
View File

@ -0,0 +1,14 @@
# Module configuration
Strimertul modules can be toggled on and off by setting flags in the `stul-meta/modules` key, which is a JSON object with the following schema:
```json
{
"configured": true, // Setting this to false will restore defaults at the next boot
"twitch": bool, // Twitch integration
"stulbe": bool, // Back-end integration
"loyalty": bool // Loyalty system
}
```
Currently modules are not turned on/off until the next time strimertul is restarted, this is a known bug and it's being tracked in [issue #8](https://github.com/strimertul/strimertul/issues/8).

87
docs/twitch.md Normal file
View File

@ -0,0 +1,87 @@
# Twitch integration
## Configuration
### Enable/disable Twitch integration
The Twitch integration can be enabled/disabled via `stul-meta/modules`, see [modules.md](./modules.md) for more details.
### Twitch integration configuration
The Twitch integration can be configured via `twitch/config` using a JSON object like this:
```json
{
"enable_bot": bool, // Enable IRC bot
"api_client_id": string, // Twitch App Client ID
"api_client_secret": string // Twitch App Client Secret
}
```
The IRC bot has its own configuration in `twitch/bot-config` as the following JSON object:
```json
{
"username": string, // Bot username, probably ignored
"oauth": string, // OAuth token
"channel": string, // Twitch channel to join
"chat_keys": bool, // True to enable chatlog keys
"chat_history": int // How many messages to save in twitch/chat-history
}
```
If `chat_keys` is enabled, these keys will be updated every time a new message is written in the specified channel:
- `twitch/ev/chat-message` containing the message that was just written
- `twitch/chat-history` containing the updated list of the last N messages (N depends on `chat_history`)
See [this page](https://github.com/strimertul/strimertul/wiki/Extending-the-bot-with-external-modules) for info on chat message schema.
## Custom commands
The bot supports user-defined custom commands for basic things like auto-replies, counters and shoutouts.
The key `twitch/bot-custom-commands` contains a JSON dictionary of custom commands like the following:
```json
{
"!command" : {
"description": string, // Command description, for UI only
"access_level": string, // Minimum required access level, see below
"response": string, // Response
"enabled": bool // Must be true for the command to work
},
...
}
```
### Access levels
The `access_level` property must be a string determining what kind of users can use the command, it can be one of the following:
| Access level identifier | Minimum access level |
| ----------------------- | ------------------------- |
| `"streamer"` | Just the broadcaster |
| `"moderators"` | Moderators and up |
| `"vip"` | VIP and up |
| `"subscriber"` | Twitch subscribers and up |
| `"everyone"` | Everyone |
Every level allows people in the upper tiers to use the command as well (eg. a VIP-only command can be used by the broadcaster and moderators).
### Response templating
Responses are fully functional golang templates, please refer to [text/template](https://pkg.go.dev/text/template) for a full reference on syntax and functionality.
The following functions are available:
- Every function in [sprig](https://masterminds.github.io/sprig/)
- [`user .`] retrieves the Twitch username of whoever typed the command
- [`param N .`] retrieves the Nth word after the command (ie. "`param 1 .`" on "`!so something awful`" would return "`something`")
- [`randomInt MIN MAX`] returns a random integer between MIN and MAX
- [`game USERNAME`] returns the current game for Twitch user USERNAME
- [`count COUNTER`] increases the counter for key `COUNTER` by 1 and returns it
## Sending text as the bot
Writing any string to `twitch/@send-chat-message` will send it as a message in chat from the bot's account