Markov chain IRC bot and PoC exercise in golang and Redis
Meowkov is a simple Markov chain IRC bot. Created as a learning exercise in golang and Redis.
To start your own instance:
git clone https://github.com/lidel/meowkov.git
meowkov.conf.template
to meowkov.conf
and change at least BotName
, Channels
and RedisServer
make build
to build meowkov
binary./meowkov
make build
builds the appmake dev-updatedeps
updates dependencies to latest versions./meowkov
runs the app against meowkov.conf
in current directory./meowkov -c /some/path/meowkov.conf
runs the app with specified config fileecho "some text" | ./meowkov -import=true -purge=false
adds piped strings to the corpusecho "some text" | ./meowkov -import=true -purge=true
replaces corpus with piped data
(destructive, remember to backup Redis database before executing this)To start dockerized instance with latest Redis:
git clone https://github.com/lidel/meowkov.git
meowkov.conf.template
to meowkov.conf
and change at least BotName
and Channels
(RedisServer
will be set automatically by Docker)make docker-rebuild
to build (in foreground) and run (in background) via Docker containerMakefile
provides commands that simplify build and deployment.
Commands assume meowkov.conf
to be present in the same directory as Makefile
.
Redis data with corpus is persisted to data/dump.rpd
.
make docker-rebuild
builds the app and runs it in a containermake docker-update
same as docker-rebuild
but also checks for updates of golang
and redis
imagesmake docker-stop
stops already existing containermake docker-start
starts already existing containermake docker-logs
tails the output (runs in debug by default)make docker-clean
removes meowkov containers and a custom imageecho "some text" | make docker-corpus-add
adds piped strings to the corpusecho "some text" | make docker-corpus-replace
replaces corpus with piped data
(destructive, remember to backup data/dump.rpd
before executing this)The bot is as good as its corpus.
Running it with empty one will not produce any meaningful results for a long time.
It is a good idea to bootstrap the corpus using old IRC logs, news articles, etc.
Text can be loaded into the corpus (which is backed by Redis) like this:
echo "line one\nline two with more text" | make docker-corpus-add
or if run in standalone mode:
echo "line one\nline two with more text" | ./meowkov -import=true -purge=false
One may also want to generate input on a different machine, for example from weechat logs:
find ~/.weechat/logs -name "*#foo*" -type f -exec sh -c "grep -vP '^.+\t(</-|-->|--|.*\*)\t' {} | cut -f3 -d$'\t'" \; > corpus.txt
Then transfer the file to the box with meowkov and perform import there:
cat corpus.txt | make docker-corpus-add
Changes are instantaneous: corpus import can be performed while bot is running, no restart is required.
The same text can be imported multiple times: Markov chains are kept in Redis Sets which provide automatic deduplication.