-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
37 lines (30 loc) · 1.06 KB
/
main.js
File metadata and controls
37 lines (30 loc) · 1.06 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
const ACCESS_TOKEN = PropertiesService.getScriptProperties().getProperty('LINE_TOKEN');
function notify() {
delTrigger();
let date = new Date()
date.setDate(date.getDate() + 1);
// 日付と祝日の取得
const tomorrow = getDate(date);
const holiday = getHoliday(date);
// 天気情報の取得
const area = '13104';
let content = UrlFetchApp.fetch('https://static.tenki.jp/static-api/history/forecast/' + area + '.js').getContentText();
content = JSON.parse(content.substring(content.indexOf('(') + 1, content.indexOf(');')));
let {max_t: temp_h = "不明", min_t: temp_l = "不明", t: weather = "不明"} = content;
const words = {
'時々': '|',
'一時': '|',
'のち': '»',
'晴': '☀',
'曇': '☁',
'雨': '☔',
'雪': '⛄'
};
for (let key in words) {
weather = weather.replace(key, words[key]);
}
// flex messeageの作成
const {flex, doNotify} = createFlexMessage(tomorrow, holiday, temp_h, temp_l, weather);
// LINE Messaging APIへ送信
if (doNotify) lineMessagingAPI(tomorrow, flex);
}