diff --git a/src/main.py b/src/main.py index cd28e90..3448f51 100644 --- a/src/main.py +++ b/src/main.py @@ -55,11 +55,11 @@ if __name__ == "__main__": # asyncio.run(main()) logger.info("Starting initialize ") _api_token = os.getenv("TELEGRAM_API_TOKEN") + application = Application.builder().token(_api_token).build() tg_handler_all = TelegramAllHandler(sites=[Site.GOOZALI], locations=["Tel Aviv, Israel", "Ramat Gan, Israel", "Central, Israel", "Rehovot ,Israel"], title_filters=title_filters) - application = Application.builder().token(_api_token).build() application.add_handler(CommandHandler("findAll", tg_handler_all.handle)) # application.add_handler(CommandHandler("galssdoor", find_glassdoor)) # application.add_handler(CommandHandler("linkedin", find_linkedin)) diff --git a/src/telegram_handler/telegram_all_handler.py b/src/telegram_handler/telegram_all_handler.py index 2aeb970..2eaecec 100644 --- a/src/telegram_handler/telegram_all_handler.py +++ b/src/telegram_handler/telegram_all_handler.py @@ -7,11 +7,12 @@ from src.jobspy import Site, scrape_jobs from src.jobspy.db.job_repository import JobRepository from src.jobspy.scrapers.utils import create_logger from src.telegram_bot import TelegramBot +from src.telegram_handler.telegram_handler import TelegramHandler logger = create_logger("TelegramAllHandler") -class TelegramAllHandler: +class TelegramAllHandler(TelegramHandler): def __init__(self, sites: list[Site], locations: list[str], title_filters: list[str]): self.sites_to_scrap = sites self.locations = locations diff --git a/src/telegram_handler/telegram_handler.py b/src/telegram_handler/telegram_handler.py new file mode 100644 index 0000000..14c71a3 --- /dev/null +++ b/src/telegram_handler/telegram_handler.py @@ -0,0 +1,12 @@ +from abc import ABC, abstractmethod + +from telegram import Update +from telegram.ext import ContextTypes + + +# Define an abstract class +class TelegramHandler(ABC): + + @abstractmethod + def handle(self, update: Update, context: ContextTypes): + pass # This is an abstract method, no implementation here. \ No newline at end of file