J
J
jestev2019-02-17 10:56:53
JavaScript
jestev, 2019-02-17 10:56:53

Why doesn't Telegram Bot work even with Proxy?

The first day I study the development of bots and immediately ran into a problem. At first, the bot did not work at all and, as I understood it, the problem was the lack of a proxy. Added them - now the error is different

const TelegramBot = require('node-telegram-bot-api')

const TOKEN = '...................................................................'

const bot = new TelegramBot(TOKEN, {
  polling: true,
    request: {
        proxy: 'https://11.22.33.44:1010/'
    }
})

bot.on('message', (msg) => {
  console.log(msg)
  bot.sendMessage(msg.chat.id, 'Здравствуйте, старина, ' + msg.from.first_name)
})

And here is the error
5c69138ba1b5f696640004.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxwi, 2019-02-17
@Maxwi

Https-proxy-agent use

const bot = new Telegraf(Token, {
    telegram: {
        agent: new HttpsProxyAgent({
            host: 'host',
            port: 'port',
            auth: 'username:password' // Если прокси приватный, если нет, то удаляйте строчку
        })
    }
})

And forget about node-telegram-bot-api, use Telegraf

A
Alexander Aksentiev, 2019-02-17
@Sanasol

Did you come up with proxies out of your head or what?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question