-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
55 lines (36 loc) · 1.5 KB
/
Main.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
import time
import requests
import discord
import xml.etree.ElementTree as ET
import datetime
import asyncio
from discord import RequestsWebhookAdapter
while 1:
class MyClient(discord.Client):
def __init__(self):
super().__init__()
self.Channel = self.get_channel("811020752882106408")
self.webHook = discord.Webhook.from_url("https://discord.com/api/webhooks/811042078670192681/By1JAy6LEI1BuRSNMrABKvXn95HlfeS_ppMpvbW6WXZsXzjH6uUz2j6HSD5uPaYozdUn", adapter=RequestsWebhookAdapter())
async def on_ready(self):
print("ready")
def sendSnowMessage(self, message):
channel = self.get_channel(self.Channel)
self.webHook.send("How much of the county {}, What county {}?, type of school {}?, how many schools {} {}s, Date effective {}, Date issued {}".format(*message))
def checkSnowdayStatus():
data = []
r = requests.get("http://wvde.state.wv.us/closings/xml/putnam")
Tree = ET.fromstring(r.text)
for node in Tree:
for child in node:
data.append(child.text)
return data
client = MyClient()
date = datetime.datetime.now()
while 1:
print("happening")
data = checkSnowdayStatus()
if (date - datetime.datetime.strptime(data[6], '%Y-%m-%d %H:%M:%S')) > datetime.timedelta(hours=12):
print(data)
client.sendSnowMessage(data)
date = datetime.datetime.now()
time.sleep(60)