From 968da48728cb07a6a42470abe1f4a369de85ab62 Mon Sep 17 00:00:00 2001 From: Yariv Menachem Date: Wed, 11 Dec 2024 11:32:58 +0200 Subject: [PATCH] added env file to store the keys --- src/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index a812053..befea77 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import asyncio -import csv +import os +from dotenv import load_dotenv from typing import List from pymongo import MongoClient, UpdateOne @@ -7,10 +8,14 @@ from telegram import Bot from jobspy import scrape_jobs from jobspy.jobs import JobPost -TELEGRAM_API_TOKEN = -CHAT_ID = +# Load the .env file +load_dotenv() + +TELEGRAM_API_TOKEN = os.getenv("TELEGRAM_API_TOKEN") +CHAT_ID = os.getenv("TELEGRAM_CHAT_ID") +MONGO_URI = os.getenv("MONGO_URI") # Connect to MongoDB server -client = MongoClient("mongodb://localhost:27017/") +client = MongoClient(MONGO_URI) # Access a database (it will be created automatically if it doesn't exist) db = client["jobs_database"] # Access a collection @@ -83,6 +88,7 @@ async def main(): print(f"Found {len(jobs)} jobs") new_jobs = insert_jobs(jobs, jobs_collection) + await send_job_to_telegram(jobs[0]) for new_job in new_jobs: await send_job_to_telegram(new_job)