123456789101112131415161718192021222324252627 |
- import urllib.request
- import json
- import requests
- def notify_group(msg):
- #'WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD' is ChoozmoTeam
- glist=['WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD']
- for gid in glist:
- headers = {"Authorization": "Bearer " + gid,"Content-Type": "application/x-www-form-urlencoded"}
- r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params={"message": msg})
- try:
- contents = urllib.request.urlopen("https://www.choozmo.com:8887/checkStatus").read()
- status_dict = json.loads(contents.decode('utf-8'))
- if len(status_dict['errors'])==0:
- print('Everything works fine')
- else:
- for msg in status_dict['errors']:
- notify_group('ERROR : '+msg+' down')
- except:
- err_msg = 'ERROR : 8887 status api down'
- print(err_msg)
- notify_group(err_msg)
|