mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Support importing plugins in assistant when ran as module
This commit is contained in:
parent
560d4bed09
commit
5d41246e73
|
@ -378,9 +378,18 @@ bot.start(bot_token=TOKEN)
|
||||||
# the now downloaded `plugins/` folder). We try importing them so
|
# the now downloaded `plugins/` folder). We try importing them so
|
||||||
# that the example runs fine without them, but optionally load them.
|
# that the example runs fine without them, but optionally load them.
|
||||||
try:
|
try:
|
||||||
|
# Standalone script assistant.py with folder plugins/
|
||||||
import plugins
|
import plugins
|
||||||
plugins.init(bot)
|
plugins.init(bot)
|
||||||
except ImportError:
|
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()
|
bot.run_until_disconnected()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user