tag:dreamwidth.org,2009-05-01:152029jodijodijodi2011-03-02T10:41:34Ztag:dreamwidth.org,2009-05-01:152029:4786Twitter bot2011-03-02T10:29:46Z2011-03-02T10:41:34Zpublic8I decided to start learning Python by creating a Twitter bot. I have an online diary, that I have been keeping for over a decade now, and I decided that I would output lines from it as tweets, so that I could keep in touch with my younger self. If you want to see it in action: <a href="http://www.twitter.com/echochild">Echochild</a>.<br /><br /><span class="cut-wrapper"><span style="display: none;" id="span-cuttag___1" class="cuttag"></span><b class="cut-open">( </b><b class="cut-text"><a href="https://jodi.dreamwidth.org/4786.html#cutid1">Things I found odd to start with in Python</a></b><b class="cut-close"> )</b></span><div style="display: none;" id="div-cuttag___1" aria-live="assertive"></div><br /><br />There are quite a few Python to Twitter packages, but in the end, I decided upon <a href="https://github.com/joshthecoder/tweepy">Tweepy</a>.<span class="cut-wrapper"><span style="display: none;" id="span-cuttag___2" class="cuttag"></span><b class="cut-open">( </b><b class="cut-text"><a href="https://jodi.dreamwidth.org/4786.html#cutid2">Installing Tweepy</a></b><b class="cut-close"> )</b></span><div style="display: none;" id="div-cuttag___2" aria-live="assertive"></div><br /><br />I formatted the diary entries, using Vi, so that there is just one sentence per line.<br /><br />I got the appropriate authorisation tokens from Twitter: consumer token, consumer secret, etc.<br /><br />Due to access restrictions, I am unable to run cron jobs or leave things running in the background, so concluded that being able to tweet just by going to a web page would do. Not quite automatic, but still, will do for now.<br /><br />I then created a CGI script in the joshthecoder-tweepy-fcaff74 directory.<span class="cut-wrapper"><span style="display: none;" id="span-cuttag___3" class="cuttag"></span><b class="cut-open">( </b><b class="cut-text"><a href="https://jodi.dreamwidth.org/4786.html#cutid3">CGI script</a></b><b class="cut-close"> )</b></span><div style="display: none;" id="div-cuttag___3" aria-live="assertive"></div><br /><br />The next thing to do is make it actually reply to people!<br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=jodi&ditemid=4786" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> comments