-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
41 lines (32 loc) · 891 Bytes
/
main.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
import sys
import asyncio
import traceback
from tasks import app
from src.telegram.client import getClient, startClient
try:
import plugins as plugins
except ImportError:
try:
from . import plugins
except ImportError:
print(traceback.format_exc())
print('could not load the plugins module', file=sys.stderr)
exit(1)
async def main():
bot = await getClient()
await startClient()
bot.parse_mode = 'html'
try:
await plugins.init(bot)
await app.serve()
await bot.run_until_disconnected()
except asyncio.CancelledError:
pass
except KeyboardInterrupt:
print("KeyboardInterrupt received, shutting down...")
except Exception as err:
print(f"An error occurred: {err}")
finally:
await bot.disconnect()
if __name__ == '__main__':
asyncio.run(main())