- 182
- 83
Переписываю одного бота на aiogram, сам в асинке полный ноль, выходит вот такая ошибка при запуске main.py.
RuntimeWarning: coroutine 'weather' was never awaited
RuntimeWarning: coroutine 'weather' was never awaited
main.py:
from aiogram import executor
from loader import dp
from threads import *
from handlers import *
if __name__ == '__main__':
threadWeather.start()
executor.start_polling(dp, skip_updates=True)
loader.py:
from aiogram import Bot, Dispatcher, types
from data import TOKEN
bot = Bot(token=TOKEN, parse_mode="HTML")
dp = Dispatcher(bot)
threads/__init__.py:
from .weather import weather
from threading import Thread
threadWeather = Thread(target=weather, args=("10:56:00",))
threads/weather.py:
from main import bot
from data import admins
from datetime import datetime
from time import sleep
# 12:00:00
async def weather(time: str) -> None:
time = time.split(":")
while True:
_ = datetime.now()
if _.hour == int(time[0]) and \
_.minute == int(time[1]) and \
_.second == int(time[2]):
await bot.send_message(admins[0], "Время пришло!")
sleep(0.25)