mirror of https://github.com/Bunsly/JobSpy
init commit
parent
2d98eb6c1c
commit
f010ce51b1
|
@ -1,10 +1,15 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from telegram.ext import Application, CommandHandler
|
||||||
|
|
||||||
from src.jobspy import Site, scrape_jobs
|
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.jobs import JobPost
|
from src.jobspy.jobs import JobPost
|
||||||
from src.jobspy.scrapers.utils import create_logger
|
from src.jobspy.scrapers.utils import create_logger
|
||||||
from src.jobspy.telegram_bot import TelegramBot
|
from src.jobspy.telegram_bot import TelegramBot
|
||||||
|
from src.jobspy.telegram_handler import TelegramHandler
|
||||||
|
|
||||||
logger = create_logger("Main")
|
logger = create_logger("Main")
|
||||||
filter_by_title: list[str] = ["test", "qa", "Lead", "Full-Stack", "Full Stack", "Fullstack", "Frontend", "Front-end", "Front End", "DevOps", "Physical", "Staff",
|
filter_by_title: list[str] = ["test", "qa", "Lead", "Full-Stack", "Full Stack", "Fullstack", "Frontend", "Front-end", "Front End", "DevOps", "Physical", "Staff",
|
||||||
|
@ -24,6 +29,7 @@ def filter_jobs_by_title_name(job: JobPost):
|
||||||
async def main():
|
async def main():
|
||||||
telegramBot = TelegramBot()
|
telegramBot = TelegramBot()
|
||||||
jobRepository = JobRepository()
|
jobRepository = JobRepository()
|
||||||
|
tg_handler = TelegramHandler()
|
||||||
# sites_to_scrap = [Site.LINKEDIN, Site.GLASSDOOR, Site.INDEED, Site.GOOZALI]
|
# sites_to_scrap = [Site.LINKEDIN, Site.GLASSDOOR, Site.INDEED, Site.GOOZALI]
|
||||||
sites_to_scrap = [Site.GOOZALI]
|
sites_to_scrap = [Site.GOOZALI]
|
||||||
# sites_to_scrap = [Site.GOOZALI]
|
# sites_to_scrap = [Site.GOOZALI]
|
||||||
|
@ -44,4 +50,12 @@ async def main():
|
||||||
|
|
||||||
# Run the async main function
|
# Run the async main function
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
# asyncio.run(main())
|
||||||
|
_api_token = os.getenv("TELEGRAM_API_TOKEN")
|
||||||
|
application = Application.builder().token(_api_token).build()
|
||||||
|
application.add_handler(CommandHandler("find", findAll))
|
||||||
|
application.add_handler(CommandHandler("galssdoor", find_glassdoor))
|
||||||
|
application.add_handler(CommandHandler("linkedin", find_linkedin))
|
||||||
|
application.add_handler(CommandHandler("indeed", find_indeed))
|
||||||
|
application.add_handler(CommandHandler("goozali", find_goozali))
|
||||||
|
tg_handler = TelegramHandler().handler()
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from telegram import Bot
|
from telegram import Bot, Update
|
||||||
|
from telegram.ext import (
|
||||||
|
Application,
|
||||||
|
CommandHandler,
|
||||||
|
ContextTypes,
|
||||||
|
ConversationHandler,
|
||||||
|
MessageHandler,
|
||||||
|
filters,
|
||||||
|
)
|
||||||
from .jobs import JobPost
|
from .jobs import JobPost
|
||||||
from .scrapers.utils import create_logger
|
from .scrapers.utils import create_logger
|
||||||
|
|
||||||
|
@ -16,13 +23,16 @@ class TelegramBot:
|
||||||
self._api_token = os.getenv("TELEGRAM_API_TOKEN")
|
self._api_token = os.getenv("TELEGRAM_API_TOKEN")
|
||||||
self.chatId = os.getenv("TELEGRAM_CHAT_ID")
|
self.chatId = os.getenv("TELEGRAM_CHAT_ID")
|
||||||
self.bot = Bot(token=self._api_token)
|
self.bot = Bot(token=self._api_token)
|
||||||
|
# Create the Application and pass it your bot's token.
|
||||||
|
self.application = Application.builder().token(self._api_token).build()
|
||||||
|
# Run the bot until the user presses Ctrl-C
|
||||||
|
self.application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||||
|
|
||||||
async def sendJob(self, job: JobPost):
|
async def sendJob(self, job: JobPost):
|
||||||
"""
|
"""
|
||||||
Send JobPost details to Telegram chat.
|
Send JobPost details to Telegram chat.
|
||||||
"""
|
"""
|
||||||
message = f"New Job Posted:\n\n" \
|
message = f"Job ID: {job.id}\n" \
|
||||||
f"Job ID: {job.id}\n" \
|
|
||||||
f"Job Title: {job.title}\n" \
|
f"Job Title: {job.title}\n" \
|
||||||
f"Company: {job.company_name}\n" \
|
f"Company: {job.company_name}\n" \
|
||||||
f"Location: {job.location.display_location()}\n" \
|
f"Location: {job.location.display_location()}\n" \
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from telegram import Bot, Update, ReplyKeyboardMarkup
|
||||||
|
from telegram.ext import (
|
||||||
|
Application,
|
||||||
|
CommandHandler,
|
||||||
|
ContextTypes,
|
||||||
|
ConversationHandler,
|
||||||
|
MessageHandler,
|
||||||
|
filters,
|
||||||
|
)
|
||||||
|
from .scrapers.utils import create_logger
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
logger = create_logger("TelegramBot")
|
||||||
|
|
||||||
|
|
||||||
|
class TelegramHandler:
|
||||||
|
def __init__(self):
|
||||||
|
self._api_token = os.getenv("TELEGRAM_API_TOKEN")
|
||||||
|
self.chatId = os.getenv("TELEGRAM_CHAT_ID")
|
||||||
|
self.bot = Bot(token=self._api_token)
|
||||||
|
# Create the Application and pass it your bot's token.
|
||||||
|
self.application = Application.builder().token(self._api_token).build()
|
||||||
|
|
||||||
|
async def findAll(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||||
|
"""Start the conversation and ask user for input."""
|
||||||
|
await update.message.reply_text(
|
||||||
|
"Hi! My name is Doctor Botter. I will hold a more complex conversation with you. "
|
||||||
|
"Why don't you tell me something about yourself?"
|
||||||
|
)
|
||||||
|
|
||||||
|
async def find_glassdoor(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||||
|
"""Start the conversation and ask user for input."""
|
||||||
|
await update.message.reply_text(
|
||||||
|
"Hi! My name is Doctor Botter. I will hold a more complex conversation with you. "
|
||||||
|
"Why don't you tell me something about yourself?"
|
||||||
|
)
|
||||||
|
|
||||||
|
def handler(self):
|
||||||
|
self.application.add_handler(CommandHandler("find", self.findAll))
|
||||||
|
self.application.add_handler(CommandHandler("galssdoor", self.find_glassdoor))
|
||||||
|
self.application.add_handler(CommandHandler("linkedin", self.findAll))
|
||||||
|
self.application.add_handler(CommandHandler("indeed", self.findAll))
|
||||||
|
self.application.add_handler(CommandHandler("goozali", self.findAll))
|
||||||
|
# Run the bot until the user presses Ctrl-C
|
||||||
|
self.application.run_polling(allowed_updates=Update.ALL_TYPES)
|
Loading…
Reference in New Issue