Skip to content

Commit

Permalink
Updated project files. Version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
juhandergod committed Mar 27, 2023
1 parent 8ccb957 commit 4dbcf34
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN pip3 install -r requirements.txt

COPY . .

CMD [ "python3", "main.py"]
CMD [ "python3", "app.py"]
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@
--------
## About

The project was created to get notification to any platform, when there is available weekend ticket for F1 Hungaroring GP.
For this case I chose Discord channel notification.

---------
## Usage

### Running with Docker

Building the docker image from source locally:
```
docker build -t f1-hungaroring-ticket-checker .
```

*You should be in the sources folder where the Dockerfile is located to run this script.*

Running the local docker-image:
Instead of having `$WEBHOOK_URL` give your discord's channel url link.
```
docker run --name f1-hungaroring-ticket-checker -it -d --env WEBHOOK_URL=$WEBHOOK_URL f1-hungaroring-ticket-checker
```


------
## Contributors

Created by @juhanderpro.
22 changes: 19 additions & 3 deletions main.py → app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import crython
import discord
import scraping
from flask import Flask
from time import sleep

if __name__ == '__main__':
tickets = scraping.get_available_weekend_tickets()
app = Flask(__name__)


@app.route("/")
def hello():
return "F1 ticket bot"


@crython.job(second=0)
def ticket_checker_job():
tickets = scraping.get_available_weekend_tickets()
if len(tickets) != 0:
ticket_names = scraping.get_tickets_name(tickets)
for ticket_name in ticket_names:
discord.send_message("Ticket available: " + ticket_name + " - " + scraping.url)
sleep(1)
else:
print("No tickets available")
print("No ticket available.")


if __name__ == "__main__":
discord.send_message("Script started successfully.")
crython.start()
app.run()
11 changes: 0 additions & 11 deletions cronjob.py

This file was deleted.

4 changes: 3 additions & 1 deletion discord.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import requests
import json
import os

# Replace the webhook URL with your own webhook URL
WEBHOOK_URL = "https://discord.com/api/webhooks/1088398861854310480/xzi0_PpEjMFMG7M9XtuW2G5iXCxn_sPr7eqQSRTTRsk5-E1ry0vp38-PtAD4UJgnhG-f"
WEBHOOK_URL = os.getenv("WEBHOOK_URL")


def send_message(message_text):
# Create the message payload
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
requests~=2.28.2
bs4~=0.0.1
beautifulsoup4~=4.12.0
cron
crython~=0.2.0
Flask~=2.2.3
six~=1.16.0

0 comments on commit 4dbcf34

Please sign in to comment.