КОД
# - *- coding: utf- 8 - *-
import asyncio
from logging import error
from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.contrib.middlewares import logging
import config
from handlers.default import startup as default
from handlers.inline import startup as inline
from utils.error import stratup as errors
from others.set_bot_commands import set_commands
import middlewares
from filters.filters import binds
from loader import bot, dp
async def on_startup():
await bot.send_message(776850045, 'Бот перезапущен')
async def main():
print('Started')
# фильтры
binds(dp)
# дефолт хендлеры для обработки инлайна и текста
default(dp)
inline(dp)
# обработка ошибок и логгирование
errors(dp)
# антифлуд
# middlewares.setup(dp)
# установка комманд
await set_commands(dp)
await on_startup()
try:
await dp.start_polling()
finally:
await dp.storage.close()
await dp.storage.wait_closed()
await bot.session.close()
if __name__ == "__main__":
try:
asyncio.run(main())
except (KeyboardInterrupt, SystemExit):
print('Bot STOPPED!!!')
Ошибки
Traceback (most recent call last):
File "C:\user\шейр\main.py", line 57, in <module>
asyncio.run(main())
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\user\шейр\main.py", line 42, in main
await on_startup()
File "C:\user\шейр\main.py", line 20, in on_startup
await bot.send_message(776850045, 'Бот перезапущен')
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\bot.py", line 341, in send_message
result = await self.request(api.Methods.SEND_MESSAGE, payload)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\base.py", line 236, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\api.py", line 140, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\utils\exceptions.py", line 140, in detect
raise err(cls.text or description)
aiogram.utils.exceptions.ChatNotFound: Chat not found
[ERROR] [21-Aug-22 00:57:46] | [base_events.py LINE:1744] | Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000209EBF114E0>
[ERROR] [21-Aug-22 00:57:46] | [base_events.py LINE:1744] | Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x00000209EB21C5E0>, 10817.781)]']
connector: <aiohttp.connector.TCPConnector object at 0x00000209EBF113C0>
[ERROR] [21-Aug-22 00:57:46] | [base_events.py LINE:1744] | Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x00000209EBF11960>
transport: <_ProactorSocketTransport fd=520 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 690, in _process_write_backlog
self._transport.write(chunk)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 361, in write
self._loop_writing(data=bytes(data))
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 397, in _loop_writing
self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function _SSLProtocolTransport.__del__ at 0x00000209EA558670>
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 321, in __del__
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 316, in close
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 599, in _start_shutdown
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 604, in _write_appdata
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 712, in _process_write_backlog
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 726, in _fatal_error
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 151, in _force_close
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed