-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
43 lines (34 loc) · 1.31 KB
/
run.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
import asyncio
import nest_asyncio
from loguru import logger
from bot.tg_module import start_telegram_bot
from bot.vk_module import start_vk_bot
from bot.database import Table
from bot.spamming.main import check_replacement
from bot.spamming.functions import get_next_check_time
from bot.config import array_times
def repeat(func, loop_repeat) -> None:
"""Функция-повторитель для loop"""
asyncio.ensure_future(func(), loop=loop_repeat)
interval = get_next_check_time(array_times, func.__name__)
loop_repeat.call_later(interval, repeat, func, loop_repeat)
if __name__ == '__main__':
logger.add("bot/log/info.log",
format="{time:HH:mm:ss} {level} {module} {function} {message}",
level="INFO",
rotation="00:00",
compression="zip",
serialize=False,
enqueue=True)
with logger.catch():
nest_asyncio.apply()
loop = asyncio.get_event_loop()
tasks = [
loop.create_task(start_telegram_bot()),
# loop.create_task(start_vk_bot())
]
Table.create_extensions()
Table.create()
Table.create_view()
CHECK_REPLACEMENT_LOOP = loop.call_later(3, repeat, check_replacement, loop)
loop.run_until_complete(asyncio.wait(tasks))