Giter VIP home page Giter VIP logo

hypernerd's Introduction

Tsoding

HyperNerd

Build Status Good For Stream

HyperNerd

Second iteration of Tsoder. Chat bot for Tsoding streams.

Quick Start

NixOS

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

Stack

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.

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

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

[github]
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 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 Config Section

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
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
apiToken https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

Docker-Compose

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

$ docker-compose up --build

Docker

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

Support

You can support my work via

hypernerd's People

Contributors

abridgewater avatar cahe7cb avatar ear avatar invisible-rabbit-hunter avatar jappeace avatar jspaulsen avatar markus1189 avatar rexim avatar tau3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hypernerd's Issues

CI build is too slow

Mostly because every time we pull the docker image and rebuild the dependencies. We need to find a way to cache all of that.

SQLite error when starting HyperNerd on already existing database

HyperNerd: SQLite3 returned ErrorError while attempting to perform prepare "CREATE TABLE EntityProperty (  id INTEGER PRIMARY KEY,  entityName TEXT NOT NULL,  entityId INTEGER NOT NULL,  propertyName TEXT NOT NULL,  propertyType TEXT NOT NULL,  propertyInt INTEGER,  propertyText TEXT,  propertyUTCTime DATETIME);": table EntityProperty already exists

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.