{"id":1659,"date":"2015-05-21T20:11:48","date_gmt":"2015-05-21T19:11:48","guid":{"rendered":"http:\/\/johnjohnston.info\/106\/?p=1659"},"modified":"2015-05-21T20:16:58","modified_gmt":"2015-05-21T19:16:58","slug":"a-ds106-dailycreate-twitter-bot","status":"publish","type":"post","link":"https:\/\/johnjohnston.info\/106\/a-ds106-dailycreate-twitter-bot\/","title":{"rendered":"A #DS106 DailyCreate Twitter Bot"},"content":{"rendered":"<p><a href=\"http:\/\/pi.johnj.info\/DailyCreateBot\/\"><img decoding=\"async\" class=\"alignleft size-full wp-image-1662\" src=\"https:\/\/johnjohnston.info\/106\/wp-content\/uploads\/2015\/05\/dailycreate-bot.gif\" alt=\"dailycreate-bot\" width=\"240\" \/><\/a><a href=\"http:\/\/pi.johnj.info\/DailyCreateBot\/\">The DailyCreate Bot<\/a><\/p>\n<p>I&#8217;ve always liked random and automated random things. While these are not strictly part of storytelling I&#8217;ve managed to bring them into DS106 whenever I can.<\/p>\n<p>A while back I set up <a href=\"https:\/\/twitter.com\/DailyCreateBot\">@DailyCreateBot<\/a> 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.<\/p>\n<p>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.<\/p>\n<p>During the week I did revisit <a href=\"http:\/\/www.rigb.org\/christmas-lectures\/sparks-will-fly\/things-with-stuff\/twitter-emblem\">a project to use the pi to flash some lights depending on a Twitter search<\/a>. I don&#8217;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.<\/p>\n<p>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 <a href=\"http:\/\/johnjohnston.info\/photoblitzer\/\">photoblitz<\/a>.<\/p>\n<p>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.<\/p>\n<p>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 <a href=\"http:\/\/mechanicalmooc.org\">mechanical mooc<\/a> . 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&#8217;d I totally messed up I could just reformat the SD card, install an so again and be back to square two.<\/p>\n<p>I had already:<\/p>\n<ul>\n<li>installed one of the basic OS FOR THE PI<\/li>\n<li>Set up SSH access so that I can get &#8216;on&#8217; to the pi from the terminal application on a mac and via SSH apps on iOS.<\/li>\n<li>set up the pi as a web server and sorted out the DNS<\/li>\n<\/ul>\n<p>Next:<\/p>\n<p>*I found a <a href=\"https:\/\/github.com\/twitterdev\/sample-python-autoreply\">python library<\/a> and <a href=\"http:\/\/raspi.tv\/2014\/tweeting-with-python-tweepy-on-the-raspberry-pi-part-2-pi-twitter-app-series\">example code<\/a> that replied.<br \/>\n*I added logic to reply with a random string taken from a list of challenges.<br \/>\n*Tested it a bit.<\/p>\n<p>Then I posted to the DS106 Google + group and a few kind folk tested it a bit. <a href=\"https:\/\/twitter.com\/Rockylou22\">Rochelle<\/a> asked:<\/p>\n<blockquote><p>\n  That is cool +John Johnston . It worked for me right out of the bot box. Do we upload to Twitter, tag them DailyCreateBot? I&#8217;d like to see what others have done. \ud83d\ude42\n<\/p><\/blockquote>\n<p>Which got me thinking. A quick google found a <a href=\"http:\/\/www.queness.com\/post\/14004\/easiest-way-to-retrieve-twitter-timeline-and-hashtags-twitter-oauth-api-11\">php\/JavaScript solution to showing tweets<\/a> with the hashtag #dailycreatebot and I&#8217;ve got this <a href=\"http:\/\/pi.johnj.info\/DailyCreateBot\/\">up and running<\/a>.<\/p>\n<p>All very much a work in progress. There are few things to be ironed out:<\/p>\n<ul>\n<li>the Python bot falls over every now and again complaining about UTF8 I need to google that some more.<\/li>\n<li>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.<\/li>\n<li>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?<\/li>\n<\/ul>\n<p>Anyway if your expectations are low you can join in:<\/p>\n<ol>\n<li>Tweet <a href=\"https:\/\/twitter.com\/DailyCreateBot\">@DailyCreateBot<\/a> and get a prompt.<\/li>\n<li>Tweet your photo with the hashtag #DailyCreateBot<\/li>\n<li><a href=\"http:\/\/pi.johnj.info\/DailyCreateBot\/\">See what other folk are doing<\/a>.<\/li>\n<li>Let me know of any interesting problems.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>The DailyCreate Bot I&#8217;ve always liked random and automated random things. While these are not strictly part of storytelling I&#8217;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 &hellip; <a href=\"https:\/\/johnjohnston.info\/106\/a-ds106-dailycreate-twitter-bot\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A #DS106 DailyCreate Twitter Bot&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[81,91],"tags":[176,153,77,43,161,175],"class_list":["post-1659","post","type-post","status-publish","format-standard","hentry","category-dailycreate","category-mashup","tag-api","tag-fun","tag-javascript","tag-php","tag-python","tag-twitter"],"better_featured_image":null,"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3RLlC-qL","_links":{"self":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/1659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/comments?post=1659"}],"version-history":[{"count":4,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/1659\/revisions"}],"predecessor-version":[{"id":1664,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/posts\/1659\/revisions\/1664"}],"wp:attachment":[{"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/media?parent=1659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/categories?post=1659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johnjohnston.info\/106\/wp-json\/wp\/v2\/tags?post=1659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}