How to Connect Telegram Bot to MTProto Proxies via Node.js?
You can use this library for server side.
And then follow this method.
What Should I put in request?
Secret and port?
const bot = new TelegramBot(token, {
polling: true,
request: {
proxy: "http://127.0.0.1:1234",
},
});
I think you should use only address and port.
I will check that. But I think that need Secret too

Anyone Solve This Problem?
How could we use secret?
I have found only this library that support secret, try it.
I think that I solved this problem but I'm not sure. I use this costruction: 'secret@hostname:port'. I noticed byproperty "request" the module when I create the bot.
var bot = new TelegramBot(appConfig.token, {
webHook: {
port: appConfig.webhook.port
},
request: {
proxy:'secret@hostname:port'
}
});
But I have another problem, my bot doesn't answer, it doesn't react to message. I try use console.log(message) in the function for calling bot.on('message'). The debug concole keeps silence.
What do you think? What problem can it be? Please, help me.
Please correct me if I'm wrong but from I see there is no way to use MTProxy. options.request.proxy is passed to request's options which only supports http and https (not even socks). After all, telegram bot API uses HTTPS requests, not MTProto connections.
For SOCKS, there's a workaround:
import Socks5HttpsAgent from 'socks5-https-client/lib/Agent'
const bot = new TelegramBot(telegramBotToken, {
request: {
agentClass: Socks5HttpsAgent,
agentOptions: {
socksHost: url.hostname,
socksPort: url.port,
socksUsername: url.username,
socksPassword: url.password,
},
},
})
@IlyaSemenov Correct, as far as this library is concerned.
Most helpful comment
Please correct me if I'm wrong but from I see there is no way to use MTProxy.
options.request.proxyis passed torequest's options which only supports http and https (not even socks). After all, telegram bot API uses HTTPS requests, not MTProto connections.For SOCKS, there's a workaround: