Skip to content

Commit

Permalink
ajds
Browse files Browse the repository at this point in the history
  • Loading branch information
Lau Skeeter committed Mar 11, 2018
1 parent 1dd6076 commit b8ca84a
Show file tree
Hide file tree
Showing 7 changed files with 2,468 additions and 7,677 deletions.
204 changes: 204 additions & 0 deletions bin/adjectives.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
adorable
alive
ancient
angry
bad
beautiful
big
bitter
blue
boiling
boring
bourgeois
brave
brief
british
broad
broken
bumpy
calm
capitalist
careful
chilly
clean
clever
clumsy
cold
communist
cool
creepy
crooked
cuddly
curly
curved
damaged
damp
dead
decaf
soy-free
deep
defeated
delicious
delightful
dirty
dry
dusty
eager
early
easy
elitist
embarrassed
empty
faint
faithful
famous
fancy
fast
fierce
filthy
flaky
flat
fluffy
french
fresh
furry
gay
gentle
gifted
gigantic
glamorous
good
gray
greasy
great
green
grumpy
handsome
happy
heavy
helpful
helpless
high
hissing
hollow
homosexual
hot
huge
icy
immense
important
inexpensive
itchy
jealous
juicy
kind
large
late
lazy
lesbian
light
little
lively
long
loose
loud
low
lumpy
massive
melodic
melted
miniature
modern
moist
mushy
mysterious
narrow
nervous
new
nice
noisy
numerous
nutritious
obedient
obnoxious
odd
old
orange
own
panicky
petite
plain
poisonous
powerful
prickly
proud
public
puny
purple
purring
quaint
queer
quick
quiet
rapid
raspy
red
repulsive
rich
rotten
round
salty
scary
screeching
shallow
shiny
short
shy
silly
skinny
slow
small
spanish
sparkling
sparse
square
steep
sticky
straight
strange
strong
substantial
sweet
swift
tall
tart
tasteless
tasty
tender
thankful
thoughtless
thundering
tiny
toxic
ugly
uneven
unsightly
uptight
vast
vegan
victorious
warm
weak
weird
wet
white
wide
wide-eyed
witty
wooden
worried
wrong
yellow
young
yummy
zealous
13 changes: 11 additions & 2 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
require('dotenv').config();
const redis = require('redis');
const shuffle = require('shuffle-array');
const chalk = require('chalk');
const fs = require('fs');
const Twitter = require('twitter');
const makeSpanish = require('./../lib/makeSpanish.js');

const words = fs.readFileSync('./bin/words.txt').toString().split('\n');
const spanishWords = words.map(_ => [makeSpanish(_),_]).filter((word)=> word[0] !== word[1] );
const adjectives = fs.readFileSync('./bin/adjectives.txt').toString().split('\n');
const words = fs.readFileSync('./bin/words.txt').toString().split('\n').map(_=>(
[
(Math.random()>.25)?shuffle(adjectives)[0]:null,
_
].filter(_=>_!==null)
))


const spanishWords = words.map(_ => [makeSpanish(_).join(' '),_.join(' ')]);

spanishWords.forEach((w,i)=>{
console.log(w);
Expand Down
48 changes: 25 additions & 23 deletions bin/tweet.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
require('dotenv').config();
const redis = require('redis');
const chalk = require('chalk');
const shuffle = require('shuffle-array');
const fs = require('fs');
const Twitter = require('twitter');
const makeSpanish = require('./../lib/makeSpanish.js');

const words = fs.readFileSync('./bin/words.txt').toString().split('\n');
const spanishWords = words.map(makeSpanish);
const adjectives = fs.readFileSync('./bin/adjectives.txt').toString().split('\n');
const words = fs.readFileSync('./bin/words.txt').toString().split('\n').map(_=>(
[
(Math.random()>.25)?shuffle(adjectives)[0]:null,
_
].filter(_=>_!==null)
))

const client = redis.createClient(process.env.REDIS_URL);

Expand All @@ -21,32 +27,28 @@ client.on('error', function (err) {
console.log('Error ' + err);
});

client.get('last', function(err, reply) {
client.get('last', function(err, i) {
if(err) {
console.error(err);
client.set('last', 0, redis.print);
}
console.log(`starting at ${reply}/${words.length}`);
console.log(`starting at ${i}/${words.length}`);
let posted = false;
for(let i = reply; i < words.length; i++) {
if(spanishWords[i]!==words[i]) {
const tweet = [`πŸ‡¬πŸ‡§ ${words[i]}`,`πŸ‡ͺπŸ‡Έ ${spanishWords[i]}`].join('\n');
posted = true;
client.set('last', parseInt(i)+1);
chirpy.post('statuses/update', {status: tweet}, (error) => {
if(error) {
console.error(chalk.red('✘ Post failed'));
console.error(error);
throw error;
}
else {
console.info(chalk.green(`βœ” Posted: ${tweet}`));
}
});
break;
}
}
if(!posted) {
if(words[i]) {
const tweet = [`πŸ‡¬πŸ‡§ ${words[i].join(' ')}`,`πŸ‡ͺπŸ‡Έ ${makeSpanish(words[i]).join(' ')}`].join('\n');
posted = true;
client.set('last', parseInt(i)+1);
chirpy.post('statuses/update', {status: tweet}, (error) => {
if(error) {
console.error(chalk.red('✘ Post failed'));
console.error(error);
throw error;
}
else {
console.info(chalk.green(`βœ” Posted: ${tweet}`));
}
});
} else {
console.error(chalk.red('✘ Ran out of words'));
client.set('last', 0, redis.print);
}
Expand Down
Loading

0 comments on commit b8ca84a

Please sign in to comment.