Skip to content

Instantly share code, notes, and snippets.

@kunimi53chi
Last active January 17, 2019 04:00
Show Gist options
  • Save kunimi53chi/11eba69c29d3582356d4336c6fc66c38 to your computer and use it in GitHub Desktop.
Save kunimi53chi/11eba69c29d3582356d4336c6fc66c38 to your computer and use it in GitHub Desktop.
Kancolle Cat Notification (Python 3)
import winsound
import requests
import sys
import time
# access to your server's banner
WATCH_URL = 'http://xxx.xxx.xxx.xxx/kcs/resources/image/world/xxx_xxx_xxx_xxx_t.png'
def alert():
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME)
def ping():
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME)
def sleep():
time.sleep(45)
# If you want to stop, pless ^C on terminal
while(True):
try:
ping()
time.sleep(6)
r = requests.get(WATCH_URL, timeout=5)
r.raise_for_status()
sleep()
except requests.exceptions.Timeout:
print('Response is too slow. Isnt it the Cat?' )
alert()
sleep()
continue
except requests.exceptions.HTTPError:
print('HTTP Error occured. Isnt it the Cat?')
alert()
sleep()
continue
except Exception as e:
print('Unexpected Exception occured.')
print('{}: {}'.format(type(e).__name__, str(e)))
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME)
sys.exit(1)
@kunimi53chi
Copy link
Author

I sure hope you know what you are doing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment