Answer the question
In order to leave comments, you need to log in
Telegram bot freezes (hiroku hosting)?
There is a bot (test - training)
Bot on js
The bot itself is uploaded to heroku.com It starts
, works and freezes
Here is the log:
2020-05-28T08:43:50.357758+00:00 app[web.1]:
2020-05-28T08:43:50.357767+00:00 app[web.1]: > [email protected] start /app
2020-05-28T08:43:50.357767+00:00 app[web.1]: > node bot.js
2020-05-28T08:43:50.357768+00:00 app[web.1]:
2020-05-28T08:43:50.855446+00:00 app[web.1]: Бот запущен
2020-05-28T08:43:51.418671+00:00 heroku[web.1]: State changed from starting to up
2020-05-28T09:15:25.299481+00:00 heroku[web.1]: Idling
2020-05-28T09:15:25.302593+00:00 heroku[web.1]: State changed from up to down
2020-05-28T09:15:26.699556+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-05-28T09:15:26.895990+00:00 heroku[web.1]: Process exited with status 143
2020-05-28T09:18:17.833275+00:00 heroku[web.1]: State changed from down to starting
2020-05-28T09:18:21.545626+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-28T09:18:23.710890+00:00 app[web.1]:
2020-05-28T09:18:23.710905+00:00 app[web.1]: > [email protected] start /app
2020-05-28T09:18:23.710905+00:00 app[web.1]: > node bot.js
2020-05-28T09:18:23.710905+00:00 app[web.1]:
2020-05-28T09:18:24.501667+00:00 heroku[web.1]: State changed from starting to up
2020-05-28T09:18:24.335618+00:00 app[web.1]: Бот запущен
require('dotenv').config();
const { Telegraf } = require('telegraf');
const api = require('covid19-api');
const markup = require('telegraf/markup');
const COUNTRIES_LIST = require(`./constants`);
const bot = new Telegraf(process.env.BOT_TOKEN);
require('https')
.createServer()
.listen(process.env.PORT || 5000)
.on('request', function (req, res) {
res.end('');
});
bot.start((ctx) =>
ctx.reply(
`
Привет ${ctx.message.from.first_name}!
Узнай статистику по Коронавирусу.
Введи на англ. название страны и получи статистику.
Посмотреть название всех стран: /help.
`,
markup
.keyboard([
[`Ukraine`, `Russia`],
[`US`, `Italy`],
[`Canada`, `Portugal`],
])
.resize()
.extra()
)
);
bot.help((ctx) => ctx.reply(COUNTRIES_LIST));
// bot.start((ctx) => console.log(ctx));
bot.on('text', async (ctx) => {
let data = {};
try {
data = await api.getReportsByCountries(ctx.message.text);
const formatData = `
Страна : ${data[0][0].country}
Заболевшие : ${data[0][0].cases}
Смертей : ${data[0][0].deaths}
Вылечились : ${data[0][0].recovered}
`;
ctx.reply(formatData);
} catch {
ctx.reply(`ошибка: такой страны нет. Смотри /help`);
}
});
bot.launch();
console.log(`Бот запущен`);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question