0

我试图编写一个简单的电报机器人,但电报在我的国家受到审查,所以我使用代理来连接电报

这是错误信息

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\utils\request.py", line 252, in _request_wrapper 
    resp = self._con_pool.request(*args, **kwargs)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py", line 68, 
in request
    return self.request_encode_body(method, url, fields=fields,
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\poolmanager.py", line 
244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
    return self.urlopen(method, url, body, headers, retries,
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
    return self.urlopen(method, url, body, headers, retries,
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
    return self.urlopen(method, url, body, headers, retries,
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 665, in urlopen
    retries = retries.increment(method, url, error=e, _pool=self,
  File "F:\VS Pj\Telegram Bot\venv\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\retry.py", line 376, in increment

raise NetworkError(f'urllib3 HTTPError {error}') from error

telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', 
port=443): Max retries exceeded with url: /bot...token.../getMe (Caused by 
NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection 
object at 0x000001917CBD7760>: Failed to establish a new connection: [WinError 10061] No 
connection could be made because the target machine actively refused it'))

这是我的代码:

from telegram.ext import Updater
from telegram.ext import CommandHandler

updater = Updater("...token...")

def start(bot,update):
    chat_id = update.message.chat_id

    bot.sendMessage(chat_id=chat_id,text='connected')

start_command = CommandHandler('start',start)

updater.dispatcher.add_handler(start_command)

updater.start_polling()
updater.idle()

我应该怎么做才能得到结果?

4

1 回答 1

0

使用过滤器断路器,因为 Telegram 在某些国家/地区是过滤器。另外,不要使用赛风。

于 2021-06-09T18:50:56.480 回答