HyperNerd
Second iteration of Tsoder. Chat bot for Tsoding streams.
Quick Start
NixOS
$ nix-shell
$ cabal sandbox init
$ cabal install happy-1.19.9
$ cabal install --only-dependencies --enable-tests
$ cabal build
$ cabal test
$ cabal run HyperNerd secret.ini database.dbStack
Native dependencies:
- OpenSSL
- zlib
$ stack build
$ stack exec hlint .
$ stack exec HyperNerd secret.ini database.dbExample of a secret.ini file
The secret.ini file consist of a several sections with bot: prefix the format of which depends on their type.
[bot:mrbotka@twitch]
type = twitch
...
... the rest of the Twitch parameters ...
...
[bot:hypernerd@discord]
type = discord
...
... the rest of the Discord parameters ...
...Twitch Bot
[bot:twitch]
type = twitch
nick = HyperNerd
owner = <your-name>
password = 12345
channel = Tsoding
clientId = <client-id-token>| name | description |
|---|---|
nick |
Nickname of the bot. |
owner |
Owner of the bot. The bot will recognize this name as an authority regardless of being a mod or broadcaster. |
password |
Password generated by https://twitchapps.com/tmi/. oauth: prefix is the part of the password. |
channel |
Channel that the bot will join on start up. |
clientId |
Client ID for Twitch API calls. |
Discord Bot
[bot:discord]
type = discord
authToken = <auth-token>
guild = <guild-id>
channel = <channel-id>
clientId = <client-id-token>| name | description |
|---|---|
authToken |
Authentication Token for the bot: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token |
guild |
The id of the guild the bot listens to |
channel |
The id of the channel the bot listens to |
clientId |
Client ID for Twitch API calls. |
Debug Bot
TBD
Docker-Compose
With secrets existing in volume defined in docker-compose.yaml,
$ docker-compose up --buildDocker
$ docker build --target app -t hypernerd .
$ mkdir hypernerd-state
$ cp secret.ini hypernerd-state
$ docker create -v /absolute/path/to/hypernerd-state/:/tmp/hypernerd/ \
--name hypernerd-bot hypernerd
$ docker start -a hypernerd-bot
$ docker stop hypernerd-botMarkov Chain Responses
To trigger a Markov chain response, just mention the bot in the chat.
Training the Markov Model
The Markov model is a csv file that is generated from the logs in the
bot's database file using the Markov CLI utility:
$ cabal exec Markov train database.db markov.csvThis command will produce the markov.csv file.
Using the Trained Markov Model with the Bot
$ cabal exec HyperNerd secret.ini database.db markov.csvThe markov.csv file is not automatically updated. To update the file
with the new logs you have to run the Markov CLI utility again.
Command Aliases
You can assign a command alias to any command:
<user> !test
<bot> test
<user> !addalias foo test
<user> !foo
<bot> test
The aliases are "redirected" only one level deep meaning that transitive aliases are not supported:
<user> !addalias bar foo
<user> !bar
*nothing, because !bar is redirected to !foo, but further redirect from !foo to !test does not happen*
Motivation to not support transitive aliases is the following:
- They are not needed in most of the cases. Generally you just have a main command and a bunch of aliases to it.
- Support for transitive aliases requires to traverse and maintain a "tree" of aliases, which complicates the logic and degrades the performance.
Quote Database
!addquote <quote-text>-- Add a quote to the quote database. Available only to subs and mods.!delquote <quote-id>-- Delete quote by id. Available only to Tsoding.!quote [quote-id]-- Query quote from the quote database.
Support
You can support my work via
- Twitch channel: https://www.twitch.tv/subs/tsoding
- Patreon: https://www.patreon.com/tsoding
