-
Notifications
You must be signed in to change notification settings - Fork 0
/
foustbot.js
147 lines (129 loc) · 8.39 KB
/
foustbot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// "And the ghosts, they own everything."
var Client = require('node-rest-client').Client;
var Twit = require('twit');
var async = require('async');
var wordFilter = require('wordfilter');
var env = require('dotenv').config();
var t = new Twit({
consumer_key: env.CONSUMER_KEY,
consumer_secret: env.CONSUMER_SECRET,
access_token: env.ACESSS_TOKEN,
access_token_secret: env.ACCESS_TOKEN_SECRET
})
// var wordnikKey = env.WORDNIK_API_KEY
run = function() {
async.waterfall([
// getNoun,
// getVerb,
// getPresentTense,
formatTweet,
postTweet
],
function(err, botData) {
if (err) {
console.log('There was an error posting to Twitter: ', err);
} else {
console.log('Tweet successful!');
console.log('Tweet: ', botData.finalTweet);
}
});
}
// getNoun = function(cb){
//
// var client = new Client();
// var wordnikRandomURL = 'http://api.wordnik.com:80/v4/words.json/randomWords?hasDictionaryDef=false' +
// '&includePartOfSpeech=noun&excludePartOfSpeech=proper-noun' +
// '&minCorpusCount=1000&maxCorpusCount=-1' +
// '&minDictionaryCount=1&maxDictionaryCount=-1&' +
// 'minLength=5&maxLength=-1&limit=10&api_key=';
// var args = {headers: {'Accept':'application/json'}};
// var wordnikURL = wordnikRandomURL + wordnikKey;
// console.log("getNoun URL: ", wordnikURL);
// client.get(wordnikURL, args, function (data, response) {
// if (response.statusCode === 200) {
// for(var i = 0; i < 1; i++){
// var temp = data[i];
// botData.noun.push(temp.word);
// }
// if (botData.noun.length) {
// cb(null, botData);
// } else {
// cb(null, null);
// }
// } else {
// cb(null, null);
// }
// });
// };
// getVerb = function(botData, cb){
// var client = new Client();
// var wordnikRandomURL = 'http://api.wordnik.com:80/v4/words.json/randomWords?hasDictionaryDef=false&includePartOfSpeech=verb' +
// '&minCorpusCount=0&maxCorpusCount=-1' +
// '&minDictionaryCount=1&maxDictionaryCount=-1&' +
// 'minLength=5&maxLength=-1&limit=10&api_key=';
// var args = {headers: {'Accept':'application/json'}}; var args = {headers: {'Accept':'application/json'}};
// var wordnikURL = wordnikRandomURL + wordnikKey;
// client.get(wordnikURL, args, function (data, response) {
// if (response.statusCode === 200) {
// for(var i = 0; i < 1; i++){
// var temp = data[i];
// botData.verb.push(temp.word);
// }
// if (botData.verb.length) {
// cb(null, botData);
// } else {
// cb(null, null);
// }
// } else {
// cb(null, null);
// }
// });
// };
// getPresentTense = function(botData, cb){
// var client = new Client();
// var wordnikPresentURL = 'http://api.wordnik.com:80/v4/word.json/'
// var wordnikPresentURLPart2 = '/relatedWords?useCanonical=false&relationshipTypes=verb-stem&limitPerRelationshipType=10&api_key=';
// var args = {headers: {'Accept':'application/json'}};
// var wordnikURL = wordnikPresentURL + botData.verb + wordnikPresentURLPart2 + wordnikKey;
// console.log("wordnikurl: ", wordnikURL);
// client.get(wordnikURL, args, function (data, response) {
// if (response.statusCode === 200) {
// if(!data.length){
// botData.present.push(botData.verb);
// } else {
// for(var i = 0; i < 1; i++){
// var temp = data[i];
// botData.present.push(temp.words);
// }
// }
// if (botData.present.length) {
// cb(null, botData);
// } else {
// cb(null, null);
// }
// } else {
// cb(null, null);
// }
// });
// };
formatTweet = function(cb){
var botData = {
finalTweet: ""
};
var conjunctions = ["For", "And", "But", "Or", "Yet", "So", "For", "And", "But", "Or", "Yet", "So", "Though", "Once", "While", "Since"];
var finals = ["something", "anything", "nothing", "everything"];
var nouns = ["weeks", "notes", "airports", "reactions", "thrills", "pies", "increases", "fuels", "houses", "credits", "dogs", "supports", "cars", "sticks", "baskets", "boats", "hooks", "jumps", "drawers", "toess", "bites", "boundaries", "mines", "oranges", "knees", "earthquakes", "earths", "horns", "moves", "cups", "dolls", "spoons", "loves", "coats", "sciences", "shapes", "servants", "eggs", "sacks", "purposes", "weights", "whips", "pigs", "statements", "notebooks", "rings", "sisters", "ends", "territorys", "quartzs", "cattle", "scales", "fairies", "tempers", "bloods", "threads", "tramps", "snakes", "cows", "suggestions", "haircuts", "taxex", "juices", "arithmetic", "legs", "hands", "breaths", "adjustments", "ranges", "wings", "protests", "partners", "pumps", "notebooks", "birthdays", "recesss", "trouserss", "downtowns", "turkeys", "rules", "frogss", "rakes", "boats", "pipes", "pushs", "badges", "boards", "plays", "companys", "hats", "yards", "golds", "antss", "hours", "fleshs", "cats", "knees", "glasss", "controls", "papers", "archs", "days", "lunchrooms", "dirts", "strangers", "arts", "bikess", "produces", "degrees", "apparels", "bridges", "weights", "breaths", "believes", "sugars", "laughs", "turns", "rocks", "roses", "attractions", "approvals", "fairiess", "winters", "sneezes", "feelings", "earths", "facts", "norths", "dogs", "jewels", "hospitals", "brothers", "loves", "limits", "points", "teachings", "planes", "seashores", "months", "crooks", "sizes", "elbows", "moms", "basketballs", "oatmeals", "bedss", "tops", "tongues", "stockings", "earthquakes", "sweaters", "minutes", "screws", "bells", "forces", "crowns", "monkeys", "interests", "keys", "plantations", "tricks", "stars", "deaths", "questions", "schools", "orders", "wounds", "scents", "chances", "marbles", "umbrellas", "stations", "years", "actions", "seats", "railways", "zincs", "tempers", "circles", "advertisements", "boots", "toys", "hills", "humors", "pizzas", "kisses", "wings", "pictures", "ministers", "queens", "cameras", "backs", "heats", "scarecrows", "fruits", "giraffes", "governments", "spoons", "uncles", "markets"];
var verbs = ["cross", "fancy", "shrug", "time", "dust", "wait", "try", "scream", "rhyme", "supply", "compete", "flood", "communicate", "radiate", "strengthen", "sip", "work", "yell", "share", "retire", "pop", "support", "milk", "examine", "chew", "last", "melt", "note", "relax", "raise", "zoom", "hope", "mine", "scold", "pine", "roll", "divide", "attempt", "announce", "spark", "play", "face", "welcome", "invite", "collect", "skip", "chop", "receive", "warn", "peel", "complain", "file", "smash", "bury", "earn", "fit", "nod", "plant", "admire", "moor", "confuse", "pretend", "search", "open", "preach", "possess", "drain", "puncture", "gather", "yawn", "replace", "care", "borrow", "exist", "wink", "trot", "educate", "crawl", "observe", "offer", "trade", "tap", "laugh", "reach", "tickle", "rinse", "obey", "bathe", "delay", "challenge", "wish", "disapprove", "drip", "sniff", "correct", "cheat", "cheer", "expand", "choke", "sparkle", "guarantee", "suspend", "wish", "apologise", "influence", "marry", "deserve", "reject", "appear", "mix", "blink", "fit", "yell", "ignore", "train", "answer", "drip", "offend", "invent", "carry", "decide", "regret", "reduce", "squeak", "sin", "claim", "nail", "guard", "disagree", "explode", "tour", "plan", "blot", "clean", "injure", "borrow", "push", "whisper", "guess", "rule", "flap", "permit", "need", "blush", "ban", "rush", "introduce", "dust", "embarrass", "play", "obey", "skip", "untidy", "pine", "bounce", "itch", "fold", "colour", "dream", "punch", "admit", "record", "note", "crush", "join", "face", "mourn", "pause", "steer", "signal", "clip", "pray", "scribble", "preserve", "precede", "scare", "rock", "stay", "radiate", "glow", "brush", "spray", "count", "flow", "prepare", "exercise", "advise", "rescue", "empty", "terrify", "box", "stuff", "spill", "boil", "love", "alert", "balance", "strengthen", "strap", "tap"];
var conjunction = conjunctions[Math.floor(Math.random()*conjunctions.length)];
var final = finals[Math.floor(Math.random()*finals.length)];
var noun = nouns[Math.floor(Math.random()*nouns.length)];
var verb = verbs[Math.floor(Math.random()*verbs.length)];
botData.finalTweet = conjunction + " the " + noun + " they " + verb + " " + final + ".";
cb(null, botData);
}
postTweet = function(botData, cb) {
t.post('statuses/update', {status: botData.finalTweet}, function(err, data, response) {
cb(err, botData);
});
}
run();