I was trying to set up a telegram bot using Python according to this tutorial. The final script I wrote in Python is
import telebot
bot_name='gfjhsbot'
bot_api='1529995319:AAGb34vl-FkYRESLMZuIsTdrlLlP7mPHEyw'
bot=telebot.TeleBot(bot_api)
@bot.message_handler(commands=['greet'])
def greet_func(message):
bot.reply_to(message,'The first telegram bot is cool!')
bot.polling()
Normally, it should work, but unfortunately, telegram is filtered and I connect to my own account through proxies, like the following image from my telegram windows environment:
One of my proxy samples is
https://t.me/proxy?server=3.66.228.40&port=443&secret=dd7aaaaaaaaaaaaabbbbbbbbbbbbbbcd61
To this reason, the above Python script does not work (when running the script and writing /greet
as command in the bot, I do not get the response 'The first telegram bot is cool!'
I expect), returning the following error after about 5 seconds:
SSLError: HTTPSConnectionPool(host='api.telegram.org', port=443):
Max retries exceeded with url: /bot1529995319:AAGb34vl-FkYRESLMZuIsTdrlLlP7mPHEyw/getUpdates?offset=1&timeout=20
(Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))
Question
How can I connect to telegram bot through proxy using a Python line of code?
Thanks in advance!