Skip to content
Total Surveillance Automatic Ban Machine for Twitch and Discord
Haskell Other
  1. Haskell 98.4%
  2. Other 1.6%
Branch: master
Clone or download
Latest commit 04c661e Dec 25, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc (#178) Fix docs Sep 13, 2018
scripts Add TODO(#711) Jul 26, 2019
test (#817) Fix hindent remarks Nov 21, 2019
.dir-locals.el (#624) Use cabal new-repl for Emacs haskell-mode Jun 3, 2019
.dockerignore Undockerignore .git folder May 9, 2019
.gitignore Gitignore ghc environment May 2, 2019
.hlint.yaml TODO(#313) Oct 9, 2018
.snitch.yaml Add transformation rule for HTML comments Jan 18, 2019
.travis.yml Downgrade hindent to 5.2.7 May 28, 2019 Extend Contribution Rules Nov 2, 2018
Dockerfile Add TODO(#578) Apr 19, 2019
HyperNerd.cabal (#807) Initial %flip implementation Nov 21, 2019
LICENSE Ready. Set. Go Jan 29, 2018 Add more info to build instructions to address concerns in #798 Oct 2, 2019
Setup.hs (#351) Apply hindent to the whole codebase Oct 31, 2018
default.nix (#604) Add hlint to NixOS development environment May 9, 2019
docker-compose.yaml Improvements to Dockerfile and build. Apr 19, 2019
stack.yaml Fix louis version Sep 21, 2019



Build Status Good For Stream


Second iteration of Tsoder. Chat bot for Tsoding streams.

Quick Start


Keep in mind that we are not using any Haskell packages from nixpkgs. All of the dependencies are supposed to be downloaded by cabal or stack during the build.

Cabal v1-build

$ 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.db

Cabal v2-build

See Nix-style Local Builds for more info

$ nix-shell
$ cabal v2-build
$ cabal v2-test
$ cabal v2-run exe:HyperNerd secret.ini database.db


Native dependencies:

  • OpenSSL
  • zlib
$ stack build
$ stack exec hlint .
$ stack exec HyperNerd secret.ini database.db

Example of a secret.ini file

The secret.ini file consist of three optional sections.

nick = HyperNerd
channel = Tsoding
password = <oauth-token>
clientId = <client-id-token>
owner = <your-name>

authToken = <auth-token>
guild = <guild-id>
channels = [<channel-id-1>, <channel-id-2>, ... ]

apiKey = <oauth-token>

Twitch Config Section

name description
nick Nickname of the bot.
owner Owner of the bot. The bot will recognize this name as an authority regardless of not being a mod or broadcaster.
password Password generated by 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 Config Section

name description
authToken Authentication Token for the bot:
guild The id of the guild the bot listens to
channels The list of ids of channels the bot listens to (the list is parsed as a Haskell list: [<channel-id-1>, <channel-id-2>, ... ])

GitHub Config Section

name desc


With secrets existing in volume defined in docker-compose.yaml,

$ docker-compose up --build


$ 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-bot
$ docker exec -it hypernerd-bot sh

Markov 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.csv

This command will produce the markov.csv file.

Using the Trained Markov Model with the Bot

$ cabal exec HyperNerd secret.ini database.db markov.csv

The 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.


You can support my work via

You can’t perform that action at this time.