olgram/main.py

39 lines
830 B
Python
Raw Normal View History

2021-07-11 12:53:33 +03:00
import asyncio
from tortoise import Tortoise
2021-09-06 00:36:03 +03:00
from olgram.router import dp
from olgram.settings import TORTOISE_ORM
2021-09-10 22:38:29 +03:00
from server.custom import init_redis
2021-07-11 12:53:33 +03:00
2021-09-09 10:58:33 +03:00
import olgram.commands.bots # noqa: F401
import olgram.commands.start # noqa: F401
import olgram.commands.menu # noqa: F401
import olgram.commands.bot_actions # noqa: F401
2021-07-11 12:53:33 +03:00
2021-09-09 23:35:13 +03:00
from server.server import main as server_main
2021-09-10 01:14:53 +03:00
import logging
logging.basicConfig(level=logging.INFO)
2021-07-11 12:53:33 +03:00
async def init_database():
await Tortoise.init(config=TORTOISE_ORM)
def main():
"""
Classic polling
"""
loop = asyncio.get_event_loop()
loop.run_until_complete(init_database())
2021-09-10 22:38:29 +03:00
loop.run_until_complete(init_redis())
2021-07-11 12:53:33 +03:00
2021-09-10 00:41:50 +03:00
loop.create_task(dp.start_polling())
2021-09-09 23:35:13 +03:00
loop.create_task(server_main().start())
2021-07-11 12:53:33 +03:00
loop.run_forever()
if __name__ == '__main__':
main()