[Python] Python telegram bot via proxy with authentification

Discussão em 'Python' iniciado por Stack, Setembro 13, 2025.

  1. Stack

    Stack Membro Participativo

    everyone.

    I am trying to create a simple telegram bot. In my country telegram is blocked so I need to work via proxy.

    from telegram.ext import Updater
    from telegram.ext import CommandHandler

    import os

    def start(bot, update):
    print("Hello")
    bot.sendMessage(chat_id=512562849, text="Hello.")

    REQUEST_KWARGS={
    'proxy_url': 'http://93.171.217.48:10996',
    'urllib3_proxy_kwargs': {
    'username': '***',
    'password': '***',
    }
    }


    updater = Updater(token='<BOT_TOKEN>',
    request_kwargs=REQUEST_KWARGS)


    start_handler = CommandHandler('start', start)

    updater.dispatcher.add_handler(start_handler)
    updater.start_polling()


    But I have the next log

    Exception in thread updater:
    ...
    _HTTPConnection.__init__(self, *args, **kw)
    TypeError: __init__() got an unexpected keyword argument 'username'


    I used the next docs.

    The free proxy works ok, but for my goals, it's bad to lose connection time after time. I prefer not to work under VPN either because of some bureaucracy in my company.

    Thanks in advance!

    Continue reading...

Compartilhe esta Página