-
Notifications
You must be signed in to change notification settings - Fork 0
/
horoskooppi.tcl
132 lines (86 loc) · 4.27 KB
/
horoskooppi.tcl
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# horoskooppi.tcl - Fetches Finnish horoschope from Iltalehti.
# by Roni "rolle" Laukkarinen
# rolle @ irc.quakenet.org, rolle_ @ IRCnet
# Updated when:
set versijonummero "0.2.20171103"
#------------------------------------------------------------------------------------
# Elä herran tähen mäne koskemaan tai taivas putoaa niskaas!
# Paskaa koodia vuodesta 1988.
package require Tcl 8.5
package require http 2.1
package require tdom
bind pub - !horo pub:horo
bind pub - !horoskooppi pub:horo
proc pub:horo { nick uhost hand chan text } {
set horoskooppiurl "http://www.iltalehti.fi/horoskooppi/index.shtml"
set horosivuhtml [::http::data [::http::geturl $horoskooppiurl]]
set horohtmlsrc [dom parse -html $horosivuhtml]
set horohtml [$horohtmlsrc documentElement]
if {[string trim $text] ne ""} {
if {[string trim $text] eq "oinas"} {
set oinashaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[2]}]
set oinas [$oinashaku asText]
putserv "PRIVMSG $chan :$oinas"
}
if {[string trim $text] eq "härkä"} {
set harkahaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[3]}]
set harka [$harkahaku asText]
putserv "PRIVMSG $chan :$harka"
}
if {[string trim $text] eq "kaksoset"} {
set kaksosethaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[4]}]
set kaksoset [$kaksosethaku asText]
putserv "PRIVMSG $chan :$kaksoset"
}
if {[string trim $text] eq "rapu"} {
set rapuhaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[5]}]
set rapu [$rapuhaku asText]
putserv "PRIVMSG $chan :$rapu"
}
if {[string trim $text] eq "leijona"} {
set leijonahaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[6]}]
set leijona [$leijonahaku asText]
putserv "PRIVMSG $chan :$leijona"
}
if {[string trim $text] eq "neitsyt"} {
set neitsythaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[7]}]
set neitsyt [$neitsythaku asText]
putserv "PRIVMSG $chan :$neitsyt"
}
if {[string trim $text] eq "vaaka"} {
set vaakahaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[8]}]
set vaaka [$vaakahaku asText]
putserv "PRIVMSG $chan :$vaaka"
}
if {[string trim $text] eq "skorpioni"} {
set skorpionihaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[9]}]
set skorpioni [$skorpionihaku asText]
putserv "PRIVMSG $chan :$skorpioni"
}
if {[string trim $text] eq "jousimies"} {
set jousimieshaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[10]}]
set jousimies [$jousimieshaku asText]
putserv "PRIVMSG $chan :$jousimies"
}
if {[string trim $text] eq "kauris"} {
set kaurishaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[11]}]
set kauris [$kaurishaku asText]
putserv "PRIVMSG $chan :$kauris"
}
if {[string trim $text] eq "vesimies"} {
set vesimieshaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[12]}]
set vesimies [$vesimieshaku asText]
putserv "PRIVMSG $chan :$vesimies"
}
if {[string trim $text] eq "kalat"} {
set kalathaku [$horohtml selectNodes {//*[@id="container_keski"]/div/div[3]/p[13]}]
set kalat [$kalathaku asText]
putserv "PRIVMSG $chan :$kalat"
}
} else {
global horoskooppiurl
putserv "PRIVMSG $chan :\002!horo\002 horoskoopinnimi (vaihtoehdot: oinas (21.3.-19.4.), härkä (20.4.-20.5.), kaksoset (21.5.-20.6.), rapu (21.6.-22.7.), leijona (23.7.-22.8.), neitsyt (23.8.-22.9.), vaaka (23.9.-23.10.), skorpioni (24.10.-22.11.), jousimies (23.11.-21.1.), kauris (22.12.-19.1.), vesimies (20.1.-19.2.), kalat (20.2.-20.3.))"
}
}
# Kukkuluuruu.
putlog "Rolle's horoskooppi.tcl (version $versijonummero) LOADED!"