-
Notifications
You must be signed in to change notification settings - Fork 0
/
df.py
47 lines (30 loc) · 1.16 KB
/
df.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from contextlib import suppress
from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.utils.exceptions import MessageToDeleteNotFound, MessageCantBeDeleted
import logging
import asyncio
import tracemalloc
tracemalloc.start()
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
logging.debug('A DEBUG Message')
logging.info('An INFO')
logging.warning('A WARNING')
logging.error('An ERROR')
logging.critical('A message of CRITICAL severity')
from auxiliary_files.config import token_API
storage = MemoryStorage()
bot = Bot(token_API)
loop = asyncio.get_event_loop()
dp = Dispatcher(bot,
storage=storage,
loop=loop)
async def delete_message(message: types.Message, sleep_time: int = 0):
await asyncio.sleep(sleep_time)
with suppress(MessageCantBeDeleted, MessageToDeleteNotFound):
await message.delete()
msg = await message.reply('Я удалюсь через 30 секунд')
asyncio.create_task(delete_message(msg, 30))
if __name__ == '__main__':
executor.start_polling(dispatcher=dp)