• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Haskell
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Total Surveillance Automatic Ban Machine for Twitch and Discord

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

More Repositories

1

olive.c

Simple 2D Graphics Library for C
C
1,747
star
2

musializer

Music Visualizer
C
857
star
3

porth

It's like Forth but in Python
630
star
4

pinpog

Ping-Pong-like game in Assembly that works without OS
Assembly
568
star
5

ded

Dramatic EDitor
C
565
star
6

nobuild

Header only library for writing build recipes in C.
C
528
star
7

todo.asm

Todo Web Application in flat assembler
Assembly
444
star
8

boomer

Zoomer application for Linux
Nim
441
star
9

snitch

Language agnostic tool that collects TODOs in the source code and reports them as Issues
Go
416
star
10

good_training_language

Хороший Учебный Язык
Rust
381
star
11

nn.h

Simple stb-style header-only library for Neural Networks
C
332
star
12

eepers

Simple Turn-based Game
Ada
319
star
13

c.php

C to Python compiler in PHP
PHP
289
star
14

nothing

A simple platformer about nothing
C
273
star
15

Noq

Simple expression transformer that is not Coq.
Rust
253
star
16

seroost

Local Search Engine
Rust
228
star
17

arena

Arena Allocator implementation in pure C as an stb-style single-file library.
C
201
star
18

raycasting

My take on Raycasting inspired by Lode's Computer Graphics Tutorial
TypeScript
173
star
19

grecha.js

Simple Front-End JavaScript Framework
JavaScript
171
star
20

4at

Simple Multi-User Chat
Rust
162
star
21

bm

Simple compiler ecosystem
C
161
star
22

tula

Turing Language
Rust
159
star
23

emoteJAM

Simple website that generates animated BTTV emotes from static images.
JavaScript
152
star
24

JelloVM

JVM in Python that can only run "Hello, World"
Python
148
star
25

zozlib.js

Unofficial Implementation of Subset of Raylib API in JavaScript
C
146
star
26

sowon

Starting Soon Timer for Tsoding Streams
C
144
star
27

memalloc

Artifacts of that Memory Management Tsoding Session
C
143
star
28

snake-c-wasm

Snake written in Pure C and compilable to WebAssembly
C
141
star
29

haskell-json

Source Code for JSON Parser Video
Haskell
136
star
30

bfjit

JIT Compiler for Brainfuck
C
134
star
31

haskell-music

Source Code from "Making Music with Haskell" video
Haskell
130
star
32

wassm

Web framework for x86_64 nasm
Assembly
126
star
33

sv

Simple String_View implementation for C programming language.
C
120
star
34

aoc-2020

Advent of Code 2020 in 25 Different Languages
Julia
109
star
35

todo-rs

Simple Interactive Terminal Todo App in Rust
Rust
105
star
36

la

Linear Algebra in C
C
97
star
37

ml-notes

Notes from Machine Learning in C session
C
89
star
38

fasm-raylib-simd

A simple demo of using SIMD instructions and Raylib in fasm
C
88
star
39

jaibreak

JavaScript
86
star
40

cm

Emacs' compilation-mode-like TUI application
Rust
86
star
41

perceptron

Simple Perceptron Implementation inspired by Veritasium Video
C
85
star
42

HTMLang

HTML as a Programming Language. Finally all of your dreams came true.
JavaScript
84
star
43

img2term

Print an image in the terminal using the term 256 colors
C
84
star
44

dimooper

Digital Music Looper
Rust
82
star
45

opengl-template

Just a simple OpenGL template that I use on my streams.
C
82
star
46

profun

Procedural vs Functional
C
79
star
47

binviz

Binary Visualization based on Christopher Domas talk: https://www.youtube.com/watch?v=4bM3Gut1hIk
C
76
star
48

articles

Here I keep some thoughts that I always wanted to write down somewhere, but never knew where.
TeX
74
star
49

noed

Not ed(1) text editor
C
68
star
50

SmoothLife

SmoothLife Implementation in C
C
68
star
51

bada

Simple Programming Language that compiles to BEAM bytecode
Rust
67
star
52

faq

FAQ
66
star
53

kdtree-in-python

Source Code for K-d tree in Python series
Python
66
star
54

jai-wasm

Jai WebAssembly Proof-of-Concept
JavaScript
64
star
55

rendering-video-in-c-with-ffmpeg

Rendering Video in C with FFMpeg
C
63
star
56

multiplayer-game-prototype

Proof-of-concept of a Simple Multiplayer Game
TypeScript
61
star
57

tic-tac-toe-fortran-raylib

Tic-Tac-Toe in Fortran with Raylib
Fortran
57
star
58

flag.h

Command-line flag parsing in C
C
56
star
59

jim

Immediate Mode JSON Serialization Library in C
C
54
star
60

seam-carving

Seam Carving implementation
C++
54
star
61

minicel

Simple Excel engine without any UI
C
53
star
62

piff

Simple File Diff Tool in Python
Python
53
star
63

glob.h

Simple Header-Only Implementation of Glob Matching
C
51
star
64

mine

Minesweeper in Terminal
Pascal
51
star
65

bi-format

Structured Human-Readable Binary Format
50
star
66

ebisp

Embedded Lisp
C
49
star
67

zigout

An attempt to implement breakout in Zig
Zig
49
star
68

something-rewrite

Rewrite of Something from scratch
C
48
star
69

autocell

Cellular Automata Experiment
TypeScript
46
star
70

wang-tiles

Wang Tiles Grid generator
C
46
star
71

rere.py

Universal Behavior Testing Tool in Python.
Python
45
star
72

conway

Conway's Game of Life implementation in C formatted as Glider
C
45
star
73

something

Finally something
C
44
star
74

imhui

Immediate Human User Interface
C
42
star
75

vodus

Twitch VOD chat renderer
C
41
star
76

markut

Autocut the Twitch VODs based on a Marker file
Go
40
star
77

subframes

Simple Experiment with Subframe rendering
C
40
star
78

elf.js

An on going project to learn ELF format.
TypeScript
39
star
79

rcui

Simple TUI framework in Rust
Rust
37
star
80

voidf

V̳͙̥̹̟͗̀̎̓͌͐́O̘̞͇̞̣͇͕͂͠I͙̋͐̍͂̀D̶͕̩̦̲͙F̟̖̮ͩ̏ͥ̂ͨ͠ ͍̰̫̯͙̯ͨ̉ͤ̈̿ͭI̤͍̲̯ͤ̎̀͝S̴̻͇̳̗̩ͧ̆ ̭̘̦ͭ͒Ĉ̸̰̼̤̖̲O̹̭̞̺̻͚̣̒M̪͓̗̤͋͢Ĩ͔̗̣̻̄̏̏̏̚N̳̦̂ͯ̅͂̓̈́G͈̣
C
36
star
81

stb_image_js

stb_image.h wrapper for a Web Browser
C
36
star
82

data-mining-in-c

Notes and Source Code from the Data Mining in C series.
C
36
star
83

rust-browser-game

Bloat-Free Browser Game in Rust (rustc-only challenge)
Rust
35
star
84

simple-ocaml-raylib-template

Intentionally Simple Raylib OCaml Template
OCaml
35
star
85

voronoi-opengl

Voronoi with OpenGL using Depth Buffer
C
34
star
86

parcoom

Parser Combinators of Monad
OCaml
31
star
87

wacket

Racket to WebAssembly "compiler".
Racket
30
star
88

deque.py

Deque-based Programming Language
Python
30
star
89

zzzwe

zzzwe
JavaScript
29
star
90

command-pattern

Command Pattern (an Imperative one)
Rust
29
star
91

schedule

Schedule for Tsoding Streams
TypeScript
28
star
92

dedup

Duplicate Files Searcher
C++
28
star
93

turd

Turing Machine in D
D
28
star
94

skedudle

Simple Event Schedule Web Application in C
C
27
star
95

bezier

Just a fun little project to learn how to render Bézier Curves.
C
27
star
96

wisp

Wisp is a set of simple scripts for setting up small QEMU-based Virtual Machines
Shell
27
star
97

ht

This is the notes from a Hash Table in C stream.
C
26
star
98

turj

Turing Machine in Jai
C
26
star
99

atomato

A collection of different Cellular Automata implementations for recreational purposes
C
25
star
100

rope-jai

Rope simulation in Jai
24
star