-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.py
48 lines (27 loc) · 1.14 KB
/
send.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
from dotenv import load_dotenv
import http.client
import datetime
import os
load_dotenv()
##### Timestamp
def timestamp():
return datetime.datetime.now().strftime("%c")
##### Discord Messages
def discord_msg(message): # Code Credit: Chris Garrett
webhookurl = os.getenv('webhookurl')
# compile the form data (BOUNDARY can be anything)
formdata = "------:::BOUNDARY:::\r\nContent-Disposition: form-data; name=\"content\"\r\n\r\n"\
+ message + "\r\n------:::BOUNDARY:::--"
# get the connection and make the request
connection = http.client.HTTPSConnection("discordapp.com")
connection.request("POST", webhookurl, formdata, {
'content-type': "multipart/form-data; boundary=----:::BOUNDARY:::",
'cache-control': "no-cache",
})
# get response
response = connection.getresponse()
result = response.read()
# return back to the calling function with the result
return result.decode("utf-8")
def scheduled_msg():
print(discord_msg("Hope you're having a great day. I'm still actively searching for your 3080... Stand by."))