import time
from datetime import datetime
time = datetime(datetime.now().year, datetime.now().month, datetime.now().day, datetime.now().hour, datetime.now().minute)
if time.hour == <час> and time.minute == <минут>:
await bot.send_message(message.from_user.id, f'Время: {time.hour}:{time.minute}')
else:
await bot.send_message(message.from_user.id, time)
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
import asyncio
from datetime import datetime
bot = Bot(token=os.getenv('TOKEN'))
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def command_start(message : types.Message):
while True:
await asyncio.sleep(1)
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
if current_time == '23:44:01':
await bot.send_message(message.chat.id, f'"Это сообщение отправлено в {current_time}"')
@dp.message_handler(commands=['mess'])
async def command(message : types.Message):
await bot.send_message(message.chat.id, 'Для полной картины, асинхронность работает')
executor.start_polling(dp, skip_updates=True)