簡體   English   中英

如何解決 aiohttp 或 aiogram 的問題?

[英]How can i fix the problem with aiohttp or aiogram?

aiogram.utils.exceptions.NetworkError:Aiohttp 客戶端拋出錯誤:ClientConnectorError:無法連接到主機 api.telegram.org:443 ssl:默認 [超出信號量超時] 我在運行電報機器人的代碼時遇到此錯誤。 然后,我再次安裝了 aiohttp。 它已經消失了。 但這里還有另一個問題。 當我運行電報機器人的代碼時,機器人不工作。 他沒有回答我的命令,但控制台沒有錯誤。 沒有錯誤 - 但機器人不起作用。
有人可以幫我解決這個問題嗎? 我感謝任何建議和提示。 Python-3.8v

代碼:

from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
import time
from time import sleep
import selenium
from selenium import webdriver
import asyncio
bot = Bot('token')
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def start_message(message):
    await bot.send_message(message.chat.id, 'some text')

首先,您在終端中使用類似的命令運行python <program>

python test1.py

在終端中,您收到消息

INFO:aiogram.dispatcher.dispatcher:Start polling....

其次,你需要去 Telegram 應用程序,去你的機器人聊天。 並編寫命令,例如/start

添加:

loop = asyncio.get_event_loop()
executor.start_polling(self.dispatcher, skip_updates=True, loop=loop)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM