C
C
colcefer2019-11-11 12:37:55
Python
colcefer, 2019-11-11 12:37:55

How to send a message using a proxy?

How to do this through a proxy?

def location_client(message):
    with Client("my_account", api_id, api_hash) as app:
        app.send_location("@..............", message.location.latitude, message.location.longitude)
        bot.send_message(message.chat.id, 'Геолокация получена', reply_markup=keyboard5);

The telebot supports proxies, everything is so simple, but here is the code from above on heroku in timeout
from telebot import apihelper

# Включаем прокси для бота для тестов
# Установите последние версии библиотек gunicorn, PySocks, pyTelegramBotAPI, requests и urllib3
apihelper.proxy = {'https': 'http://login:[email protected]:8000'}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
colcefer, 2019-11-11
@colcefer

Usage
To use Pyrogram with a proxy, simply append the following to your config.ini file and replace the values ​​with your own settings:

[proxy]
enabled = True
hostname = 11.22.33.44
port = 1080
username = <your_username>
password = <your_password>

To enable or disable the proxy without deleting your settings from the config file, change the enabled value as follows:
1, yes, True or on: Enables the proxy
0, no, False or off: Disables the proxy
alternatively, you can setup your proxy without the need of the config.ini file by using the proxy parameter in the Client class:
from pyrogram import Client

app = Client(
    session_name="example",
    proxy=dict(
        hostname="11.22.33.44",
        port=1080,
        username="<your_username>",
        password="<your_password>"
    )
)

app.start()

...

Pyrogram can use SOCKS5, but I can't even figure out how to use HTTPS...and where to put it all...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question