From 5d41246e739c5dd7d6d423403cb887b4d334a4a7 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 11 May 2019 20:44:35 +0200 Subject: [PATCH] Support importing plugins in assistant when ran as module --- telethon_examples/assistant.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/telethon_examples/assistant.py b/telethon_examples/assistant.py index e7b1fe5e..cf1d8723 100644 --- a/telethon_examples/assistant.py +++ b/telethon_examples/assistant.py @@ -378,9 +378,18 @@ bot.start(bot_token=TOKEN) # the now downloaded `plugins/` folder). We try importing them so # that the example runs fine without them, but optionally load them. try: + # Standalone script assistant.py with folder plugins/ import plugins plugins.init(bot) except ImportError: - pass + try: + # Running as a module with `python -m assistant` and structure: + # assistant/ + # __main__.py (this file) + # plugins/ (cloned) + from . import plugins + plugins.init(bot) + except ImportError: + plugins = None bot.run_until_disconnected()