-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-svg.ps1
53 lines (47 loc) · 1.18 KB
/
build-svg.ps1
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
$key = $env:WEATHER_API_KEY
$locationKey = "14-349727_1_AL";
$emojis = @{
1 = "☀️"
2 = "☀️"
3 = "🌤"
4 = "🌤"
5 = "🌤"
6 = "🌥"
7 = "☁️"
8 = "☁️"
11 = "🌫"
12 = "🌧"
13 = "🌦"
14 = "🌦"
15 = "⛈"
16 = "⛈"
17 = "🌦"
18 = "🌧"
19 = "🌨"
20 = "🌨"
21 = "🌨"
22 = "❄️"
23 = "❄️"
24 = "🌧"
25 = "🌧"
26 = "🌧"
29 = "🌧"
30 = "🌫"
31 = "🥵"
32 = "🥶"
}
$url = "http://dataservice.accuweather.com/forecasts/v1/daily/1day/$($locationKey)?apikey=$($key)"
$r = Invoke-RestMethod $url
$target = $r.DailyForecasts[0]
$degF = $target.Temperature.Maximum.Value
$degC = [math]::Round((($degF - 32) / 1.8))
$icon = $emojis[[int]$target.Day.Icon]
$psTime = (get-date).year - (get-date "7/1/2008").year
$todayDay = (get-date).DayOfWeek
$data = Get-Content -Raw ./template.svg
$data = $data.replace("{degF}", $degF)
$data = $data.replace("{degC}", $degC)
$data = $data.replace("{weatherEmoji}", $icon)
$data = $data.replace("{psTime}", $psTime)
$data = $data.replace("{todayDay}", $todayDay)
$data | Set-Content -Encoding utf8 ./chat.svg