Skip to content

Commit

Permalink
buldpacks update, error handling in /torrent status
Browse files Browse the repository at this point in the history
  • Loading branch information
patheticGeek committed Jan 9, 2020
1 parent dad50cf commit 0cec22f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": "https://github.com/patheticGeek/torrent-aio-bot",
"keywords": ["node", "express", "bot", "torrent", "automation"],
"builpacks": [
"heroku/nodejs",
"https://github.com/jontewks/puppeteer-heroku-buildpack.git"
{ "url": "heroku/nodejs" },
{ "url": "https://github.com/jontewks/puppeteer-heroku-buildpack.git" }
]
}
46 changes: 25 additions & 21 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,31 @@ function bot(torrent) {
const link = match[1];

const status = torrent.getTorrent(link);
let result = "";
result += `Name: ${status.name}\n\n`;
if (status.speed) result += `Speed: ${status.speed}\n\n`;
result += `Downloaded: ${status.downloaded}\n\n`;
result += `Total: ${status.total}\n\n`;
if (status.redableTimeRemaining)
result += `Time remaining: ${status.redableTimeRemaining}\n\n`;
if (status.files) result += `No of files: ${status.files.length}\n\n`;
result += `Magnet Link: ${status.magnetURI}`;
bot.sendMessage(from, result);
if (status.progress === 100) {
let result2 = [];
status.files.forEach(file => {
let a = "";
a += `Name: ${file.name}\n\n`;
a += `Download Link: \n ${file.downloadLink}`;
result2.push(a);
});
result2.forEach(item => {
bot.sendMessage(from, item);
});
if (status) {
let result = "";
result += `Name: ${status.name}\n\n`;
if (status.speed) result += `Speed: ${status.speed}\n\n`;
result += `Downloaded: ${status.downloaded}\n\n`;
result += `Total: ${status.total}\n\n`;
if (status.redableTimeRemaining)
result += `Time remaining: ${status.redableTimeRemaining}\n\n`;
if (status.files) result += `No of files: ${status.files.length}\n\n`;
result += `Magnet Link: ${status.magnetURI}`;
bot.sendMessage(from, result);
if (status.progress === 100) {
let result2 = [];
status.files.forEach(file => {
let a = "";
a += `Name: ${file.name}\n\n`;
a += `Download Link: \n ${file.downloadLink}`;
result2.push(a);
});
result2.forEach(item => {
bot.sendMessage(from, item);
});
}
} else {
bot.sendMessage(from, "Torrent does not exists");
}
});

Expand Down

0 comments on commit 0cec22f

Please sign in to comment.