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:
- Clone the repo:
git clone https://github.com/lidel/meowkov.git
- Copy
meowkov.conf.template
tomeowkov.conf
and change at leastBotName
,Channels
andRedisServer
- Run
make build
to buildmeowkov
binary - Run
./meowkov
- That is all: meowkov bot will join specified room after a few seconds
make build
builds the appmake dev-updatedeps
updates dependencies to latest versions./meowkov
runs the app againstmeowkov.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:
- Clone the repo:
git clone https://github.com/lidel/meowkov.git
- Copy
meowkov.conf.template
tomeowkov.conf
and change at leastBotName
andChannels
(RedisServer
will be set automatically by Docker) - Run
make docker-rebuild
to build (in foreground) and run (in background) via Docker container - That is all: meowkov bot will join specified room after a few seconds
Makefile
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 asdocker-rebuild
but also checks for updates ofgolang
andredis
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 backupdata/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.