kopia lustrzana https://github.com/fabston/TradingView-Webhook-Bot
Added Twitter support
You are now also able to send alerts to twitter. Can be enabled in config.pypull/1/head
rodzic
6b0e1d932a
commit
5ffe8d5f60
|
@ -22,4 +22,9 @@ This bot listens to [TradingView](https://tradingview.com) alerts via webhooks a
|
||||||

|

|
||||||
|
|
||||||
## Donations
|
## Donations
|
||||||
BTC: `13VmcVh7U3y7UQiUGp1nnyn6Pz9TPR61a9`
|
If you find the bot suitable for your needs, please consider donating whatever amount you like to:
|
||||||
|
|
||||||
|
#### Bitcoin (BTC)
|
||||||
|
```
|
||||||
|
13VmcVh7U3y7UQiUGp1nnyn6Pz9TPR61a9
|
||||||
|
```
|
||||||
|
|
|
@ -11,6 +11,13 @@ channel = # Channel ID (ex. -1001487568087)
|
||||||
send_discord_alerts = True
|
send_discord_alerts = True
|
||||||
discord_webhook = '' # Discord Webhook URL (https://support.discordapp.com/hc/de/articles/228383668-Webhooks-verwenden)
|
discord_webhook = '' # Discord Webhook URL (https://support.discordapp.com/hc/de/articles/228383668-Webhooks-verwenden)
|
||||||
|
|
||||||
|
#Twitter Settings
|
||||||
|
send_twitter_alerts = False
|
||||||
|
tw_ckey = ''
|
||||||
|
tw_csecret = ''
|
||||||
|
tw_atoken = ''
|
||||||
|
tw_asecret = ''
|
||||||
|
|
||||||
# Email Settings
|
# Email Settings
|
||||||
send_email_alerts = False
|
send_email_alerts = False
|
||||||
email_sender = '' # Your email address
|
email_sender = '' # Your email address
|
||||||
|
|
23
handler.py
23
handler.py
|
@ -1,15 +1,22 @@
|
||||||
import config as config
|
import config as config
|
||||||
from telegram import Bot
|
from telegram import Bot
|
||||||
from discord_webhook import DiscordWebhook
|
from discord_webhook import DiscordWebhook
|
||||||
|
import tweepy
|
||||||
import smtplib, ssl
|
import smtplib, ssl
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
|
||||||
telegram = config.send_telegram_alerts
|
telegram = config.send_telegram_alerts
|
||||||
discord = config.send_discord_alerts
|
discord = config.send_discord_alerts
|
||||||
|
twitter = config.send_twitter_alerts
|
||||||
email = config.send_email_alerts
|
email = config.send_email_alerts
|
||||||
|
|
||||||
if telegram:
|
if telegram:
|
||||||
tg_bot = Bot(token=config.tg_token)
|
tg_bot = Bot(token=config.tg_token)
|
||||||
|
|
||||||
|
if twitter:
|
||||||
|
tw_auth = tweepy.OAuthHandler(config.tw_ckey, config.tw_csecret)
|
||||||
|
tw_auth.set_access_token(config.tw_atoken, config.tw_asecret)
|
||||||
|
tw_api = tweepy.API(tw_auth)
|
||||||
|
|
||||||
def send_buy_order(data):
|
def send_buy_order(data):
|
||||||
if telegram:
|
if telegram:
|
||||||
|
@ -17,12 +24,20 @@ def send_buy_order(data):
|
||||||
print('Alert has been sent to Telegram.')
|
print('Alert has been sent to Telegram.')
|
||||||
else:
|
else:
|
||||||
print('INFO: Telegram alerts are disabled.')
|
print('INFO: Telegram alerts are disabled.')
|
||||||
|
|
||||||
if discord:
|
if discord:
|
||||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||||
response = discord_alert.execute()
|
response = discord_alert.execute()
|
||||||
print('Alert has been sent to Discord.')
|
print('Alert has been sent to Discord.')
|
||||||
else:
|
else:
|
||||||
print('INFO: Discord alerts are disabled.')
|
print('INFO: Discord alerts are disabled.')
|
||||||
|
|
||||||
|
if twitter:
|
||||||
|
tw_api.update_status(status=data)
|
||||||
|
print('Alert has been sent to Twitter.')
|
||||||
|
else:
|
||||||
|
print('INFO: Twitter alerts are disabled.')
|
||||||
|
|
||||||
if email:
|
if email:
|
||||||
email_msg = MIMEText(data)
|
email_msg = MIMEText(data)
|
||||||
email_msg['Subject'] = config.email_subject
|
email_msg['Subject'] = config.email_subject
|
||||||
|
@ -43,12 +58,20 @@ def send_sell_order(data):
|
||||||
print('Alert has been sent to Telegram.')
|
print('Alert has been sent to Telegram.')
|
||||||
else:
|
else:
|
||||||
print('INFO: Telegram alerts are disabled.')
|
print('INFO: Telegram alerts are disabled.')
|
||||||
|
|
||||||
if discord:
|
if discord:
|
||||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||||
response = discord_alert.execute()
|
response = discord_alert.execute()
|
||||||
print('Alert has been sent to Discord.')
|
print('Alert has been sent to Discord.')
|
||||||
else:
|
else:
|
||||||
print('INFO: Discord alerts are disabled.')
|
print('INFO: Discord alerts are disabled.')
|
||||||
|
|
||||||
|
if twitter:
|
||||||
|
tw_api.update_status(status=data)
|
||||||
|
print('Alert has been sent to Twitter.')
|
||||||
|
else:
|
||||||
|
print('INFO: Twitter alerts are disabled.')
|
||||||
|
|
||||||
if email:
|
if email:
|
||||||
email_msg = MIMEText(data)
|
email_msg = MIMEText(data)
|
||||||
email_msg['Subject'] = config.email_subject
|
email_msg['Subject'] = config.email_subject
|
||||||
|
|
|
@ -2,5 +2,6 @@ flask
|
||||||
waitress
|
waitress
|
||||||
python-telegram-bot
|
python-telegram-bot
|
||||||
discord-webhook
|
discord-webhook
|
||||||
|
tweepy
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue