Browse Source

fix #2

master
Morgan Bazalgette 4 years ago
parent
commit
eac4480f97
1 changed files with 16 additions and 15 deletions
  1. +16
    -15
      index.js

+ 16
- 15
index.js View File

@@ -79,23 +79,24 @@ var sendPic = function(userID, chatID) {
splitPostUrl = postUrl.split("/");
filename = splitPostUrl[splitPostUrl.length - 1];
temp_filename = 'tmp/' + utils.r(0, 2000) + filename;
console.log("total derp. {0} - {1} - {2} - {3}".format(userID, chatID, temp_filename));
request(postUrl, function(err, re, body) {
bot.sendPhoto(
{
chat_id: chatID,
files: {
photo: temp_filename
},
caption: "source: http://gelbooru.com/index.php?page=post&s=view&id=" + actualPostID
}, function(){
fs.unlink(temp_filename, function(){});
memoryData.users[userID].queue -= 1;
if (memoryData.users[userID].queue > 0) {
sendPic(userID, chatID);
setTimeout(function() {
bot.sendPhoto(
{
chat_id: chatID,
files: {
photo: temp_filename
},
caption: "source: http://gelbooru.com/index.php?page=post&s=view&id=" + actualPostID
}, function(){
fs.unlink(temp_filename, function(){});
memoryData.users[userID].queue -= 1;
if (memoryData.users[userID].queue > 0) {
sendPic(userID, chatID);
}
}
}
);
);
}, 300); // Give the hard disk a break.
}).pipe(fs.createWriteStream(temp_filename));
});
});

Loading…
Cancel
Save