-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_hackmit_puzzle.py
More file actions
39 lines (30 loc) · 1.21 KB
/
check_hackmit_puzzle.py
File metadata and controls
39 lines (30 loc) · 1.21 KB
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
'''
Watches my.hackmit.org for changes in HTML. Use to
detect puzzle upload.
Author: Wyatt Phillips
'''
import requests, bs4
import time, datetime
import os
from pushsafer import init, Client
def print_wtime(text):
print(datetime.datetime.fromtimestamp(time.time()).strftime('[%Y-%m-%d %I:%M %p]: ') + text)
url = 'https://hackmit.org/'
string_watch = "<!-- nice attempt, but puzzle isn't up yet -->"
update_time = 60
event_fire_attempt = 0
event_fired = False
while not event_fired:
res = requests.get(url)
event_fire_attempt = event_fire_attempt + 1
if not res.status_code == 200:
print_wtime('failed to retrieve webpage (' + str(res.status_code) + ')... attempt #' + str(event_fire_attempt))
time.sleep(update_time)
elif not string_watch in res.text:
print_wtime('Event Fired: String detected at ' + url)
event_fired = True
init("9pF4clfsIC4DQGrQQgul")
Client("").send_message("A puzzle has ben uploaded to HackMIT!", "Event Fired!", "17746", "26", "5", "3", "https://hackmit.org/", "HackMIT", "0", "1", "120", "1200", "0", "", "", "")
else:
print_wtime('no state change detected... attempt #' + str(event_fire_attempt))
time.sleep(update_time)