-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather.red
47 lines (35 loc) · 1021 Bytes
/
weather.red
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
Red [
Title: ".system.apps.weather"
]
weather: function ['.city [string! word! unset!] /out][
.default.city: "paris"
switch/default type?/word get/any '.city [
unset! [
.city: .default.city
weather (.city)
]
word! string! [
.city: form .city
if not value? '.system [
sysRead: :read
]
output: sysRead to-url rejoin ["http://wttr.in/" .city]
parse output [(cum: copy "") thru "<pre>"
[some [copy text [to "<" | to "</"] (append cum text) [thru ">" | thru "/>"] ]]
copy text to "</pre>" (append cum text)]
replace/all cum {"} {"}
parse cum [copy output to "Follow @igor_chubin"]
either out [
return output
][
print output
]
]
][
throw-error 'script 'expect-arg .city
]
]
w: :weather
if not value? '.system [
weather
]