# twitch - kano addon -- twk-b on efnet set twitch(version) 0.0.5 addname "twitch $twitch(version)" addecho "" addecho "[kano] , , , " addecho "[kano] /| , , _ /| /| " addecho "[kano] ____/ |_/| |\\ (_)___/ |_______ / | " addecho "[kano] \\__ _/ | _ | \\ _\\__ __/ \\/ | " addecho "[kano] / | |/ \\| )/ ) / |/ /\\__| (__ " addecho "[kano] / | | | | |/ | \\/ \\_ \\ " addecho "[kano] ( | ! ! | | | / o ) " addecho "[kano] \\___ |\\_______ |_ |\\___ |\\____ /\\__|__ | created by twk-b" addecho "[kano] \\| \\| \\| \\| \\/ \\| version $twitch(version)" addecho "[kano] ` ` ` ` ` thnx to kano, conio, ph0rg..." addecho "" # ac @ @ # type = check, edit, nedit, combo, ecombo foreach win "status channel query users chat" { menu $win "Addo&ns->&twitch->&list" /bnc-c menu $win "Addo&ns->&twitch->&add/edit" /bnc menu $win "Addo&ns->&twitch->&random" "/bnc-c -random" menu $win "Addo&ns->&twitch->&stats" /bncstat menu $win "" } ac check @autoback @1 auto back on keypress \[twitch\] kaddhelp xget "xdcc get from " "/xget " /xg kaddhelp xlist "xdcc list <+/@/all> voice by default" "/xlist " /xl kaddhelp bnc "bnc configureation" /bnc - kaddhelp bnc-c "bnc connect dialog, or -random for random" "/bnc-c \[-random\]" - hotkey enter { if {[get_cookie autoback 1] && $isaway && [string index [input get_text] 0]!="/" && [window_type]=="channel"} { /back }} alias ca { /clearall; complete } alias m { /msg [join [raw_args]]; complete } alias w { /wall [join [raw_args]]; complete } alias u { /dvoc [join [raw_args]]; complete } alias xg { /xget [raw_args]; complete } alias xget { if {[lindex [args] 0] == "?" || [llength [args]] < "2"} { /help xget; complete } foreach pack [lrange [args] 1 end] { if {[string index $pack 0] == "#"} { /quote privmsg [lindex [args] 0] :\x01XDCC send $pack\x01; echo "[twitch] [twitch] getting packet $pack from [lindex [args] 0]" } else { /quote privmsg [lindex [args] 0] :\x01XDCC send #$pack\x01; echo "[twitch] getting packet #$pack from [lindex [args] 0]" } } complete } alias xl { /xlist [args]; complete } alias xlist { if {[lindex [args] 0] == "?"} { /help xlist; complete } set names "" if {[llength [args]]} { switch -- [lindex [args] 0] { all { set names [channel]; regsub -all @ $names "" names; regsub -all \\+ $names "" names } @ - o { set names [nicks [channel] @*]; regsub -all @ $names "" names } + - v - default { if {[lsearch [string tolower [nicks [channel]]] *[string tolower [lindex [args] 0]]]!=-1} { set names [lindex [args] 0] } else { set names [nicks [channel] +*]; regsub -all \\+ $names "" names }} } } else { set names [nicks [channel] +*]; regsub -all \\+ $names "" names } echo "[twitch] twitch - xlisting users ([join $names ,])..." /quote privmsg [join $names ,] :\x01XDCC list\x01 complete } alias b { /botsay [raw_args]; complete } alias botsay { global twitch if ![stricmp [lindex [args] 0] "-botname"] { set twitch(botname) [lindex [args] 1]; echo "[twitch] botname set to [lindex [args] 1]" } elseif [info exists twitch(botname)] { /quote PRIVMSG $twitch(botname) :say [channel] [raw_args] } else { echo "[twitch] please set the botname to use. /botsay -botname " } complete } alias bnc { set info [get_cookie twitch-bnc] set hosts ""; foreach i $info { lappend hosts [lindex $i 0] } switch -- [string tolower [lindex [args] 0]] { "-list" { set bstat [get_cookie twitch-bstat] echo "[twitch] bnc listing..." set vcnt 0 foreach i $info { echo "[kano] [b].:' [lindex $i 0][b] ([llength [lrange $i 5 end]] vhosts)... " set hcnt 0 foreach vh [lrange $i 5 end] { set found 0 foreach bs $bstat { if {!$found && [string match $vh:* $bs]} { echo "[kano] | ([format %-2s [lindex [split $bs :] 1]]) $vh "; set hcnt [expr $hcnt + [lindex [split $bs :] 1]]; set found 1 }} if {!$found} { echo "[kano] | (??) $vh " } } echo "[kano] `:. ($hcnt) usages..." set hcnt 0; foreach bs $bstat { if {[lsearch [lrange $i 5 end] [lindex [split $bs :] 0]]!=-1} { set hcnt [expr $hcnt + [lindex [split $bs :] 1]] }} set vcnt [expr $vcnt + $hcnt] } echo "[twitch] [b][llength $info][b] bnc server with [b]$vcnt[b] usages..." complete; return } } set il "" lappend il [list label a 55 5 140 10 "bnc host"] lappend il [list combo addrem 5 15 45 100 "add/edit remove"] lappend il [list combo -e hosts 55 15 140 100 $hosts] set ans [FALC_dialog -t "\[twitch\] bnc" 200 35 $il] if {$ans==""} { complete; return } set host [string tolower [lindex [lindex $ans 1] 1]] switch -- [lindex [lindex $ans 0] 1] { "add/edit" { if {[lsearch $hosts $host]==-1} { set port 7000; set password ""; set ident [my_user]; set vhosts "$host"; set servers [join [server] :]; set new 1 } else { foreach i $info { if {![stricmp [lindex $i 0] $host]} { set port [lindex $i 1]; set password [lindex $i 2]; set ident [lindex $i 3]; set server [lindex $i 4]; set servers [lindex $i 4]; set vhosts [lrange $i 5 end]; set new 0 }}} foreach s [get_cookie servers] { if [stricmp $s [lindex $servers 0]] { lappend servers [join $s :] }} while 1 { set il "" lappend il [list label a 5 5 85 10 "bnc port"] lappend il [list edit port 50 5 30 10 $port] lappend il [list label a 90 5 45 10 "password"] lappend il [list edit password 130 5 60 10 $password] lappend il [list label a 5 15 85 10 "ident"] lappend il [list edit ident 50 15 140 10 $ident] lappend il [list label a 5 24 85 10 "irc server:port"] lappend il [list combo -e server 50 25 140 100 $servers] lappend il [list combo addrem 5 35 40 100 "none add remove"] lappend il [list combo -e vhosts 50 35 140 100 $vhosts] set ans [FALC_dialog -t "\[twitch\] bnc $host" 195 55 $il] if {"$ans"==""} { break } set port [lindex [lindex $ans 0] 1] set password [lindex [lindex $ans 1] 1] set ident [lindex [lindex $ans 2] 1] set server [lindex [lindex $ans 3] 1] switch -- [lindex [lindex $ans 4] 1] { add { lappend vhosts [lindex [lindex $ans 5] 1] set_cookie twitch-bstat "[get_cookie twitch-bstat] [lindex [lindex $ans 5] 1]:0" } remove { [regsub -all -- [lindex [lindex $ans 5] 1] $vhosts "" vhosts] set bstat ""; foreach bs [get_cookie twitch-bstat] { if [string match [lindex [lindex $ans 5] 1]:* $bs] { lappend bstat $bs }} set_cookie twitch-bstat $bstat } } } if $new { lappend info "$host $port $password $ident $server $vhosts" set_cookie twitch-bnc $info set_cookie twitch-bstat "[get_cookie twitch-bstat] $host:0" echo "[twitch] added bnc host: $host..." } else { set info2 "" foreach i $info { if {[stricmp [lindex $i 0] $host]} { lappend info2 $i } else { lappend info2 "$host $port $password $ident $server $vhosts" }} set_cookie twitch-bnc $info2 echo "[twitch] updated bnc host: $host..." } } "remove" { set info2 "" foreach i $info { if [stricmp [lindex $i 0] $host] { lappend info2 $i } } else { set bstat ""; foreach bs [get_cookie twitch-bstat] { if {[lsearch [lrange $i 5 end] [lindex [split $bs :] 0]]==-1} { lappend bstat $bs }} set_cookie twitch-bstat $bstat } set_cookie twitch-bnc $info2 echo "[twitch] removed bnc host: $host..." } } complete } alias bnc-c { set info [get_cookie twitch-bnc] set hostinfo "" if ![stricmp [lindex [args] 0] "-random"] { set hostinfo [lindex $info [rand 0 [expr [llength $info]-1]]] set vhost [lindex [lrange $hostinfo 5 end] [rand 0 [expr [llength [lindex $hostinfo 4]]-1]]] } else { set vhosts ""; foreach i $info { lappend vhosts [lrange $i 5 end] }; set vhosts [join $vhosts] set il "" lappend il [list combo vhost 5 5 140 100 $vhosts] set ans [FALC_dialog -t "\[twitch\] bnc connection" 150 25 $il] if {$ans==""} { complete; return } set vhost [lindex [lindex $ans 0] 1] foreach i $info { if {[lsearch [lrange $i 5 end] [lindex [lindex $ans 0] 1]]!=-1} { set hostinfo $i }} } set hcnt 0; set vcnt 0 set bstat [get_cookie twitch-bstat] foreach bs $bstat { if {[lsearch [lrange $hostinfo 5 end] [lindex [split $bs :] 0]]!=-1} { set hcnt [expr $hcnt + [lindex [split $bs :] 1]] if {[lindex [split $bs :] 0]==$vhost} { set vcnt [lindex [split $bs :] 1] } } } set vcnt 0 set bstat [get_cookie twitch-bstat] foreach bs $bstat { if {[string match $vhost:* $bs]} { set vcnt [expr 1 + [lindex [split $bs :] 1]] regsub -- $bs $bstat "$vhost:$vcnt" bstat set_cookie twitch-bstat $bstat } } echo "[twitch] connection to: [lindex $hostinfo 0]:[lindex $hostinfo 1] ($hcnt) using: $vhost..." /server [lindex $hostinfo 0]:[lindex $hostinfo 1]:[lindex $hostinfo 2] timer 2 1 "/quote vip $vhost; /quote ident [lindex $hostinfo 3]; /quote conn [split [lindex $hostinfo 4] :]" } proc twitch {} { return "[kano] 14\[twitch\]" }