From 02a8529fc4d9a494410e3d2ec5b3926ec19466cc Mon Sep 17 00:00:00 2001 From: jon4h Date: Sun, 11 Oct 2020 19:25:42 +0200 Subject: [PATCH 1/2] add security code --- config.py | 2 ++ main.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index af7812a..8ef09a5 100644 --- a/config.py +++ b/config.py @@ -10,6 +10,8 @@ whitelisted = [ 'buy alert', 'sell alert' ] +sec_code = '' + # Telegram Settings send_telegram_alerts = False tg_token = '' # Bot token. Get it from @Botfather diff --git a/main.py b/main.py index 91cf928..3f8d303 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ def webhook(): if request.method == 'POST': data = request.get_data(as_text=True) for whitelisted in config.whitelisted: - if whitelisted.lower() in data.lower(): + if whitelisted.lower() in data.lower() and config.sec_code in data: print('[✓]', timestamp, 'Alert Received & Sent!\n>', data) send_alert(data) return 'Sent alert', 200 From c648e1132a8fdc9e4d5d7c788c482d48591c071f Mon Sep 17 00:00:00 2001 From: jon4h Date: Sun, 11 Oct 2020 19:42:44 +0200 Subject: [PATCH 2/2] dokerize --- Dockerfile | 11 +++++++++++ docker-compose.yml | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57cc104 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.9-alpine +LABEL Auther="jon4hz" +WORKDIR /usr/src/app +COPY requirements.txt ./ +RUN apk add gcc python3-dev openssl-dev musl-dev libffi-dev &&\ + pip install --no-cache-dir -r requirements.txt + +COPY main.py handler.py config.py ./ +EXPOSE 80 + +ENTRYPOINT [ "python", "main.py" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3e2c177 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +--- +version: '3.5' +services: + tradingview-webhook-bot: + build: . + container_name: tradingview-webhook-bot + ports: + - '80:80' + restart: unless-stopped \ No newline at end of file