### Not updated anymore, go to: http://fragp.com/files/scripts/selfmade/tcl/leo.tcl # leo.tcl 0.2 / phrep_ - irc.quakenet.org # 0.2.1 similar match / fragp - irc.quakenet.org # 0.2.2 putquick>puthelp, channel setting leo, more link / CyBex - irc.quakenet.org # 0.2.3 changes output format / CyBex # 0.2.4 fixed new html output of dict.leo.org / CyBex # 0.2.5 fixed orthographically similar words / CyBex # 0.2.6 partyline leo added / CyBex # 0.2.7 chanmode +c detection / CyBex # 0.2.8 translate german <> france with !leofr or "leo fr " # use: chanset #channel +leo (to activate) setudef flag leo package require http bind pub - !leo pub:leo bind pub - !leofr pub:leofr bind dcc - leo dcc:leo proc striptext {text} { regsub -all -- "\002|\037|\026|\003(\\d{1,2})?(,\\d{1,2})?" $text "" text return $text } proc rleo {c {n 0}} { if {$c=="-"} {return ""} regsub -all {(?:\<(.*?)\>)} $c "" c regsub -all {( )} $c " " c regsub -all {(®)} $c "" c regsub -all {(\s+)} $c " " c if {$n==1} { return " / [join $c]" } elseif {$n==2} { return " = [join $c]" } { return [join $c] } } proc rlleo {c {n 0} {l 0}} { if {$c=="-"} {return ""} regsub -all {(?:\<(.*?)\>)} $c " " c regsub -all {(\s+)} $c " " c regsub -all { |–} $c "" c if $l { if $n { return " / [join $c] (ger)" } { return "[join $c] (ger)"} } { if $n { return " / [join $c] (eng)" } { return "[join $c] (eng)" } } } proc rlfleo {c {n 0} {l 0}} { if {$c=="-"} {return ""} regsub -all {(?:\<(.*?)\>)} $c " " c regsub -all {(\s+)} $c " " c regsub -all { |–} $c "" c if $l { if $n { return " / [join $c] (ger)" } { return "[join $c] (ger)"} } { if $n { return " / [join $c] (fra)" } { return "[join $c] (fra)" } } } proc lbold {t s} { set x [string last [string tol $s] [string tol $t]]; set l [string len $s]; set z ""; while {$x!=-1} { set y "\002[string range $t $x [expr $x+$l]]\002"; append y [string range $t [expr $x+$l+1] end]; set t [string range $t 0 [expr $x-1]]; set z "$y$z"; set x [string last [string tol $s] [string tol $t]] } return $t$z } proc html2text {html} { regsub -all -- {\\|\[|\]} $html {\\\1} text regsub -all -- "�{0,2}(\\d+);" $text {[format %c \1]} text set text [subst -novariables $text] return [string map [list {¿} {¿} {ä} {ä} {Ä} {Ä} {ö} ö {Ö} {Ö} {ü} ü {Ü} {Ü} {ß} {ß} \ {} {} {} {} {'} \' {"} \" {„} \" {‘} \' {–} {-} {é} {é} \ {&eagrave;} {è} {ï} {ï} {&} {&} { } { } {>} {>} {<} {<} {♦} {*} {€} {€} \ {©} {©} {™} {™} {¡} {¡} {¢} {¢} {£} {£} {§} {§} {¨} \" \ {±} {±} {²} {²} {³} {³} {´} \' {µ} {µ} {¶} {¶} {·} {·} \ {¼} {¼} {½} {½} {¾} {¾} {•} {·} ] $text] } proc leo {x chan nick} { set n "http://dict.leo.org/?search=$x&searchLoc=0&relink=off&spellToler=on§Hdr=off&cmpType=relaxed&lang=en" set tok [http::geturl $n -timeout 1500] set con [http::data $tok] http::cleanup $tok set con [html2text $con] if {[regexp "search results" $con trash]} { set ehit "-"; set ghit "-"; set ehitt "-"; set ghitt "-"; set ehittt "-"; set ghittt "-"; set ehitttt "-"; set ghitttt "-"; set ehittttt "-"; set ghittttt "-" set r1 [regexp -nocase "(.*?).*?(.*?)" $con trash ehit ghit] set r2 [regexp -nocase ".*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitt ghitt] set r3 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehittt ghittt] set r4 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitttt ghitttt] set r5 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*.*?.*?(.*?).*(.*?)" $con trash ehittttt ghittttt] set text "[rleo $ehit 0][rleo $ghit 2][rleo $ehitt 1][rleo $ghitt 2][rleo $ehittt 1][rleo $ghittt 2][rleo $ehitttt 1][rleo $ghitttt 2][rleo $ehittttt 1][rleo $ghittttt 2]" set text [lbold $text $x] append text " - more: \037http://dict.leo.org/?search=$x\037" if {[string match *c* [lindex [split [getchanmode $chan]] 0]]} { puthelp "PRIVMSG $chan :[striptext $text]" } { puthelp "PRIVMSG $chan :$text" } } else { if {[regexp "similar words" $con trash]} { set ehit "-"; set ghit "-" regexp "
Orthographically similar words – English:

.*?" $con trash ehit; if {$ehit!="-"} {set ehit "Orthographically similar words – German:

.*?" $con trash ghit; if {$ghit!="-"} {set ghit "
(.*?).*?(.*?)" $con trash ehit ghit] set r2 [regexp -nocase ".*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitt ghitt] set r3 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehittt ghittt] set r4 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitttt ghitttt] set r5 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*.*?.*?(.*?).*(.*?)" $con trash ehittttt ghittttt] set text "[rleo $ehit 0][rleo $ghit 2][rleo $ehitt 1][rleo $ghitt 2][rleo $ehittt 1][rleo $ghittt 2][rleo $ehitttt 1][rleo $ghitttt 2][rleo $ehittttt 1][rleo $ghittttt 2]" set text [lbold $text $x] append text " - more: \037http://dict.leo.org/?search=$x&lp=frde\037" if {[string match *c* [lindex [split [getchanmode $chan]] 0]]} { puthelp "PRIVMSG $chan :[striptext $text]" } { puthelp "PRIVMSG $chan :$text" } } else { if {[regexp "ähnliche Wörter" $con trash]} { set ehit "-"; set ghit "-" regexp "
Orthographisch ähnliche Wörter - Französisch:

.*?" $con trash ehit; if {$ehit!="-"} {set ehit "
Orthographisch ähnliche Wörter - Deutsch:

.*?" $con trash ghit; if {$ghit!="-"} {set ghit "
(.*?).*?(.*?)" $con trash ehit ghit] set r2 [regexp -nocase ".*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitt ghitt] set r3 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehittt ghittt] set r4 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?(.*?).*(.*?)" $con trash ehitttt ghitttt] set r5 [regexp -nocase ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*.*?.*?(.*?).*(.*?)" $con trash ehittttt ghittttt] set text "[rleo $ehit 0][rleo $ghit 2][rleo $ehitt 1][rleo $ghitt 2][rleo $ehittt 1][rleo $ghittt 2][rleo $ehitttt 1][rleo $ghitttt 2][rleo $ehittttt 1][rleo $ghittttt 2]" set text [lbold $text $x] append text " - more: \037http://dict.leo.org/?search=$x\037" putidx $idx $text } else { if {[regexp "similar words" $con trash]} { set ehit "-"; set ghit "-" regexp "
Orthographically similar words – English:

.*?" $con trash ehit; if {$ehit!="-"} {set ehit "
Orthographically similar words – German:

.*?" $con trash ghit; if {$ghit!="-"} {set ghit "