thrownewerrors.HttpError(`Encountered a non-200 status code for Pastebin.com while retrieving a raw paste: ${response.statusCode}`,{type:"statusCode"});
}elseif(response.body.toString().indexOf("Please slow down, you are hitting our servers unnecessarily hard!")===0){
noDecode:true/* Because Pastebin.com errors aren't JSON... */
});
}).then((response)=>{
if(response.statusCode!==200){
thrownewerrors.HttpError(`Encountered a non-200 status code for Pastebin.com while listing the most recent pastes: ${response.statusCode}`,{type:"statusCode"});
}else{
returntryParseBody(response.body).reverse();
}
}).tap((pastes)=>{
previousKnownPastes=knownPastes;
knownPastes=pastes.map(paste=>paste.key);
}).filter((paste)=>{
return(!previousKnownPastes.includes(paste.key));
}).tap((pastes)=>{
debug(`Found ${pastes.length} new pastes`);
}).each((paste)=>{
/* We *intentionally* do not return the Promise chain below; we don't want to block the interval with queue items. */
Promise.try(()=>{
returnqueue.push("fetchPaste",{
pasteKey:paste.key
});
}).then((rawPaste)=>{
this.emit("paste",Object.assign({
raw:rawPaste
},paste));
}).catch((err)=>{
this.emit("error",err);
});
}).catch((err)=>{
/* This is where eg. rate-limiting errors will end up. */