Link Dump

 

bot summit
http://www.crummy.com/2013/11/27/0

 

Wikipedia: meet the man who has edited 3m articles - because he’s written editing bots.

 

How to spot a Social Bot on Twitter (2014.06)
Twitter bots grow up and take on the world (2014.08)

 

 

bot impersonation - identity theft ?

 

twitterbot with scraperwiki and IFTTT

 

 

Using Heroku

  • See Also publishing a heroku app
  • Will need to initiate an app.
  • Install environment settings (no doubt) (see below)
  • copy the environment settings locally
  • create the Procfile - which is probably
    worker node index.js
  • run locally using foreman start worker

 

 

Config file

In order to be able to commit to .git and not put your actual auth-tokens into the file, use something like this:

 

module.exports = {
    consumer_key:         process.env.CONSUMER_KEY,
    consumer_secret:      process.env.CONSUMER_SECRET,
    access_token:         process.env.ACCESS_TOKEN,
    access_token_secret:  process.env.ACCESS_TOKEN_SECRET,

    // static_lib:           (process.env.STATIC_LIB.toLowerCase() === 'true'),
    tweet_on:             (process.env.TWEET_ON.toLowerCase() === 'true'),
    log:                  (process.env.LOG.toLowerCase() === 'true'),
    seconds:              parseInt(process.env.SECONDS, 60),
    minutes:              parseInt(process.env.MINUTES, 1)
};

 

Using Google Spreadsheet with apps script

Using Google Spreadsheets for a generated text Twitter bot

  • updated article - uses new OAuth script required by Twitter changes
  • my (unmodified?) copy
  • solanasbot01 variant (private to me)
    • the “first” variation used the original code, but with a single row of apx 20 sentences.
    • Second variant had a single column, and modified code (which I should document).
  • NOTE: scripts (of at least this kind) will continue running on the Google server, even after the spreadsheet/script browser-tabs are closed.

 

http://www.kahero.net/creating-twitter-bot-using-google-app-script/

 

google docs on apps-script

 

Darius Kazemi sources

How to make a Twitter Bot

How I built metaphor-a-minute

https://github.com/dariusk/twoheadlines
http://tinysubversions.com/twoheadlines/docs/
https://github.com/dariusk/rapbot

 

twitter-bot starter-kit - using grunt-init

 

Other resources

http://blog.tullyhansen.com/post/62774813528/fake-it-til-you-make-it-a-basic-bot-primer-for-the

 

http://dghubble.com/blog/posts/twitter-app-write-access-and-bots/

 

twitter bot on heroku

 

https://github.com/zwass/heroku-twitterbot-starter - python
Five Steps To Build Your Own Random Non-Sequitur Twitter Bot

 

A Twitter Bot in 20 Minutes With Node.js

 

Basic Twitter-bot Etiquette

 

scrub output for “bad” words: https://github.com/dariusk/wordfilter

 

Underscore.js stuff (for templating)

http://braddunbar.net/2013/08/19/underscore-templates/
Best Practices When Working With JavaScript Templates
Getting cozy with underscore.js
An introduction to underscore.js

 

http://underscorejs.org/#template - official docs

 

Everything you need to know about underscore template is here. Only 3 things to keep in mind:

 


    <% %> - to execute some code
    <%= %> - to print some value in template
    <%- %> - to print some values with HTML escaped

 

That’s all about it.

 

Simple example:

 

var tpl = _.template("<h1>Some text: <%= foo %></h1>");

 

then tpl({foo: "blahblah"}) would be rendered to the string <h1>Some text: blahblah</h1>

 

 

 

 

TODO: move this to a dedicated page in WebDevelopment

 

Using Wordnik for bots

See Wordnik
See https://github.com/dariusk/rapbot/blob/master/rapbot.js which uses multiple calls.

 

 

editing the text

Split into sentences
sorted by length

 

http://txt.binnyva.com/2009/04/sort-by-line-length/

 

cat /etc/passwd | awk '{print length, $0}' | sort -n | awk '{$1=""; print $0 }'
Didn’t work on my windows system, but cat | awk | <file> worked, so then I fired it up in Emacs, where sort-numeric-fields did the trick. I then deleted the numbers at the front of each line: ^[0-9]*\s-
Well, I also only selected the lines that had < 140 chars.

 

Could do this “easier” in a node.js script.
Will look into it.
Or in emacs, I suppose....

 

 

Auth Issues

TODO: try the get_tokens.js tool from aparrish’s example-twitter-bot-node

 

 

I ran into some authentication issues and.... I’m still not sure how I resolved them. Initially, on Wednesday, I couldn’t get the app set to do read+write, said I needed a mobile phone, and twitter would crash when I tried to add one (I think because my mobile number is already connected an account. My _real_ one).

 

Anyway. Later on it worked, without prompting for mobile.
Second bot had no issues.

 

Third bot had the auth troubles again -- insisted I need a mobile.
Ultimately, I deleted the mobile from my main account and added it to the bot so I could authenticate.
Then I deleted the mobile and re-added it to my profile.
UGH

 

I was able to use the techniques in twitter app write access and bots after installing ruby. Can’t find this functionality in anything else at the moment... More notes on twurl

 

I... don’t know where I installed ruby. It only appears at home as part of Heroku. so, I added that to the path. OK?

 

NOTE: capture the consumer-key and consumer-secret from the bot-application created under the main account (mine).

  1. Get access token
    1. Go to http://apps.twitter.com and select the app.
    2. Select the Keys and Access Tokens tabs.
    3. Log out.
    4. alternatively, you might them stored in Passpack or Keepass or something

 

  1. Log in to bot-account.
  2. do the command-line to authorize this account
    1. twurl authorize --consumer-key "[consumer-key]" --consumer-secret "[consumer-secret]"
  3. copy the URL provided
    1. looks like
      https://api.twitter.com/oauth/authorize?oauth_consumer_key=foo&oauth_nonce=bar&oauth_signature=v4aJ5M45HSE%baz%253D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1426708098&oauth_token=quz&oauth_version=1.0
  4. paste into browser
  5. authorize the app
  6. enter the PIN back into the shell1
    1. NOTE: I thought the application wasn’t working because there was no prompt for the PIN.
    2. There isn’t any. Just start typing.
    3. twurl seg-faults for me in cmder. At work, anyway. On lunch.
  7. get the new values from the .twurlc file for your bot
    1. the .twurlc file was create for me in C:\users\<username>\ - but if you have a HOME environment variable, it could be elsewhere.
    2. Using Heroku? You’ll need something like the following to set the env-vars:
      1. heroku config:set CONSUMER_KEY=foo CONSUMER_SECRET=bar ACCESS_TOKEN= ACCESS_TOKEN_SECRET= TWEET_ON=true LOG=true MINUTES=15 SECONDS=60
    3. or, edit the .env file directly if you have it
      1. the ACCESS_TOKEN_ and ACCESS_TOKEN_SECRET keys are the targets
      2. CONSUMER_KEY and CONSUMER_KEY_SECRET are the shared keys for the app

 

 

Consumer Key? Consumer Secret?

I don’t know why it’s called that in every blasted articled I’ve read, since Twitter (as of 2014.08) calls it the API Key and API Secret

 

Go figure.

 

alternative libraries

https://github.com/aparrish/example-twitter-bot-node/blob/master/get_tokens.js
https://www.npmjs.com/package/qauth

 

 

 

See Also

WordSalad.TwitterBotProject - in which I write some (surprise!) Twitter bots.
WordSalad.AutomaticForThePeople
WordSalad.WritingMachines
MicroBlogging
posts tagged bots on michaelpaulukonis.com

 

 

Category tags

Twitter Bots MicroBlogging Automation OAuth Authentication Heroku Cloud


 

Comments

No comments yet.

 

 

Add Comment

Heading:
 Your Message
 
 Enter value ← Have you entered the code number?
Author: