Why and how I built the simply server-less @hintjensquotes@botsin.space bot. And my tribute to Pieter.

bot’s main page

Recently I setup the Mastodon bot serving quotes of Pieter Hintjens. Pieter was one of the most influential man I ever met. And I do consider his ideas as brilliant, though-provoking, sometimes counter intuitive and typically in a sharp opposition to industry practices. His list of achievements is amazing, he was a president of Foundation for a Free Information Infrastructure fighting the software patents in Europe. He acted as CEO of imatix, where they developed many things including Xitami web server, GSL code generator and OpemAMQ AMQP 0.9 server.

From recent past he has famous for ZeroMQ project he co-founded. He was a force behind the community pushing a lot of former imatix experience to his open source project, namely high level bindings for libzmq czmq, C/C++ project skeleton generator, zproject, client/server generator zproto and so.

Pieter

Sadly as he suffers the terminal phase of a cancer, he took euthanasia in October 4th 2016. Despite his friends took over websites to maintain his legacy, the digital footprint of a person is typically dying too. Domains got expired, links are no longer valid. Or as it happened recently, the Wikidot, the engine behind his former homepage was destroyed by hackers and turned offline.

Pieter spent most of his professional life building distributed messaging applications and have a great passion for the open source. Therefor the Mastodon Fediverse looks like the best place to publish his words giving them an after life. I am pretty sure he would love the idea and [@hintjensquotes@botsin.space][https://botsin.space/@hintjensquotes bot].

That would be the why part. The how is fortunately simple. All in all what it does is to provide Pieters’s quotes, so having it running on top cluster on top of Hadoop on top of RabbitMQ on top of Kafka sending stuff via CORBA or JMS would not be in the spirit.

The Lazy Perfectionist

Never design anything that’s not a precise minimal answer to a problem we can identify and have to solve. (Pieter Hintjens)

The Lazy Perfectionist and other Patterns

Engineers and designers love to make stuff and decoration, and this inevitably leads to complexity. It is crucial to have a ‘“stop mechanism”’, a way to set short, hard deadlines that force people to make smaller, simpler answers to just the most crucial problems.

How to Design Perfect (Software) Products

And a last, but not least

Use Git and Github

I am not going todignify this with a non-zero number. If you aren’t using git and github.com then you are already making excuses for doing it wrong. It is not about fashion or groupthink. Github (the company) know how to make Good Code, and their tools reflect this.

Ten Rules for Good code

Note that the github advice was written in 2015, eons before Microsoft takeover and Pieter got worried about it in a meantime. There are alternatives like gitlab or codeberg, SourceHut.

But the requirements from a guru were clean

  • simple
  • using git(hub)

Whole bot is then a single 170 lines long program in Go: main.go. Go is compiled language, but go run command and the focus on a compilation speed, makes it suitable for a scripting work. And since Go is statically typed language, yet a simple, it is great alternative to traditional shell, Python, Perl or Ruby.

Quotes themselves are in a plain yaml file, which is embeded into Go variable during a build. {retty neat feature simplifying the code even more.

Bot will then choose a random number capped by number of quotes, traverse the list of articles and quotes to find a proper one and send it to Mastodon. The most challenging part was to find a way how to actually post the status, however fellow Python devs posted quite some howtos.

TL;DR; is create an account on botsin.space, in development create an application, copy the access token to your application code and that’s it.

Mastodon application setup

And the serverless part? I did not want to setup some machine, or to deploy the code into my Turris router and make it running from there. As serverless means to use other’s server, the Github and Github Actions was the best place to ensure bot actually runs daily.

Github Action daily.yml

And that’s all folks