kopia lustrzana https://github.com/fabston/TradingView-Webhook-Bot
Added option to whitelist words
- Easily add whitelisted words in config.py - Better error handlingpull/8/head
rodzic
f2a5f5c5ec
commit
b35a293a65
|
@ -8,7 +8,6 @@
|
||||||
<br /><a href="https://github.com/sixBit/TradingView-Webhook-Bot/stargazers"><img src="https://img.shields.io/github/stars/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub stars"></a>
|
<br /><a href="https://github.com/sixBit/TradingView-Webhook-Bot/stargazers"><img src="https://img.shields.io/github/stars/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub stars"></a>
|
||||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/network/members"><img src="https://img.shields.io/github/forks/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub forks"></a>
|
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/network/members"><img src="https://img.shields.io/github/forks/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub forks"></a>
|
||||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/watchers"><img src="https://img.shields.io/github/watchers/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub watchers"></a>
|
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/watchers"><img src="https://img.shields.io/github/watchers/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub watchers"></a>
|
||||||
<br /><a href="https://conversations.im/j/codehub@room.sixbit.io"><img src="https://inverse.chat/badge.svg?room=codehub@room.sixbit.io" alt="Join XMPP Server"></a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
@ -24,7 +23,8 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## About
|
## About
|
||||||
The **TradingView Webhook Bot** ⚙️ listens to [TradingView](https://tradingview.com) alerts via [webhooks](https://www.tradingview.com/support/solutions/43000529348-i-want-to-know-more-about-webhooks/) using [flask](https://flask.palletsprojects.com/en/1.1.x/). All alerts can be instantly sent to Telegram, Discord, Twitter and/or Email.
|
The **TradingView Webhook Bot** ⚙️ listens to [TradingView](https://tradingview.com) alerts via [webhooks](https://www.tradingview.com/support/solutions/43000529348-i-want-to-know-more-about-webhooks/) using [flask](https://flask.palletsprojects.com/en/1.1.x/).
|
||||||
|
All alerts can be instantly sent to Telegram, Discord, Twitter and/or Email.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Telegram Support using the [Python Telegram](https://github.com/python-telegram-bot/python-telegram-bot) libary
|
- Telegram Support using the [Python Telegram](https://github.com/python-telegram-bot/python-telegram-bot) libary
|
||||||
|
@ -32,7 +32,7 @@ The **TradingView Webhook Bot** ⚙️ listens to [TradingView](https://tradingv
|
||||||
- Twitter Support using the [tweepy](https://github.com/tweepy/tweepy) libary
|
- Twitter Support using the [tweepy](https://github.com/tweepy/tweepy) libary
|
||||||
- Email Support using [smtplib](https://docs.python.org/3/library/smtplib.html)
|
- Email Support using [smtplib](https://docs.python.org/3/library/smtplib.html)
|
||||||
- Alert channels can be enabled or disabled in [`config.py`](https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/config.py)
|
- Alert channels can be enabled or disabled in [`config.py`](https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/config.py)
|
||||||
- Differentiate between Buy and Sell alerts
|
- Whitelisted words can be easily added in [`config.py`](https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/config.py)
|
||||||
- TradingView `{{close}}`, `{{exchange}}` etc. variables support. Read more [here](https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/)
|
- TradingView `{{close}}`, `{{exchange}}` etc. variables support. Read more [here](https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/)
|
||||||
|
|
||||||
> 💡 Got a feature idea? Open an [issue](https://github.com/sixBit/Telegram-Webhook-Bot/issues/new) and I might implement it.
|
> 💡 Got a feature idea? Open an [issue](https://github.com/sixBit/Telegram-Webhook-Bot/issues/new) and I might implement it.
|
||||||
|
|
14
config.py
14
config.py
|
@ -5,8 +5,10 @@
|
||||||
# ----------------------------------------------- #
|
# ----------------------------------------------- #
|
||||||
|
|
||||||
# Alert message in TradingView (ex. https://i.imgur.com/RFkuf1d.png)
|
# Alert message in TradingView (ex. https://i.imgur.com/RFkuf1d.png)
|
||||||
Buy_Alert = 'Buy Alert!'
|
# !! Case insensitive !!
|
||||||
Sell_Alert = 'Sell Alert!'
|
whitelisted = [
|
||||||
|
'buy alert', 'sell alert'
|
||||||
|
]
|
||||||
|
|
||||||
# Telegram Settings
|
# Telegram Settings
|
||||||
send_telegram_alerts = False
|
send_telegram_alerts = False
|
||||||
|
@ -30,7 +32,7 @@ email_sender = '' # Your email address
|
||||||
email_receivers = ['', ''] # Receivers, can be multiple
|
email_receivers = ['', ''] # Receivers, can be multiple
|
||||||
email_subject = 'Trade Alert!'
|
email_subject = 'Trade Alert!'
|
||||||
|
|
||||||
email_port = 465 # SMTP SSL Port (ex. 465)
|
email_port = 465 # SMTP SSL Port (ex. 465)
|
||||||
email_host = '' # SMTP host (ex. smtp.gmail.com)
|
email_host = '' # SMTP host (ex. smtp.gmail.com)
|
||||||
email_user = '' # SMTP Login credentials
|
email_user = '' # SMTP Login credentials
|
||||||
email_password = '' # SMTP Login credentials
|
email_password = '' # SMTP Login credentials
|
34
main.py
34
main.py
|
@ -5,27 +5,31 @@
|
||||||
# ----------------------------------------------- #
|
# ----------------------------------------------- #
|
||||||
|
|
||||||
import config
|
import config
|
||||||
from flask import Flask, request, abort
|
import time
|
||||||
|
from flask import Flask, request
|
||||||
from handler import *
|
from handler import *
|
||||||
|
|
||||||
|
timestamp = time.strftime("%Y-%m-%d %X")
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/webhook', methods=['POST'])
|
@app.route('/webhook', methods=['POST'])
|
||||||
def webhook():
|
def webhook():
|
||||||
if request.method == 'POST':
|
try:
|
||||||
data = request.get_data(as_text=True)
|
if request.method == 'POST':
|
||||||
if config.Buy_Alert in data:
|
data = request.get_data(as_text=True)
|
||||||
print('Alert Received:', data)
|
for whitelisted in config.whitelisted:
|
||||||
send_alert(data)
|
if whitelisted.lower() in data.lower():
|
||||||
return '', 200
|
print('[✓]', timestamp, 'Alert Received & Sent!\n>', data)
|
||||||
elif config.Sell_Alert in data:
|
send_alert(data)
|
||||||
print('Alert Received:', data)
|
return 'Sent alert', 200
|
||||||
send_alert(data)
|
else:
|
||||||
return '', 200
|
print('[✗]', timestamp, 'Alert Received & Refused!\n>', data)
|
||||||
|
return 'Refused alert', 400
|
||||||
else:
|
else:
|
||||||
abort(400)
|
return 'Refused alert', 400
|
||||||
else:
|
except Exception as e:
|
||||||
abort(400)
|
print('[✘]', timestamp, 'Error:\n>', e)
|
||||||
|
return 'Error', 400
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
|
Ładowanie…
Reference in New Issue