-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline_notification.py
64 lines (50 loc) · 1.78 KB
/
line_notification.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import requests
import time
import schedule
from okayama_alarm import wrn_okayama
from okayama_weather import Weahter
def line_massage(line_massage_notification):
token = ''
line_api = 'https://notify-api.line.me/api/notify'
headers = {'Authorization': f'Bearer {token}'}
data = {'message': f'message: {line_massage_notification}'}
requests.post(line_api, headers=headers, data=data)
def reserve_mimasaka():
wrn = wrn_okayama()
if [] == wrn["美作"]:
pass
else:
line_massage(f'現在、美作市に{wrn["美作"]}警報が発令されています。\n'
f'あと10分で決まるぞ!!')
time.sleep(60)
def decision_mimasaka():
wrn = wrn_okayama()
if [] == wrn["美作"]:
pass
else:
line_massage(f'美作市に{wrn["美作"]}警報が発令!!\n学校休み')
time.sleep(60)
def reserve_okayama():
wrn = wrn_okayama()
if [] == wrn["岡山"]:
pass
else:
line_massage(f'現在、岡山市に{wrn["岡山"]}警報が発令されています。\n10分後に期待だ!!!!')
def decision_okayama():
wrn = wrn_okayama()
if [] == wrn["岡山"]:
pass
else:
line_massage(f'岡山市に{wrn["岡山"]}警報が出ています')
time.sleep(60)
def okayama_weather():
w = Weahter()
weather = w.okayama_weather()[1]
print(f'{weather[0]}の天気は{weather[1]}、翌日の{weather[3]}は{weather[4]}です')
schedule.every().day.at('05:50').do(reserve_mimasaka)
schedule.every().day.at('06:00').do(decision_mimasaka)
schedule.every().day.at('06:50').do(reserve_okayama)
schedule.every().day.at('07:00').do(decision_okayama)
schedule.every().day.at('00:00').do(okayama_weather)
while True:
schedule.run_pending()