-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (36 loc) · 1.2 KB
/
main.py
File metadata and controls
41 lines (36 loc) · 1.2 KB
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
# Copyright (c) 2025 devgagan : https://github.com/devgaganin.
# Licensed under the GNU General Public License v3.0.
# See LICENSE file in the repository root for full license text.
import asyncio
from shared_client import start_client
import importlib
import os
import sys
async def load_and_run_plugins():
await start_client()
plugin_dir = "plugins"
plugins = [f[:-3] for f in os.listdir(plugin_dir) if f.endswith(".py") and f != "__init__.py"]
for plugin in plugins:
module = importlib.import_module(f"plugins.{plugin}")
if hasattr(module, f"run_{plugin}_plugin"):
print(f"Running {plugin} plugin...")
await getattr(module, f"run_{plugin}_plugin")()
async def main():
await load_and_run_plugins()
while True:
await asyncio.sleep(1)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
print("Starting clients ...")
try:
loop.run_until_complete(main())
except KeyboardInterrupt:
print("Shutting down...")
except Exception as e:
print(e)
sys.exit(1)
finally:
try:
loop.close()
except Exception:
pass