Skip to content
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

Blocked Telegram in Russia #822

Closed
PallacHH opened this issue Apr 17, 2018 · 13 comments
Closed

Blocked Telegram in Russia #822

PallacHH opened this issue Apr 17, 2018 · 13 comments

Comments

@PallacHH
Copy link

As you know, telegrams were blocked in Russia and this caused difficulties in working with the bot. Can I add a proxy to the core when I request it?

@jacklul
Copy link
Collaborator

jacklul commented Apr 17, 2018

#667 (comment)

@PallacHH
Copy link
Author

PallacHH commented Apr 17, 2018

I can edit it only in files libary or i can

Request::setClient(new \GuzzleHttp\Client([
                'base_uri' => 'https://api.telegram.org',
                'proxy' => 'http://proxy',
            ]));  

?

if i have proxy with login and password, structure of string like this:
http://login:password@ip:port ?

@NovikovRoman
Copy link

NovikovRoman commented Apr 17, 2018

...
$telegram = new Telegram($apiKey, $botName);
Request::setClient(new \GuzzleHttp\Client([
        'base_uri' => 'https://api.telegram.org',
        'proxy' => 'http://111.111.111.111:1080',
]));
...

if i have proxy with login and password, structure of string like this:
http://login:password@ip:port ?
Yes

@PallacHH
Copy link
Author

Thanks

@jacklul
Copy link
Collaborator

jacklul commented Apr 17, 2018

You shouldn't edit it inside library, put the code I linked into your hook script /before handling updates.

@noplanman
Copy link
Member

As @jacklul already mentioned, just set the proxy client before handling the request.

Here is an example for using a local Tor proxy with SOCKS5:

$telegram = new Telegram(...);
...
Request::setClient(new Client([
    'base_uri' => 'https://api.telegram.org',
    'proxy'    => 'socks5://127.0.0.1:9050',
]));
...
$telegram->handle();

@kirush0280
Copy link

kirush0280 commented Apr 18, 2018

set.php:

try {
    // Create Telegram API object
    $telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);

    $telegram = Request::setClient(new \GuzzleHttp\Client([    'proxy'    => 'socks5://alex:xxxx@xxx.xxx.240.10:8088',]));

    // Set webhook
    $result = $telegram->setWebhook($hook_url);

    // Uncomment to use certificate
    //$result = $telegram->setWebhook($hook_url, ['certificate' => $path_certificate]);

...
PHP Fatal error: Uncaught Error: Class 'Request' not found in var/www/help.xxx.net/xxx/telegram/set.php:12

How to enable it right?

@akalongman
Copy link
Member

@kirush0280

  1. You have to import Request class first
  2. You do not need assign Request::setClient call to $telegram variable

@kirush0280
Copy link

Thank you. It works.

@31337Ghost
Copy link

Also when your DNS traffic is spoofed you should to use 'proxy' => 'socks5h:// against socks5:// whithout h

@timurkayzer
Copy link

Hi! @akalongman would you please tell what kind of Request it is, from which library?

@akalongman
Copy link
Member

@timurkayzer

\Longman\TelegramBot\Request

@frozencodeuz
Copy link

thanks it worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants