I have a telegram bot and want to send messages using python requests. In my country sending request to telegram is blocked. I don’t know How to config the proxy to send message to telegram. “vless” and “vmesss” proxies work fine in v2rayN windows software but they don’t work in request proxies. Your help would be appreciated. I get error:
ConnectionError: HTTPSConnectionPool(host=’api.telegram.org’, port=443): Max retries exceeded with url:
No connection could be made because the target machine actively refused it
Here is the codes I tried:
import requests
import telebot
bot_token = 'sample_token'
proxies=dict(http='vless://[email protected]:80?path=%2FSvnTeam-TeleGram-ChaNnel-VIP%3Fed%3D2048&security=none&encryption=none&host=SvnTeamV2rayGmOne7.7.7.7.ir.Com.Site.xn--fhq0laa256bac7403eea044azr5g.CoM.&type=ws#%40expresfree%F0%9F%87%A9%F0%9F%87%AAVIP-1')
url = f"https://api.telegram.org/bot{bot_token}/getUpdates"
print(requests.get(url=url,proxies=proxies ).json())
bot = telebot.TeleBot(bot_token)
bot.send_message(chat_id='12345678', text="Hello world")