@email@example.com: a server-less Mastodon bot
Why and how I built the simply server-less @firstname.lastname@example.org bot. And my tribute to Pieter.
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.
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 [@email@example.com][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)
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.
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.
But the requirements from a guru were clean
- using git(hub)
Whole bot is then a single 170 lines long program in 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.
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.
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.
And that’s all folks