C
C
cepprice2018-10-04 21:15:53
Node.js
cepprice, 2018-10-04 21:15:53

How to run a Telegram bot on Node.js with Proxy?

process.env["NTBA_FIX_319"] = 1

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

const TOKEN = 'my_token' // changed

const bot = new TelegramBot(TOKEN, {
    polling: true,
    request: {
        proxy: 'http://46.105.57.149:43878/'
    }
});

bot.on('message', (msg) => {
    console.log(msg)
    bot.sendMessage(msg.chat.id, "Privet")
})

I get an error
error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: tunneling socket could not be established, cause=connect ETIMEDOUT 46.105.57.149:43878"}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zlo1, 2018-10-05
@zlo1

Use a proxy with connect support,
or better, connect using socks5 proxy
https://github.com/yagop/node-telegram-bot-api/iss...

Y
YouReTs, 2019-04-04
@YouReTs

Before starting the bot, write this in the console itself:

rem //  npm config set https-proxy http://user:[email protected]:8080
npm config set https-proxy http://46.105.57.149:43878/
npm config set https-proxy https://46.105.57.149:43878/

npm config rm proxy
npm config rm https-proxy
npm config --global rm proxy
npm config --global rm https-proxy
npm config delete proxy
npm config delete https-proxy

Or did you find another way? Write a comment below, I'd like to know...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question