mirror of https://github.com/Bunsly/JobSpy
new abstract class to identify telegram handler
parent
458728bb71
commit
4549b2ffc8
|
@ -55,11 +55,11 @@ if __name__ == "__main__":
|
||||||
# asyncio.run(main())
|
# asyncio.run(main())
|
||||||
logger.info("Starting initialize ")
|
logger.info("Starting initialize ")
|
||||||
_api_token = os.getenv("TELEGRAM_API_TOKEN")
|
_api_token = os.getenv("TELEGRAM_API_TOKEN")
|
||||||
|
application = Application.builder().token(_api_token).build()
|
||||||
tg_handler_all = TelegramAllHandler(sites=[Site.GOOZALI],
|
tg_handler_all = TelegramAllHandler(sites=[Site.GOOZALI],
|
||||||
locations=["Tel Aviv, Israel", "Ramat Gan, Israel",
|
locations=["Tel Aviv, Israel", "Ramat Gan, Israel",
|
||||||
"Central, Israel", "Rehovot ,Israel"],
|
"Central, Israel", "Rehovot ,Israel"],
|
||||||
title_filters=title_filters)
|
title_filters=title_filters)
|
||||||
application = Application.builder().token(_api_token).build()
|
|
||||||
application.add_handler(CommandHandler("findAll", tg_handler_all.handle))
|
application.add_handler(CommandHandler("findAll", tg_handler_all.handle))
|
||||||
# application.add_handler(CommandHandler("galssdoor", find_glassdoor))
|
# application.add_handler(CommandHandler("galssdoor", find_glassdoor))
|
||||||
# application.add_handler(CommandHandler("linkedin", find_linkedin))
|
# application.add_handler(CommandHandler("linkedin", find_linkedin))
|
||||||
|
|
|
@ -7,11 +7,12 @@ from src.jobspy import Site, scrape_jobs
|
||||||
from src.jobspy.db.job_repository import JobRepository
|
from src.jobspy.db.job_repository import JobRepository
|
||||||
from src.jobspy.scrapers.utils import create_logger
|
from src.jobspy.scrapers.utils import create_logger
|
||||||
from src.telegram_bot import TelegramBot
|
from src.telegram_bot import TelegramBot
|
||||||
|
from src.telegram_handler.telegram_handler import TelegramHandler
|
||||||
|
|
||||||
logger = create_logger("TelegramAllHandler")
|
logger = create_logger("TelegramAllHandler")
|
||||||
|
|
||||||
|
|
||||||
class TelegramAllHandler:
|
class TelegramAllHandler(TelegramHandler):
|
||||||
def __init__(self, sites: list[Site], locations: list[str], title_filters: list[str]):
|
def __init__(self, sites: list[Site], locations: list[str], title_filters: list[str]):
|
||||||
self.sites_to_scrap = sites
|
self.sites_to_scrap = sites
|
||||||
self.locations = locations
|
self.locations = locations
|
||||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue