TypeError: __init__() got an unexpected keyword argument 'username' using http Proxy
I want to send messages through a HTTP proxy to Telegram. I have a simple code:
import telegram
from telegram.ext import Updater, CommandHandler
Bot_Token="MY_TOKEN"
Grp_ID="GROUP_ID"
REQUEST_KWARGS={'proxy_url': 'http://IP:PORT', 'urllib3_proxy_kwargs': {"username": "U_NAME" , "password": "PASSWORD"}}
updater = Updater(Bot_Token, request_kwargs=REQUEST_KWARGS)
bot_=updater.bot
bot_.send_message(chat_id=Grp_ID,text="Hello")
but I get the following error:
TypeError: __init__() got an unexpected keyword argument 'username'
How can I fix the issue? Thanks
When using http proxies you don't pass the username and password like that. Instead you want to do it directly in the proxy_url: 'http://U_NAME:PASSWORD@IP:PORT'.
I changed as you suggest. But again I get the following error:
telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botMYBOTID/sendMessage (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',)))
Could you try asking this question our Telegram group. In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel to participate in the group.
The group makes it easier to provide timely help :)
Sure, But when I click on the link I get the following error:
There is no Telegram account with the username you provided. Click for technical details <https://web.telegram.org/#/im?tgaddr=tg:%2F%2Fresolve%3Fdomain%3Dpythontelegrambotgroup>
Thank you.
On Wed, Sep 5, 2018 at 1:31 AM Jasmin Bom [email protected] wrote:
Could you try asking this question our Telegram group https://t.me/pythontelegrambotgroup. In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel https://webchat.freenode.net/?channels=#%23python-telegram-bot to participate in the group.
The group makes it easier to provide timely help :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/python-telegram-bot/python-telegram-bot/issues/1199#issuecomment-418516361, or mute the thread https://github.com/notifications/unsubscribe-auth/AVVaDq3IjqX0Febq5FFg9-l46Bs-4E5nks5uXuoPgaJpZM4WUuUC .
In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel to participate in the group.
https://webchat.freenode.net/?channels=##python-telegram-bot