-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
23 lines (21 loc) · 944 Bytes
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const memobird = require('./src/memobird');
const telegram = require('./src/telegram');
telegram.on('text', (msg) => {
//console.log('text', msg);
//telegram.send(msg.chat.id, 'Received your message');
memobird.text(msg.text).then(result => telegram.send(msg.chat.id, '🖨 Sent to MemoBird'));
});
telegram.on('photo', async (msg) => {
//console.log('image', msg);
//telegram.send(msg.chat.id, 'Received your photo');
const txt = msg.caption || '';
const url = await telegram.getFile(msg.photo[1].file_id);
memobird.image(url, txt).then(result => telegram.send(msg.chat.id, '🖨 Sent to MemoBird'))
});
telegram.on('file', async (msg) => {
//console.log('file', msg);
telegram.send(chatId, 'Filetype not supported 😥');
return;
const url = await telegram.getFile(msg.photo[1].file_id);
memobird.image(url, caption).then(result => telegram.send(msg.chat.id, '🖨 Sent to MemoBird'))
});