New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with russian telegram blocking? #562
Comments
I quickly looked through code, and found that all API interactions rely on var request = require('request-promise').defaults({
proxy:'http://username:password@host:port',
strictSSL :false
}); |
How to use it in bot? |
const request = require('request-promise').defaults(/* http proxy settings here */); Notice: it supports HTTP(s) proxies only, not socks |
Thank you. This works
|
Also you can use TelegramBot options like this: const bot = new TelegramBot(config.get('telegram_token'), {
polling: true,
request: {
// Proxy settings here
proxy: 'http:/***',
}
}); |
@samohovets Thank you. This work too. |
Please suggest which proxy to use?Is there any good free proxies? |
Please add support of SOCKS5 proxy. |
@Osrx const TelegramBot = require('node-telegram-bot-api')
const Agent = require('socks5-https-client/lib/Agent')
const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {
polling: true,
request: {
agentClass: Agent,
agentOptions: {
socksHost: process.env.PROXY_SOCKS5_HOST,
socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
// If authorization is needed:
// socksUsername: process.env.PROXY_SOCKS5_USERNAME,
// socksPassword: process.env.PROXY_SOCKS5_PASSWORD
}
}
}) I use this solution to continue developing bot on my local PC (I'm in Russia, so without proxy I can not start bots) and it works. |
@nskondratev can you please advise which proxies to use? |
@IzaGz I set up proxy server on DigitalOcean droplet, which costs $5 per month. |
one click to bypass Telegram block |
I use proxy how @nskondratev supposes and have the error: "Unhandled rejection RequestError: Error: connect ECONNREFUSED 127.0.0.1:1080". How can the library call localhost? |
@IzaGz you can use Tor Browser as SOCKS5 proxy. |
@nskondratev var options = {
url: "https://api.telegram.org/bot1111111...11/getMe",
agentClass: Agent,
agentOptions: {
socksHost: config.proxy.socksHost,
socksPort: config.proxy.socksPort,
socksUsername: config.proxy.socksUsername,
socksPassword: config.proxy.socksPassword
}
}
request(options, function (error, res, html) {
if (!error && res.statusCode == 200) {
console.log(html)
}else {
console.log(error)
}
}) But when i am trying to use "socks5-https-client" with 'node-telegram-bot-api': const bot = new TelegramBot(config.bot.token, {
polling: true,
request: {
agentClass: Agent,
agentOptions: {
socksHost: config.proxy.socksHost,
socksPort: config.proxy.socksPort,
// If authorization is needed:
socksUsername: config.proxy.socksUsername,
socksPassword: config.proxy.socksPassword
}
}
}); timeout error occurs. Could you please help to understand why proxy is not working with 'node-telegram-bot-api'? |
@IldarMurzenkov hi, what is the "config" ? Have same problem "error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: connect ECONNREFUSED 127.0.0.1:1080"}" |
How to bypass the telegram block in russia?
The text was updated successfully, but these errors were encountered: