|
|
@ -15,7 +15,7 @@ tokenHandler.getAccessToken((accessToken) => {
|
|
|
|
access_token: accessToken,
|
|
|
|
access_token: accessToken,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
let memeHandler = new MemeHandler(memeAPI, subreddits, allowedMedia);
|
|
|
|
let memeHandler = new MemeHandler(memeAPI, subreddits, allowedMedia);
|
|
|
|
executeAndSetInterval(() => {
|
|
|
|
executeAndSetInterval(function postRandomMeme(){
|
|
|
|
memeHandler.getRandomMeme(sub => {
|
|
|
|
memeHandler.getRandomMeme(sub => {
|
|
|
|
let status = `"${sub.title}"\n${sub.text}\nby ${sub.author}`;
|
|
|
|
let status = `"${sub.title}"\n${sub.text}\nby ${sub.author}`;
|
|
|
|
if (allowedMedia.find(type => type === sub.url.split(/[.]+/).pop())){
|
|
|
|
if (allowedMedia.find(type => type === sub.url.split(/[.]+/).pop())){
|
|
|
@ -24,7 +24,8 @@ tokenHandler.getAccessToken((accessToken) => {
|
|
|
|
client.postMedia(status, filepath);
|
|
|
|
client.postMedia(status, filepath);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
client.postStatus(status);
|
|
|
|
console.log("no valid media, fetching new sub")
|
|
|
|
|
|
|
|
postRandomMeme();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}, interval);
|
|
|
|
}, interval);
|
|
|
|