Tram Alerts Twitter Bot

Why?

I’d been using the tram for years, it’s great mostly. Whenever there was a problem I’d invariably turn around and drive home and just work from home. Great if your job allows but annoyed I’d driven to Toton and back unnecessarily.

Often the info was there just waiting to be read. Over on Twitter but I’d miss it, forget to check. What to do 🤔 well if you favourite a Twitter account you’ll get a push notification every time they tweet, problem solved I thought, only they tweet good morning, which is nice I get it but I don’t want my phone going off everyday, just when there’s a problem.

So TramAlertsBot was born with the aim being to retweet just the travel updates and favourite that. Problem solved.

It’s currently written in Perl all in one file, authentication keys, phrase dictionary, code, it’s a mess.

A Python rewrite is now live, separate files for code, keywords and authentication, much cleaner. – Could probably go into Lambda next at near zero cost

It also trawls the status web page, I’ve not looked at rewriting this yet but it needs it and I’m always relived when it works… I’ve now rewritten this part in ruby. I tried with python and Beautiful Soup but I just couldn’t get on with it. So ruby and Nokogiri it is then, much better than grepping raw HTML, I’m able to parse/pull elements from the page, where I’m even able to tweet what the disruption is with some degree of confidence… until they change the webpage and it breaks…

For well over a year it’s been running at home on a zfs backup server. As a cloud engineer this is all wrong I know. Especially as I’ve now moved to and live in Spain. After recent hardware failures I’ve rescued the code, put it in git and hosting it in Nuremberg in the cloud, it runs on OpenBSD because everything that can run on OpenBSD should be run on OpenBSD where it’s backed up. Lesson learned