kopia lustrzana https://github.com/fabston/TradingView-Webhook-Bot
Clean up and beautify code
rodzic
997420fb59
commit
cb431288d7
|
@ -12,13 +12,18 @@ import tweepy
|
|||
import smtplib, ssl
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
|
||||
def send_alert(data):
|
||||
if config.send_telegram_alerts:
|
||||
tg_bot = Bot(token=config.tg_token)
|
||||
try:
|
||||
tg_bot.sendMessage(data['telegram'], data['msg'].encode('latin-1','backslashreplace').decode('unicode_escape'), parse_mode='MARKDOWN')
|
||||
tg_bot.sendMessage(data['telegram'],
|
||||
data['msg'].encode('latin-1', 'backslashreplace').decode('unicode_escape'),
|
||||
parse_mode='MARKDOWN')
|
||||
except KeyError:
|
||||
tg_bot.sendMessage(config.channel, data['msg'].encode('latin-1','backslashreplace').decode('unicode_escape'), parse_mode='MARKDOWN')
|
||||
tg_bot.sendMessage(config.channel,
|
||||
data['msg'].encode('latin-1', 'backslashreplace').decode('unicode_escape'),
|
||||
parse_mode='MARKDOWN')
|
||||
except Exception as e:
|
||||
print('[X] Telegram Error:\n>', e)
|
||||
|
||||
|
|
4
main.py
4
main.py
|
@ -12,10 +12,12 @@ from handler import *
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
def get_timestamp():
|
||||
timestamp = time.strftime("%Y-%m-%d %X")
|
||||
return timestamp
|
||||
|
||||
|
||||
@app.route('/webhook', methods=['POST'])
|
||||
def webhook():
|
||||
try:
|
||||
|
@ -35,6 +37,8 @@ def webhook():
|
|||
print('[X]', get_timestamp(), 'Error:\n>', e)
|
||||
return 'Error', 400
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from waitress import serve
|
||||
|
||||
serve(app, host='0.0.0.0', port=80)
|
Ładowanie…
Reference in New Issue