-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnnm_main.py
29 lines (22 loc) · 1.14 KB
/
nnm_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
from telegram.ext import Application, CommandHandler
from bot.Handlers import Handlers
from config.Settings import Settings
from bot.modules.Helpers import Helpers
def main() -> None:
settings = Settings()
helpers = Helpers(settings)
helpers.wait_for_internet()
handlers = Handlers(settings, helpers)
try:
application = Application.builder().token(settings.TELEGRAM_TOKEN).post_init(handlers.startup).build()
application.add_handler(CommandHandler("reboot", handlers.reboot_command))
application.add_handler(CommandHandler("enable", handlers.enable_command))
application.add_handler(CommandHandler("disable", handlers.disable_command))
application.add_handler(CommandHandler("enable_nodes", handlers.enable_nodes_command))
application.add_handler(CommandHandler("disable_nodes", handlers.disable_nodes_command))
application.add_handler(CommandHandler("check", handlers.check_command))
application.run_polling(drop_pending_updates=True)
except Exception as e:
helpers.write_log('error', f"Bot Crashed. {type(e).__name__} – {e}")
if __name__ == "__main__":
main()