-
Notifications
You must be signed in to change notification settings - Fork 1
/
discord_webhook.py
52 lines (37 loc) · 1.79 KB
/
discord_webhook.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from discord_webhooks import DiscordWebhooks
import os
from dotenv import load_dotenv # for python-dotenv method
load_dotenv()
# Put your discord webhook url here.
webhook_url = os.environ.get('webhook_url')
def send_msg(class_name, status, start_time, end_time):
WEBHOOK_URL = webhook_url
webhook = DiscordWebhooks(WEBHOOK_URL)
# Attaches a footer
webhook.set_footer(text='-- Naman')
if(status == "joined"):
webhook.set_content(title='Class Joined Succesfully',
description="Here's your report with :heart:")
# Appends a field
webhook.add_field(name='Class', value=class_name)
webhook.add_field(name='Status', value=status)
webhook.add_field(name='Joined at', value=start_time)
webhook.add_field(name='Leaving at', value=end_time)
elif(status == "left"):
webhook.set_content(title='Class left Succesfully',
description="Here's your report with :heart:")
# Appends a field
webhook.add_field(name='Class', value=class_name)
webhook.add_field(name='Status', value=status)
webhook.add_field(name='Joined at', value=start_time)
webhook.add_field(name='Left at', value=end_time)
elif(status == "noclass"):
webhook.set_content(title='Seems like no class today',
description="No join button found! Assuming no class.")
# Appends a field
webhook.add_field(name='Class', value=class_name)
webhook.add_field(name='Status', value=status)
webhook.add_field(name='Expected Join time', value=status)
webhook.add_field(name='Expected Leave time', value=end_time)
webhook.send()
print("Sent message to discord")