I’ve always liked random and automated random things. While these are not strictly part of storytelling I’ve managed to bring them into DS106 whenever I can.
A while back I set up @DailyCreateBot for some reason or other. Obviously a Twitter bot of some kind to do with the Daily Create. I do remember having trouble with the OAuth requirements of the more recent Twitter API and giving up.
Last weekend, on a rainy day I blew the dust of my raspberry pi and got it online and set up as a server. I was not too sure what to do with it at the time.
During the week I did revisit a project to use the pi to flash some lights depending on a Twitter search. I don’t have hardware for that but I was interested in how simple the project was. There seems to be plenty of libraries that can sort out Authentication to Twitter for you now. A bit of googling and thinking, mostly googling and I have a Twitter bot set up.
The @DailyCreateBot will reply with a suggestion of a photo challenge of you mention him on Twitter. I am using the same list that Alan Levin provided for me for the photoblitz.
The @DailyCreateBot runs on Python. This is where the pi comes in I would not even know where to begin to find out how to host a python app but the pi lets me do that easily.
I am not proposing to write a step-by-step guide here but it is worth mentioning that several things went wrong or did not work as expected. All were beyond my 2 weeks worth of Python on the mechanical mooc . All were solved by a wee bit of googling and sometime just repeating things till they worked. The delight of working on a pi is that I knew I’d I totally messed up I could just reformat the SD card, install an so again and be back to square two.
I had already:
- installed one of the basic OS FOR THE PI
- Set up SSH access so that I can get ‘on’ to the pi from the terminal application on a mac and via SSH apps on iOS.
- set up the pi as a web server and sorted out the DNS
Next:
*I found a python library and example code that replied.
*I added logic to reply with a random string taken from a list of challenges.
*Tested it a bit.
Then I posted to the DS106 Google + group and a few kind folk tested it a bit. Rochelle asked:
That is cool +John Johnston . It worked for me right out of the bot box. Do we upload to Twitter, tag them DailyCreateBot? I’d like to see what others have done. 🙂
Which got me thinking. A quick google found a php/JavaScript solution to showing tweets with the hashtag #dailycreatebot and I’ve got this up and running.
All very much a work in progress. There are few things to be ironed out:
- the Python bot falls over every now and again complaining about UTF8 I need to google that some more.
- the web page showing images just uses the styles used in the demo of the code. I need to tidy it up and perhaps skip tweets with the hashtag but no images.
- there is also the problem Rochelle pointed out that if you reply to the bot you get another prompt. I wonder if I could turn off replies if there is an image in the tweet?
Anyway if your expectations are low you can join in:
- Tweet @DailyCreateBot and get a prompt.
- Tweet your photo with the hashtag #DailyCreateBot
- See what other folk are doing.
- Let me know of any interesting problems.