a vkontakte bot implementing some neat text&image-based quest challenges
- a recent version of rust (developed on 1.41)
- an instance of redis accessible on
redis://127.0.0.1/
- go to settings -> api usage
- create a new token with the following rights: community management, community messages, photos
- switch to the long poll api tab
- enable it
- uncheck all event types but message received
mkdir static
and put all static content (texts and images) in there.
if you are not sure what files you need, move along to the next step,
the compiler will error out on missing entries
cargo run -- <behavior>
see below for a list of available behaviors
prepare the server:
apt-get install redis
vim /etc/redis/redis.conf
:- navigate to the append only mode section and set
appendonly
toyes
. it is a good idea to keep bothAOF
andRDB
(only the latter is enabled by default).
- navigate to the append only mode section and set
service redis restart
- create a shell script to make the bot resilient to failures:
#/bin/bash echo "Starting salmonbot $1, log file: salmon-$1.log (append mode)" while true; do ./salmonbot $1 2>&1 | tee -a salmon-$1.log echo "Panic encountered (exit code $?), restarting the bot..." done
build the bot and upload it:
cargo build --release
(might take a few minutes)scp target/release/salmonbot ocean:~
run it:
ssh ocean
./hacky-shell-script.sh <behavior>
pray
perform perceptual image comparison against a hardcoded hash, additionally preventing the player from participating more than once (the player's id is stored/looked up in a set)
control the player's progression through the challenge by placing their id in buckets (sets) according to the submitted image
the challenge is split into several stages with distinct images. to advance to the next one, the player's id needs to exist in all buckets for the current stage
reply with perceptual hashes of submitted images — handy for development and testing