-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adc51cf
commit 1de035d
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from modules.bot import LOGGER | ||
|
||
|
||
def list_all_modules(): | ||
import glob | ||
from os.path import basename, dirname, isfile | ||
|
||
# This generates a list of modules in this folder for the * in __main__ to work. | ||
mod_paths = glob.glob(dirname(__file__) + "/*.py") | ||
all_modules = [ | ||
basename(f)[:-3] | ||
for f in mod_paths | ||
if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py") | ||
] | ||
|
||
return all_modules | ||
|
||
|
||
ALL_MODULES = list_all_modules() | ||
LOGGER.info("Modules Loaded: %s", str(ALL_MODULES)) | ||
|
||
__all__ = ALL_MODULES + ["ALL_MODULES"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import time | ||
import importlib | ||
|
||
from modules.bot import dp, LOGGER | ||
|
||
from modules.bot import ALL_MODULES | ||
|
||
from telegram.ext import ContextTypes, CommandHandler | ||
from telegram import Update | ||
|
||
|
||
for module_name in ALL_MODULES: | ||
imported_module = importlib.import_module("bot.modules." + module_name) | ||
if not hasattr(imported_module, "__mod_name__"): | ||
imported_module.__mod_name__ = imported_module.__name__ | ||
|
||
|
||
|
||
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): | ||
args = context.args | ||
message = update.effective_message | ||
await message.reply_text("bot working fine!") | ||
|
||
|
||
|
||
def main(): | ||
|
||
start_handler = CommandHandler("start", start) | ||
dp.add_handler(start_handler) | ||
|
||
LOGGER.info("bot is now deployed!!!----Using long polling...") | ||
dp.run_polling(timeout=15, drop_pending_updates=False) | ||
|
||
if __name__ == "__main__": | ||
LOGGER.info("Successfully loaded all modules") | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python-telegram-bot==20.0 | ||
requests |