Answer the question
In order to leave comments, you need to log in
How to run pyTelegramBotAPI?
I decided to try writing my own telegram bot:
import telebot
bot = telebot.TeleBot('МойТокен')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, 'Привет, ты написал мне /start')
bot.polling(none_stop=True)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botМойТокен/getUpdates?offset=1&timeout=20 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x040C7838>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=3.5)
Answer the question
In order to leave comments, you need to log in
try instead on
Also check Windscribe's connection, suddenly connected to CIS countries. In the worst case, reinstall the library and regenerate the token for the bot.
Also try writing this:bot.polling(none_stop=True)
bot.infinity_polling(True)
if __name__ == '__main__':
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
time.sleep(3)
print(e)
For some reason, the bot cannot connect to the telegram servers. It's strange that with the use of VPN the error remained. Perhaps the matter is in the Internet connections, or it is worth changing the VPN or its server. Check the connection on whoer.net, if it shows that your ip is not Russian, then it's not a VPN.
Go to @BotFather and create a bot, after creation you will be given a Token. You paste it here
bot = telebot.TeleBot('MyToken')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question