sh_discord_bot/src/bot/main.py

41 lines
837 B
Python
Raw Normal View History

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):
self._bot: Optional[Application] = None
async def main(self):
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app: Application = await app_builder.build_async()
await app.run_async()
async def stop(self):
await self._bot.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
# ___// | /
# `--' \_~-,