-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
23 lines (19 loc) · 709 Bytes
/
bot.js
File metadata and controls
23 lines (19 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const { Telegraf } = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.on('message', async (ctx) => {
// resend existing file by file_id
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "https://fish-text.ru/get", false ); // false for synchronous request
xmlHttp.send( null );
let text = JSON.parse(xmlHttp.responseText).text;
await ctx.replyWithPhoto({
url: 'https://picsum.photos/300/300/?blur',
filename: 'kitten.jpg',
}, {caption: text});
})
bot.launch();
// Enable graceful stop