trilemabot [i]: introduction and self-voicing patch proposal

072 June 5, 2018 -- (tech)

First, the rationale and scope definition. In an ideal, purely platonic world, trilemabot represents a perfect cut of the points in the #trilema bot spec that are common to all #trilema bots, past, present and future. In practice, basing his or her bot upon the Republican ircbot standard, an operator could be served by some or all of the following pieces of scaffolding: self-voicing, a means to implement prefixed commands, querying deedbot to get WoT ratings or perform automated payments, and others -- the list, I suspect, is far from exhaustive. This is where trilemabot should prove itself useful.

Following discussions in the forum, this post presents a first patch proposal for trilemabot, that adds self-voicing on top of ircbot. Please note that this proposal is at the moment merely a draft: the final patch will be posted here after review by the Lordship, and as a regrind on top of ircbot1.

Now, without further ado, the README:

`trilemabot` extends `ircbot` with #trilema-specific functionality. See the
following for more details:

  * http://trilema.com/2016/how-to-participate-in-the-affairs-of-the-most-serene-republic/
  * http://trilema.com/2016/trilema-bot-spec/
  * http://thetarpit.org/posts/y04/072-trilemabot-i.html

Currently the following functionalities are implemented:

  * self-voicing with deedbot, using a list of pre-provided OTPs

INSTALL:

  * Install and load cl-irc and its dependencies

  * Install ircbot

  * Use V to press `trilemabot`

mkdir -p ~/src/trilemabot
cd ~/src/trilemabot

mkdir .wot
cd .wot && wget http://lucian.mogosanu.ro/spyked.asc && cd ..

v.pl init http://lucian.mogosanu.ro/src/trilemabot/
v.pl press trilemabot-voicer trilemabot-voicer.vpatch

  * Load `trilemabot` via Quicklisp or directly using ASDF:

(dolist (path '("/path/to/ircbot/" "~/src/trilemabot/trilemabot-voicer/"))
  (pushnew path asdf:*central-registry* :test #'string=))
(asdf:load-system :trilemabot)

And last but not least, USAGE:

(asdf:load-system :trilemabot)
(defvar *bot*)
(setq *bot*
      (trlb:make-trilemabot
       "chat.freenode.net" 6667 "nick" "password" '("#trilema")))

;; connect in separate thread, returning thread
(ircbot:ircbot-connect-thread *bot*)

;;;; 1. Self-voicing

;; ask for n !!up OTPs from deedbot
(loop for i from 1 to n do
  (trlb:trilemabot-send-up *bot*)
  (sleep 0.5))

;; get messages received from deedbot
(trlb:trilemabot-inbox *bot*)

;; add decrypted !!up OTPs
(trlb:trilemabot-add-voice-otps *bot*
 "decrypted-otp-1" "decrypted-otp2" ... "decrypted-otpn")

;; get the list of !!up OTPs
(trlb:trilemabot-voice-otp-stash *bot*)

;; save !!up OTPs to disk
(trlb:trilemabot-save-voice-otp-stash *bot* "voice-otps.sexp")

;; self-voice
(trlb:trilemabot-voice *bot*)

;; if `voice-otp-stash' is not empty, the bot will automatically
;; self-voice on reconnect
(ircbot:ircbot-reconnect *bot*)

  1. At the time of writing this is not possible because ircbot and trilemabot are separate modules, and they absolutely require a manifest as the binder that puts them in the same V tree.