Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def whatDay ():
- # return date.datetime.now()
- day_in_int = date.datetime.today().weekday()
- if (day_in_int == 0):
- return "Monday"
- elif (day_in_int == 1):
- return "Tuesday"
- elif (day_in_int == 2):
- return "Wednesday"
- elif (day_in_int == 3):
- return "Thursday"
- elif (day_in_int == 4):
- return "Friday"
- elif (day_in_int == 5):
- return "Saturday"
- elif (day_in_int == 6):
- return "Sunday"
- else:
- return ""
- def whatTime():
- return date.datetime.utcnow().hour
- def isPractice ():
- currDay = whatDay()
- if (currDay == "Tuesday") or (currDay == "Wednesday") or (currDay == "Thursday") or (currDay == "Friday"):
- return 1
- else:
- return 0
- def waitTillPractice():
- bSentMessage = 0
- while(bSentMessage == 0):
- while(not isPractice()):
- print('Waiting for practice')
- time.sleep(30)
- #check if it's 20:00 UTC (2pm MST)
- if(whatTime() == 15):
- print("Sent checkin message at ", date.datetime.utcnow())
- #send checkin message:
- send()
- bSentMessage = 1
- else:
- print("wtf?")
- #wait 23.9 hours, so that we're not taking up cpu cycles
- print("Waiting till tomorrow <3")
- time.sleep(86040)
- bSentMessage = 0
- print('bSendMessage= ', bSentMessage)
- def send():
- message = "<@&559797378757034093> Check-in for practice/ games! If you're going to be late, signify the time you'll arrive. E.g. :eight: = I'm arriving at 8pm EST"
- # message = "Check-in for practice/ games! If you're going to be late, signify the time you'll arrive. E.g. :eight: = I'm arriving at 8pm EST"
- # your webhook URL
- webhookurl = "<webhook url>"
- # 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 the response
- response = connection.getresponse()
- result = response.read()
- # return back to the calling function with the result
- return result.decode("utf-8")
- waitTillPractice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement