-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
59 lines (51 loc) · 1.38 KB
/
test.js
File metadata and controls
59 lines (51 loc) · 1.38 KB
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
const fs = require('fs');
const TelegramBotAPI = require('./index.js');
const bot = new TelegramBotAPI('INSERT_YOUR_TOKEN_HERE');
(async () => {
try {
// Simple methods
console.log(await bot.getMe());
console.log(await bot.sendMessage({
chat_id: 888352,
text: 'Test',
reply_markup: {
inline_keyboard: [[{
text: 'Test',
callback_data: 'test',
}]]
}
}));
// Multiple ways to send files
const buffer = fs.readFileSync('./README.md');
const uint8 = new DataView(buffer.buffer);
console.log(await bot.sendDocument({
chat_id: 888352,
document: new File([uint8], 'READMEEE.md'),
document$name: 'readme.txt',
document$type: 'text/plain',
reply_markup: {
inline_keyboard: [[{
text: 'Test',
callback_data: 'test',
}]]
}
}));
const image = fs.readFileSync("C:\\Users\\denull\\Pictures\\calc.png");
const stream = fs.createReadStream("C:\\Users\\denull\\Pictures\\wiki.png");
const message = await bot.sendPhoto({
chat_id: 888352,
photo: image.buffer,
});
bot.editMessageMedia({
chat_id: 888352,
message_id: message.message_id,
media: {
type: 'photo',
media: 'attach://attach',
},
attach: stream,
});
} catch (error) {
console.error(error);
}
})();