2022-07-14 16:32:46 +02:00
|
|
|
import asyncio
|
2022-07-16 19:47:04 +02:00
|
|
|
from typing import Optional
|
2022-07-14 16:32:46 +02:00
|
|
|
|
|
|
|
from cpl_core.application import ApplicationBuilder
|
|
|
|
|
|
|
|
from bot.application import Application
|
|
|
|
from bot.startup import Startup
|
|
|
|
|
|
|
|
|
2022-07-16 19:47:04 +02:00
|
|
|
class Main:
|
|
|
|
|
|
|
|
def __init__(self):
|
2022-07-16 19:55:22 +02:00
|
|
|
self._app: Optional[Application] = None
|
2022-07-16 19:47:04 +02:00
|
|
|
|
|
|
|
async def main(self):
|
|
|
|
app_builder = ApplicationBuilder(Application)
|
|
|
|
app_builder.use_startup(Startup)
|
2022-07-16 19:55:22 +02:00
|
|
|
self._app: Application = await app_builder.build_async()
|
|
|
|
await self._app.run_async()
|
2022-07-16 19:47:04 +02:00
|
|
|
|
|
|
|
async def stop(self):
|
2022-07-16 19:55:22 +02:00
|
|
|
await self._app.stop_async()
|
2022-07-14 16:32:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2022-07-16 19:47:04 +02:00
|
|
|
main = Main()
|
|
|
|
try:
|
|
|
|
asyncio.run(main.main())
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
asyncio.run(main.stop())
|
|
|
|
|
|
|
|
# ((
|
|
|
|
# ( `)
|
|
|
|
# ; / ,
|
|
|
|
# / \/
|
|
|
|
# / |
|
|
|
|
# / ~/
|
|
|
|
# / ) ) ~ edraft
|
|
|
|
# ___// | /
|
|
|
|
# `--' \_~-,
|