Created
March 26, 2014 13:13
-
-
Save samplereality/9782844 to your computer and use it in GitHub Desktop.
In a Station of the Metro bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Twit = require('twit'); | |
var rita = require('rita'); | |
// In a Station of the Metro | |
// | |
// The apparition of these faces in the crowd: | |
// Petals on a wet, black bough. | |
// insert your twitter app info here | |
// var T = new Twit({ | |
// consumer_key: '', | |
// consumer_secret: '', | |
// access_token: '', | |
// access_token_secret: '' | |
// }); | |
lexicon = new rita.RiLexicon(); | |
String.prototype.capitalize = function() { | |
return this.charAt(0).toUpperCase() + this.slice(1); | |
} | |
function makeStation() { | |
var station = lexicon.randomWord('nn',2); | |
var apparition = lexicon.randomWord('nn',4); | |
var faces = lexicon.randomWord('nns',2); | |
var crowd = lexicon.randomWord('nn',1); | |
var petals = lexicon.randomWord('nns',2); | |
var wet = lexicon.randomWord('jj',1); | |
var black = lexicon.randomWord('jj',1); | |
var boughArray = lexicon.rhymes(crowd); | |
var bough = boughArray[Math.floor(Math.random() * boughArray.length)]; | |
while (lexicon.isNoun(bough) == false) { | |
bough = boughArray[Math.floor(Math.random() * boughArray.length)]; | |
} | |
var first = station.substr(0,1); | |
var article = "a"; | |
if (first === 'a' || | |
first === 'e' || | |
first === 'i' || | |
first === 'o' || | |
first === 'u') { | |
article = "an"; | |
} | |
var first2 = wet.substr(0,1); | |
var article2 = "a"; | |
if (first2 === 'a' || | |
first2 === 'e' || | |
first2 === 'i' || | |
first2 === 'o' || | |
first2 === 'u') { | |
article2 = "an"; | |
} | |
stanzaOne = "In " + article + " " + station + " of the Metro\u000A\u000A" | |
stanzaTwo = "The " + apparition + " of these " + faces + " in the " + crowd + ":\u000A"; | |
stanzaThree = petals.capitalize() + " on " + article2 + " " + wet + ", " + black + " " + bough + "."; | |
poem = stanzaOne.toUpperCase()+stanzaTwo+stanzaThree; | |
console.log(poem); | |
} | |
// Toggle Twitter by un/commenting next four lines | |
// T.post('statuses/update', { status: poem}, function(err, reply) { | |
// console.log("error: " + err); | |
// console.log("reply: " + reply); | |
// }); | |
// } | |
makeStation(); | |
// Tweet every 197 minutes | |
// setInterval(function () { | |
// try { | |
// makeStation(); | |
// } | |
// catch (e) { | |
// console.log(e); | |
// } | |
// }, 1000 * 60 * 197); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment