电报Bot代理Python

时间:2020-04-06 16:19:34

标签: python proxy telegram-bot

美好的一天,今天,我决定写一个电报机器人,但是由于需要使用代理服务器,我尝试了所有方法,安装了VPN(免费),该机器人无法启动,尝试了免费代理,该机器人没有从他们开始,我买了几个代理,但没有帮助。请帮助我,我真的很想学习如何用Telegram开发机器人。

import telebot 
import requests
from telebot import apihelper
import time

token = '1257478688'
bot = telebot.TeleBot(token, threaded= False)
apihelper.proxy = {'https':'socks5://87.247.143.209:45576'}

@bot.message_handler(comands=['start'])
def start_message(message):
    bot.send_message(message.chat.id,'Привет, я буду присылать тебе лучшие фильмы по жанрам, только попроси')


while True:
    try:
        bot.polling(none_stop=True,interval=0,timeout=20)
    except Exception as E:
        print(E.args)
        time.sleep(2)

错误已更改,当我开始使用付费代理时,看起来像这样:

(MaxRetryError("SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: 
/bot1257478688/getUpdates?offset=1&timeout=20 (Caused by NewConnectionError
('<requests.packages.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x03909E10>: 
Failed to establish a new connection: 0x02: Connection not allowed by ruleset'))"),)


0 个答案:

没有答案