-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscord_alerts.py
More file actions
26 lines (25 loc) · 975 Bytes
/
Copy pathdiscord_alerts.py
File metadata and controls
26 lines (25 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from discord_webhook import DiscordWebhook, DiscordEmbed
from datetime import datetime
def webhook_alert(symbol,side,coin_price,client_number):
'''
Webhook Conection with Discord for Notifications and logs.
'''
now = datetime.now()
timestamp = datetime.timestamp(now)
description = (
f"Coin: {symbol}\n"
f"Side: {side}\n"
f"Price: {coin_price}\n"
f"Client number: {client_number}"
)
if side.lower() == "buy":
color = "00ff27"
elif side.lower() == "sell":
color = "ff0004"
webhook = DiscordWebhook(url='--Webhook Url Here--')
embed = DiscordEmbed(title='New Position Order', description=description, color=color)
embed.set_timestamp()
embed.set_footer(text='Glaud#0283', icon_url='https://glaud.should-be.legal/3kR3RAm.png')
embed.set_thumbnail(url='https://glaud.should-be.legal/A1wFArM.png')
webhook.add_embed(embed)
webhook.execute()