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
|
|||
![Webhook Bot](https://i.imgur.com/hA6yvtj.png)
|
||||
|
||||
## 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
|
||||
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
|
||||
send_email_alerts = False
|
||||
email_sender = '' # Your email address
|
||||
|
|
23
handler.py
23
handler.py
|
@ -1,15 +1,22 @@
|
|||
import config as config
|
||||
from telegram import Bot
|
||||
from discord_webhook import DiscordWebhook
|
||||
import tweepy
|
||||
import smtplib, ssl
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
telegram = config.send_telegram_alerts
|
||||
discord = config.send_discord_alerts
|
||||
twitter = config.send_twitter_alerts
|
||||
email = config.send_email_alerts
|
||||
|
||||
if telegram:
|
||||
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):
|
||||
if telegram:
|
||||
|
@ -17,12 +24,20 @@ def send_buy_order(data):
|
|||
print('Alert has been sent to Telegram.')
|
||||
else:
|
||||
print('INFO: Telegram alerts are disabled.')
|
||||
|
||||
if discord:
|
||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||
response = discord_alert.execute()
|
||||
print('Alert has been sent to Discord.')
|
||||
else:
|
||||
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:
|
||||
email_msg = MIMEText(data)
|
||||
email_msg['Subject'] = config.email_subject
|
||||
|
@ -43,12 +58,20 @@ def send_sell_order(data):
|
|||
print('Alert has been sent to Telegram.')
|
||||
else:
|
||||
print('INFO: Telegram alerts are disabled.')
|
||||
|
||||
if discord:
|
||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||
response = discord_alert.execute()
|
||||
print('Alert has been sent to Discord.')
|
||||
else:
|
||||
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:
|
||||
email_msg = MIMEText(data)
|
||||
email_msg['Subject'] = config.email_subject
|
||||
|
|
|
@ -2,5 +2,6 @@ flask
|
|||
waitress
|
||||
python-telegram-bot
|
||||
discord-webhook
|
||||
tweepy
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue