A
A
AlessandrIT2019-11-13 14:50:18
Python
AlessandrIT, 2019-11-13 14:50:18

Why does the proxy work in the Telegram client but not in the Python bot?

There is a simple bot in Python for Cart,

the code
import telebot
from telebot import apihelper

token = '' #вписан верный

apihelper.proxy = {'https':'socks5://166.62.43.205:49683'}


bot = telebot.TeleBot(token)

@bot.message_handler(commands=['start'])
def start_message(message):
    bot.send_message(message.chat.id, 'Привет, ты написал мне /start')

@bot.message_handler(content_types=['text'])
def send_text(message):
    if message.text.lower() == 'привет':
        bot.send_message(message.chat.id, 'Привет, создатель')
    elif message.text.lower() == 'пока':
        bot.send_message(message.chat.id, 'Прощай, создатель')

bot.polling()


However, he cannot reach the Telegram servers. Sometimes it happens that the connection will appear, but literally for 10 seconds, and then rarely.
How to treat it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question