forked from Armanidrisi/Terabox-downloader-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (58 loc) · 1.96 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
async function main () {
const { Telegraf, Markup } = require("telegraf");
const { getDetails } = require("./api");
const { parseList, sendFile } = require("./utils");
const express = require('express');
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.start(async ctx => {
ctx.reply(
`Hi ${ctx.message.from.first_name},\n\nI can Download Files from Terabox.\n\nMade with ❤️ by @Mohd_arman_idrisi01\n\nSend any terabox link to download.`,
Markup.inlineKeyboard([
Markup.button.url(" Channel", "https://t.me/botcodes123"),
Markup.button.url("Report bug", "https://t.me/Armanidrisi_bot")
])
);
});
bot.on("message", async ctx => {
const messageText = ctx.message.text;
if (
messageText.includes("terabox.com") ||
messageText.includes("teraboxapp.com")
) {
const parts = messageText.split("/");
const linkID = parts[parts.length - 1];
// ctx.reply(linkID)
try{
const details = await getDetails(linkID);
if (details.ok) {
ctx.reply(`Sending ${details.list.length} Files Please Wait.!!`);
const list = parseList(details.list);
list.forEach(item => {
sendFile(
{
shareid: details.shareid,
uk: details.uk,
sign: details.sign,
timestamp: details.timestamp,
fs_id: item.fs_id
},
ctx
);
});
} else {
ctx.reply(details.message);
}
console.log(`${details}`);
}catch(e){
console.log (e.message)
}
} else {
ctx.reply("Please send a valid Terabox link.");
}
});
const app = express();
// Set the bot API endpoint
app.use(await bot.createWebhook({ domain: process.env.WEBHOOK_URL }));
app.listen(process.env.PORT || 3000,()=>console.log("Server Started"));
}
main();