Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
barryspacezero committed Apr 22, 2023
1 parent adc51cf commit 1de035d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
22 changes: 22 additions & 0 deletions __init__.py
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"]
36 changes: 36 additions & 0 deletions __main__.py
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()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python-telegram-bot==20.0
requests

0 comments on commit 1de035d

Please sign in to comment.