tclserv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 21b7fd4d58f57f9e9b3ef619b3d248e1bec1fdd0
parent 9e2b737750c78f8bb76a3cd9acc88af5e8c363d8
Author: Ellenor Malik ellenor@umbrellix.net <j4jackj@gmx.com>
Date:   Sat, 30 Jun 2018 05:45:11 -0700

fuckity

Diffstat:
Acore/0000-callbacks.tcl | 40++++++++++++++++++++++++++++++++++++++++
Dcore/0000-conn.tcl | 65-----------------------------------------------------------------
Acore/0999-conn.tcl | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcore/2000-protocol-common.tcl | 39---------------------------------------
Mcore/2003-ts6.tcl | 25++++++++++++++-----------
Mcore/4000-eggcom.tcl | 2+-
Mmain.tcl | 2+-
Mmodules/debugserv.tcl | 64+++++++++++++++++++++++++++-------------------------------------
Mmodules/quoteserv.tcl | 85++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mmodules/weather.tcl | 29+++++++++++++++--------------
10 files changed, 207 insertions(+), 210 deletions(-)

diff --git a/core/0000-callbacks.tcl b/core/0000-callbacks.tcl @@ -0,0 +1,40 @@ +proc llbind {sock type client comd script} { + set moretodo 1 + while {0!=$moretodo} { + set llbindnum [rand 1 100000000] + if {[tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$llbindnum"]!=""} {} {set moretodo 0} + } + tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$llbindnum" $script + return $llbindnum +} + +proc unllbind {sock type client comd id} { + tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$id" "" + tnda unset "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$id" +} +proc unllbindall {sock type client comd} { + tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]" "" + tnda unset "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]" +} +proc firellbind {sock type client comd args} { +# puts stdout "$sock $type $client [ndcenc $comd] $args" + global globuctx globctx + set globctx $::netname($sock) + set globuctx $client + if {""!=[tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]"]} { + foreach {id script} [tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]"] { + if {$script != ""} { + set scr $script +# lappend $scr $sock + foreach {a} $args { + lappend scr $a + } + if {[set errcode [catch {eval $scr} erre]] > 0} { + puts stdout [format "in script %s:\n\nerror code %s, %s\ncontact script developer for assistance\n" $scr $errcode $erre] + firellbind $sock evnt - error $erre {*}$scr + } + } + };return + } + #if {""!=[tnda get "llbinds/$type/-/[ndcenc $comd]"]} {foreach {id script} [tnda get "llbinds/$type/-/[ndcenc $comd]"] {$script [lindex $args 0] [lrange $args 1 end]};return} +} diff --git a/core/0000-conn.tcl b/core/0000-conn.tcl @@ -1,65 +0,0 @@ -package require tls - -# just to have sanity here. don't want a {} dict or a bum array -set $::netname(-) - - -proc connect {addr port script} { - if {[string index $port 0] == "+"} { set port [string range $port 1 end] ; set comd ::tls::socket } {set comd socket} - set sck [$comd $addr $port] - fconfigure $sck -blocking 0 -buffering line - fileevent $sck readable [concat $script $sck] - return $sck -} - -proc mknetwork {headlines block} { - if {[llength $headlines]<2} { - puts stdout "fuck it, block's invalid ($headlines)" - return - } - set proto [dict get $block proto] - set numeric [dict get $block numeric] - set pass [dict get $block pass] - set host [dict get $block host] - set port [dict get $block port] - set servername [lindex $headlines 1] - set netname [lindex $headlines 0] - if {[catch {set ::sock($netname)} result] == 0} { - if {![eof $::sock($netname)]} { - puts stdout "probably rehashing (connected network block, [tnda get rehashing], $result)" - return - } - } - if {[dict exists $block prefixes]} { - # only required for ts6 - set prefixes [split [dict get $block prefix] " "] - set pfxl [split [lindex $prefixes 0] {}] - set pfxr [split [lindex $prefixes 1] {}] - set pfx [list] - foreach {p} $pfxl {m} $pfxr { - lappend pfx $p - lappend pfx $m - } - tnda set "ts6/$netname/prefix" $pfx - } { - # safe defaults, will cover charybdis and chatircd - tnda set "ts6/$netname/prefix" [list @ o % h + v] - } - # open a connection - set socke [connect $host $port [list $proto irc-main]] - after 500 $proto login $socke $numeric $pass $netname $servername - # store it up - postblock network $headlines $block -} - -proc core.conn.mknetworks {args} { - set blocks [tnda get "openconf/[ndcenc network]/blocks"]] - for {set i 1} {$i < ($blocks + 1)} {incr i} { - after 1000 [list mknetwork [tnda get [format "openconf/%s/hdr%s" [ndcenc network] $i]] [tnda get [format "openconf/%s/n%s" [ndcenc network] $i]]] - } -} - -blocktnd network - -llbind - evnt - confloaded core.conn.mknetworks - -#blockwcb network mknetwork diff --git a/core/0999-conn.tcl b/core/0999-conn.tcl @@ -0,0 +1,66 @@ +package require tls + +# just to have sanity here. don't want a {} dict or a bum array +set ::netname(-) - + +proc connect {addr port script} { + if {[string index $port 0] == "+"} { set port [string range $port 1 end] ; set comd ::tls::socket } {set comd socket} + set sck [$comd $addr $port] + fconfigure $sck -blocking 0 -buffering line + fileevent $sck readable [concat $script $sck] + return $sck +} + +proc mknetwork {headlines block} { + if {[llength $headlines]<2} { + puts stdout "fuck it, block's invalid ($headlines)" + return + } + set proto [dict get $block proto] + set numeric [dict get $block numeric] + set pass [dict get $block pass] + set host [dict get $block host] + set port [dict get $block port] + set servername [lindex $headlines 1] + set netname [lindex $headlines 0] + if {[catch {set ::sock($netname)} result] == 0} { + if {![eof $::sock($netname)]} { + puts stdout "probably rehashing (connected network block, [tnda get rehashing], $result)" + return + } + } + if {[dict exists $block prefixes]} { + # only required for ts6 + set prefixes [split [dict get $block prefix] " "] + set pfxl [split [lindex $prefixes 0] {}] + set pfxr [split [lindex $prefixes 1] {}] + set pfx [list] + foreach {p} $pfxl {m} $pfxr { + lappend pfx $p + lappend pfx $m + } + tnda set "ts6/$netname/prefix" $pfx + } { + # safe defaults, will cover charybdis and chatircd + tnda set "ts6/$netname/prefix" [list @ o % h + v] + } + # open a connection + set socke [connect $host $port [list $proto irc-main]] + after 500 $proto login $socke $numeric $pass $netname $servername + # store it up +# postblock network $headlines $block +} + +proc core.conn.mknetworks {args} { + set blocks [tnda get "openconf/[ndcenc network]/blocks"] + for {set i 1} {$i < ($blocks + 1)} {incr i} { + puts stdout "$blocks" + after 1000 [list mknetwork [tnda get [format "openconf/%s/hdr%s" [ndcenc network] $i]] [tnda get [format "openconf/%s/n%s" [ndcenc network] $i]]] + } +} + +blocktnd network + +llbind - evnt - confloaded core.conn.mknetworks + +#blockwcb network mknetwork diff --git a/core/2000-protocol-common.tcl b/core/2000-protocol-common.tcl @@ -1,39 +0,0 @@ -proc llbind {sock type client comd script} { - set moretodo 1 - while {0!=$moretodo} { - set llbindnum [rand 1 100000000] - if {[tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$llbindnum"]!=""} {} {set moretodo 0} - } - tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$llbindnum" $script - return $llbindnum -} - -proc unllbind {sock type client comd id} { - tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$id" "" - tnda unset "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]/$id" -} -proc unllbindall {sock type client comd} { - tnda set "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]" "" - tnda unset "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]" -} -proc firellbind {sock type client comd args} { -# puts stdout "$sock $type $client [ndcenc $comd] $args" - global globuctx globctx - set globctx $::netname($sck) - set globuctx $client - if {""!=[tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]"]} { - foreach {id script} [tnda get "llbinds/$::netname($sock)/$type/$client/[ndcenc $comd]"] { - if {$script != ""} { - set scr $script -# lappend $scr $sock - foreach {a} $args { - lappend scr $a - } - if {[catch {eval $scr} erre] > 0} {puts stdout $erre - firellbind $sock evnt - error $erre {*}$scr - } - } - };return - } - #if {""!=[tnda get "llbinds/$type/-/[ndcenc $comd]"]} {foreach {id script} [tnda get "llbinds/$type/-/[ndcenc $comd]"] {$script [lindex $args 0] [lrange $args 1 end]};return} -} diff --git a/core/2003-ts6.tcl b/core/2003-ts6.tcl @@ -274,7 +274,8 @@ proc ::ts6::irc-main {sck} { switch -nocase -- [lindex $comd $one] { "479" {putcmdlog $payload} "PASS" { - putquick "PRIVMSG #services :$line" + # putquick "PRIVMSG #services :$line" + puts stdout "we have a winner! $one" set ssid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append ssid [::ts6::b64e $::sid($sck)] tnda set "servers/$::netname($sck)/[ndaenc [lindex $comd 4]]/uplink" $ssid tnda set "servers/$::netname($sck)/[ndaenc [lindex $comd 4]]/sid" $payload @@ -282,15 +283,17 @@ proc ::ts6::irc-main {sck} { } "SERVER" { - putquick "PRIVMSG #services :$line" + puts stdout "we have a winner! $one" # if {[lindex $comd [expr {$one + 2}]] != 1} {return};#we don't support jupes tnda set "servers/$::netname($sck)/[ndaenc [tnda get "socksid/$::netname($sck)"]]/name" [lindex $comd [expr {$one + 1}]] tnda set "servers/$::netname($sck)/[ndaenc [tnda get "socksid/$::netname($sck)"]]/description" [lindex $comd [expr {$one + 3}]] - firellbind $sck evnt "-" "ts6.alive" $::netname($sck) ;#obvious - firellbind $sck evnt "-" "alive" $::netname($sck) ;#obvious + firellbind $sck evnt "-" "alive" $::netname($sck) + firellbind - evnt "-" "alive" $::netname($sck) + firellbind $sck evnt "-" "ts6.alive" $::netname($sck) } "SID" { + puts stdout "we have a winner! $one" tnda set "servers/$::netname($sck)/[ndaenc [lindex $comd 4]]/name" [lindex $comd 2] tnda set "servers/$::netname($sck)/[ndaenc [lindex $comd 4]]/description" [lindex $comd 5] tnda set "servers/$::netname($sck)/[ndaenc [lindex $comd 4]]/uplink" [lindex $comd 0] @@ -428,8 +431,8 @@ proc ::ts6::irc-main {sck} { "BMASK" { # always +, no ctr and no state set adding [split $payload " "] - if {[lindex $comd 3] > [tnda get "channels/$::netname($sck)/$chan/ts"]} {return} ;# send it packing. - set channel [lindex $comd 3] + set chan [ndaenc [lindex $comd 3]] + if {[lindex $comd 2] > [tnda get "channels/$::netname($sck)/$chan/ts"]} {return} ;# send it packing. set type [lindex $comd 4] foreach {mask} $adding { firellbind $sck mode - + $type [lindex $comd 0] [lindex $comd 3] $mask $::netname($sck) @@ -514,8 +517,8 @@ proc ::ts6::irc-main {sck} { set loggedin [lindex $comd 11] set realhost [lindex $comd 10] set modes [lindex $comd 5] - puts stdout $comd - puts stdout $modes + # puts stdout $comd + # puts stdout $modes if {[string first "o" $modes] != -1} {set oper 1} if {"*"!=$loggedin} { tnda set "login/$::netname($sck)/[lindex $comd $num]" $loggedin @@ -655,7 +658,7 @@ proc ::ts6::irc-main {sck} { } } } erreur] - #puts stdout [join [list $erreno $erreur] " "] + if {$erreno != 0} {puts stdout [join [list $erreno $erreur] " "]} } # irrelevant parameters should simply be ignored. @@ -691,13 +694,13 @@ proc ::ts6::login {sck {osid "42"} {password "link"} {servname "net"} {servernam #source services.conf proc ::ts6::nick2uid {sck nick} { - foreach {u n} [tnda get "nick/$netname"] { + foreach {u n} [tnda get "nick/$::netname($sck)"] { if {[string tolower $n] == [string tolower $nick]} {return $u} } return "" } proc ::ts6::intclient2uid {sck nick} { - foreach {u n} [tnda get "intclient/$netname"] { + foreach {u n} [tnda get "intclient/$::netname($sck)"] { if {[string tolower $n] == [string tolower $nick]} {return $u} } return "" diff --git a/core/4000-eggcom.tcl b/core/4000-eggcom.tcl @@ -167,7 +167,7 @@ proc setuctx {ctx} { proc % {c args} { set ul [list [curctx proto] $c [curctx sock]] foreach {a} $args {lappend ul $a} - uplevel 1 $a + uplevel 1 $ul } proc curctx {{type .net}} { diff --git a/main.tcl b/main.tcl @@ -120,7 +120,7 @@ proc svc.rehash {} { svc.rehash #by now we've loaded everything -callbind - evnt - "confloaded" loaded +firellbind - evnt - "confloaded" loaded #load from cfg file, not here diff --git a/modules/debugserv.tcl b/modules/debugserv.tcl @@ -1,10 +1,11 @@ blocktnd debugserv -llbind - evnt - confloaded debugserv.connect +llbind - evnt - alive debugserv.connect proc debugserv.connect {arg} { puts stdout [format "there are %s debugserv blocks" [set blocks [tnda get "openconf/[ndcenc debugserv]/blocks"]]] for {set i 1} {$i < ($blocks + 1)} {incr i} { + if {[string tolower [lindex [tnda get [format "openconf/%s/hdr%s" [ndcenc debugserv] $i]] 0]] != [string tolower $arg]} {continue} after 1000 [list debugserv.oneintro [tnda get [format "openconf/%s/hdr%s" [ndcenc debugserv] $i]] [tnda get [format "openconf/%s/n%s" [ndcenc debugserv] $i]]] } } @@ -27,7 +28,7 @@ proc debugserv.find6sid {n s {hunting 0}} { } proc debugservenabled {chan} { - if {[string tolower $chan] != [string tolower [tnda get "debugserv/[curctx]logchan"]} {return 0} + if {[string tolower $chan] != [string tolower [tnda get "debugserv/[curctx net]/logchan"]]} {return 0} return 1 } @@ -39,21 +40,31 @@ proc debugserv.oneintro {headline block} { tnda set "debugserv/$net/logchan" $logchan #tnda set "debugserv/$net/nspass" $nspass setctx $net - if {[% intclient2uid [tnda get "debugserv/$net/ourid"]] == ""} {$::nettype($net) sendUid $nsock $nick $ident $host $host [set ourid [$::nettype($net) getfreeuid $net]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes} + if {[% intclient2uid [tnda get "debugserv/$net/ourid"]] == ""} {% sendUid $nick $ident $host $host [set ourid [% getfreeuid]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes} + set ouroid [tnda get "debugserv/$net/ourid"] + if {[info exists ourid]} {tnda set "debugserv/$net/ourid" $ourid} {set ourid [tnda get "debugserv/$net/ourid"]} + unllbindall $nsock pub - ".rehash" + unllbindall $nsock pub - ".metadata" + unllbindall $nsock msg $ourid "rehash" + unllbindall $nsock msg $ourid "metadata" + if {$ouroid != $ourid} { + unllbindall $nsock msg $ouroid "rehash" + unllbindall $nsock msg $ouroid "metadata" + } setuctx $nick - tnda set "debugserv/$net/ourid" $ourid llbind $nsock pub - ".metadata" [list debugserv.pmetadata $net] llbind $nsock pub - ".rehash" [list debugserv.crehash $net] if {[string length $nspass] != 0 && [string length $nickserv] != 0} { # only works if nettype is ts6! - if {[string first [debugserv.find6sid $net $nsserv] [$::nettype($net) nick2uid $net $nickserv]] == 0} { - $::nettype($net) privmsg $nsock $ourid $nickserv $nspass + if {[string first [debugserv.find6sid $net $nsserv] [% nick2uid $nickserv]] == 0} { + % privmsg $ourid $nickserv $nspass } { - $::nettype($net) privmsg $nsock $ourid $logchan [gettext debugserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [debugserv.find6sid $net $nsserv]] + % privmsg $ourid $logchan [gettext debugserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [debugserv.find6sid $net $nsserv]] } } - after 650 $::nettype($net) putjoin $nsock $ourid $logchan - after 700 [list $::nettype($net) putmode $nsock $ourid $logchan "+ao" [format "%s %s" [$::nettype($net) intclient2uid $net $ourid] [$::nettype($net) intclient2uid $net $ourid]]] + after 650 % putjoin $ourid $logchan + after 700 [list % putmode $ourid $logchan "+ao" [format "%s %s" [% intclient2uid $ourid] [% intclient2uid $ourid]]] + llbind $nsock msg [tnda get "debugserv/$net/ourid"] "metadata" [list debugserv.metadata $net] llbind $nsock msg [tnda get "debugserv/$net/ourid"] "rehash" [list debugserv.rehash $net] # llbind $nsock pub - "gettext" [list debugserv.gettext $net] @@ -63,52 +74,31 @@ proc debugserv.oneintro {headline block} { proc debugserv.rehash {n i m} {debugserv.crehash $n $i $i $m} -proc operHasPrivilege {n i p} { - # this bit requires irca. - set metadatum [tnda get "metadata/$n/$i/[ndcenc PRIVS]"] - set md [split $metadatum " "] - set pl [split $p " ,"] - foreach {pv} $pl { - if {[lsearch $md $pv] != -1} {return 1} - } - return 0 -} - -proc operHasAllPrivileges {n i p} { - # this bit requires irca. - set metadatum [tnda get "metadata/$n/$i/[ndcenc PRIVS]"] - set md [split $metadatum " "] - set pl [split $p " ,"] - foreach {pv} $pl { - if {[lsearch $md $pv] == -1} {return 0} - } - return 1 -} - proc debugserv.crehash {n c i m} { if {![operHasPrivilege $n $i [tnda get "debugserv/$n/rehashprivs"]]} { - $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.youvenoprivs2 $i [join [split [tnda get "debugserv/$n/rehashprivs"] ", "] ", or "]] + % [expr {$c != $i ? "privmsg" : "notice"}] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.youvenoprivs2 $i [join [split [tnda get "debugserv/$n/rehashprivs"] ", "] ", or "]] } { after 500 [list uplevel #0 [list svc.rehash]] - $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.rehashed [$::nettype($n) uid2nick $n $i]] + % [expr {$c != $i ? "privmsg" : "notice"}] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.rehashed [% uid2nick $i]] } } proc debugserv.pmetadata {n c i m} { # net chan id msg setctx $n - if {($c != $i) && ![debugservenabled]} {return} + if {($c != $i) && ![debugservenabled $c]} {return} set metadatalist [tnda get "metadata/$n/$i"] if {[llength $metadatalist] < 2} { - $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.nometadata [$::nettype($n) uid2nick $n $i]] + % [expr {$c != $i ? "privmsg" : "notice"}] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.nometadata [% uid2nick $i]] } foreach {.datum value} $metadatalist { set datum [ndcdec ${.datum}] - $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [set totmsg [gettext debugserv.metadata $datum [$::nettype($n) uid2nick $n $i] $value]] + % [expr {$c != $i ? "privmsg" : "notice"}] [tnda get "debugserv/$n/ourid"] $c [set totmsg [gettext debugserv.metadata $datum [% uid2nick $i] $value]] } - $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext [expr {[tnda get "oper/$n/$i"] == 1 ? "debugserv.isoper" : "debugserv.isntoper"}] [$::nettype($n) uid2nick $n $i] $i] + % [expr {$c != $i ? "privmsg" : "notice"}] [tnda get "debugserv/$n/ourid"] $c [gettext [expr {[tnda get "oper/$n/$i"] == 1 ? "debugserv.isoper" : "debugserv.isntoper"}] [% uid2nick $i] $i] } proc debugserv.metadata {n i m} { debugserv.pmetadata $n $i $i $m } + diff --git a/modules/quoteserv.tcl b/modules/quoteserv.tcl @@ -3,11 +3,12 @@ blocktnd qshelp source quoteserv.help -llbind - evnt - confloaded quoteserv.connect +llbind - evnt - alive quoteserv.connect proc quoteserv.connect {arg} { puts stdout [format "there are %s quoteserv blocks" [set blocks [tnda get "openconf/[ndcenc quoteserv]/blocks"]]] for {set i 1} {$i < ($blocks + 1)} {incr i} { + if {[string tolower [lindex [tnda get [format "openconf/%s/hdr%s" [ndcenc quoteserv] $i]] 0]] != [string tolower $arg]} {continue} after 1000 [list quoteserv.oneintro [tnda get [format "openconf/%s/hdr%s" [ndcenc quoteserv] $i]] [tnda get [format "openconf/%s/n%s" [ndcenc quoteserv] $i]]] } } @@ -39,20 +40,20 @@ proc quoteserv.oneintro {headline block} { tnda set "quoteserv/[curctx net]/logchan" $logchan #tnda set "quoteserv/[curctx net]/nspass" $nspass setctx $net - $::nettype($net) sendUid $nsock $nick $ident $host $host [set ourid [$::nettype($net) getfreeuid $net]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes + % sendUid $nick $ident $host $host [set ourid [% getfreeuid]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes tnda set "quoteserv/[curctx net]/ourid" $ourid # llbind $nsock pub - ".metadata" [list quoteserv.pmetadata $net] # llbind $nsock pub - ".rehash" [list quoteserv.crehash $net] if {[string length $nspass] != 0 && [string length $nickserv] != 0} { # only works if nettype is ts6! - if {[string first [quoteserv.find6sid $net $nsserv] [$::nettype($net) nick2uid $net $nickserv]] == 0} { - $::nettype($net) privmsg $nsock $ourid $nickserv $nspass + if {[string first [quoteserv.find6sid $net $nsserv] [% nick2uid $nickserv]] == 0} { + % privmsg $ourid $nickserv $nspass } { - $::nettype($net) privmsg $nsock $ourid $logchan [gettext quoteserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [quoteserv.find6sid $net $nsserv]] + % privmsg $ourid $logchan [gettext quoteserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [quoteserv.find6sid $net $nsserv]] } } - after 650 $::nettype($net) putjoin $nsock $ourid $logchan - after 700 [list $::nettype($net) putmode $nsock $ourid $logchan "+ao" [format "%s %s" [$::nettype($net) intclient2uid $net $ourid] [$::nettype($net) intclient2uid $net $ourid]]] + after 650 % putjoin $ourid $logchan + after 700 [list % putmode $ourid $logchan "+ao" [format "%s %s" [% intclient2uid $ourid] [% intclient2uid $ourid]]] # llbind $nsock msg [tnda get "quoteserv/[curctx net]/ourid"] "metadata" [list quoteserv.metadata $net] # llbind $nsock msg [tnda get "quoteserv/[curctx net]/ourid"] "rehash" [list quoteserv.rehash $net] # llbind $nsock pub - "gettext" [list quoteserv.gettext $net] @@ -65,7 +66,7 @@ proc quoteserv.oneintro {headline block} { puts stdout "to join $chan on [curctx]" if {1!=$is} {continue} quoteservjoin [ndadec $chan] 0 -# [curctx proto] putjoin [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] +# % putjoin [tnda get "quoteserv/[curctx net]/ourid"] [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] # tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname([curctx sock])/ts"] } } @@ -79,16 +80,16 @@ proc qs.pmdo {n i t m} { proc quoteservjoin {chan {setting 1}} { set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] puts stdout "to join $chan on [curctx]" - [curctx proto] putjoin [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan - [curctx proto] putmode [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan "+ao" \ - [format "%s %s" [[curctx proto] intclient2uid [curctx net] [tnda get "quoteserv/[curctx net]/ourid"]]\ - [[curctx proto] intclient2uid [curctx net] [tnda get "quoteserv/[curctx net]/ourid"]]] + % putjoin [tnda get "quoteserv/[curctx net]/ourid"] $chan + % putmode [tnda get "quoteserv/[curctx net]/ourid"] $chan "+ao" \ + [format "%s %s" [% intclient2uid [tnda get "quoteserv/[curctx net]/ourid"]]\ + [% intclient2uid [tnda get "quoteserv/[curctx net]/ourid"]]] if {$setting} {nda set "quoteserv/[curctx net]/regchan/$ndacname" 1} } proc quoteservpart {chan {who "the script"} {msg isunused}} { set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] - [curctx proto] putpart [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.left $who] + % putpart [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.left $who] nda set "quoteserv/[curctx net]/regchan/$ndacname" 0 nda unset "quoteserv/[curctx net]/regchan/$ndacname" } @@ -133,9 +134,9 @@ proc quoteservdo {n chan from m} { set ptn [format "*%s*" [join $para " "]] set qts [quotesearch $chan $ptn] if {[llength $qts] != 0} { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.results #[join $qts ", #"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.results #[join $qts ", #"]] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] } } "vi*1st*ma*" { @@ -151,10 +152,10 @@ proc quoteservdo {n chan from m} { set qtn [lindex $qts 0] set qt [nda get "quoteserv/[curctx net]/quotes/$ndacname/q$qtn"] set qb [nda get "quoteserv/[curctx net]/quotes/$ndacname/u$qtn"] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] } } "ad*" { @@ -167,20 +168,20 @@ proc quoteservdo {n chan from m} { set qt [join $para " "] set qtn [expr {([llength [nda get "quoteserv/[curctx net]/quotes/$ndacname"]]/6)+1}] nda set "quoteserv/[curctx net]/quotes/$ndacname/q$qtn" $qt - nda set "quoteserv/[curctx net]/quotes/$ndacname/u$qtn" [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [[curctx proto] uid2nick [curctx net] $from] [[curctx proto] uid2ident [curctx net] $from] [[curctx proto] uid2host [curctx net] $from]] + nda set "quoteserv/[curctx net]/quotes/$ndacname/u$qtn" [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [% uid2nick $from] [% uid2ident $from] [% uid2host $from]] nda set "quoteserv/[curctx net]/quotes/$ndacname/a$qtn" [string tolower [tnda get "login/[curctx net]/$from"]] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.added $qtn] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.added $qtn] } "gad*" { set qt [join $para " "] set qtn [expr {([llength [nda get "quoteserv/[curctx net]/quotes/$ndacname"]]/6)+3}] if {![operHasPrivilege [curctx net] $from [tnda get "quoteserv/[curctx net]/operflags"]]} { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] } { nda set "quoteserv/[curctx net]/gquotes/q$qtn" $qt - nda set "quoteserv/[curctx net]/gquotes/u$qtn" [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [[curctx proto] uid2nick [curctx net] $from] [[curctx proto] uid2ident [curctx net] $from] [[curctx proto] uid2host [curctx net] $from]] + nda set "quoteserv/[curctx net]/gquotes/u$qtn" [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [% uid2nick $from] [% uid2ident $from] [% uid2host $from]] nda set "quoteserv/[curctx net]/gquotes/a$qtn" [tnda get "login/[curctx net]/$from"] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.added $qtn] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.added $qtn] } } "de*" { @@ -192,7 +193,7 @@ proc quoteservdo {n chan from m} { } set qtn [lindex $para 0] if {![string is integer $qtn]} { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint] } if {[ismodebutnot $chan $from v] || [operHasPrivilege [curctx net] $from [tnda get "quoteserv/[curctx net]/operflags"]] || [string tolower [uid2hand $from]] == [nda get "quoteserv/[curctx net]/quotes/$ndacname/a$qtn"]} { set qt [nda get "quoteserv/[curctx net]/quotes/$ndacname/q$qtn"] @@ -201,22 +202,22 @@ proc quoteservdo {n chan from m} { nda unset "quoteserv/[curctx net]/quotes/$ndacname/q$qtn" nda unset "quoteserv/[curctx net]/quotes/$ndacname/u$qtn" nda unset "quoteserv/[curctx net]/quotes/$ndacname/a$qtn" - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.removed $qtn $qb] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.removedcontents $qt] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.removed $qtn $qb] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.removedcontents $qt] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] } } "gde*" { set qtn [lindex $para 0] - if {![string is integer $qtn]} {[curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} + if {![string is integer $qtn]} {% privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} if {[operHasPrivilege [curctx net] $from [tnda get "quoteserv/[curctx net]/operflags"]]} { nda unset "quoteserv/[curctx net]/gquotes/q$qtn" "" nda unset "quoteserv/[curctx net]/gquotes/u$qtn" "" nda unset "quoteserv/[curctx net]/gquotes/a$qtn" "" - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database." + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database." } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] } } "jo*" { @@ -227,7 +228,7 @@ proc quoteservdo {n chan from m} { if {[ismodebutnot $tochan $from v] || [operHasPrivilege [curctx net] $from [tnda get "quoteserv/[curctx net]/operflags"]]} { quoteservjoin $tochan } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] } } "goa*" - "pa*" - "le*" { @@ -236,9 +237,9 @@ proc quoteservdo {n chan from m} { } set tochan [lindex $para 0] if {[ismodebutnot $tochan $from v] || [operHasPrivilege [curctx net] $from [tnda get "quoteserv/[curctx net]/operflags"]]} { - quoteservpart $tochan [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [[curctx proto] uid2nick [curctx net] $from] [[curctx proto] uid2ident [curctx net] $from] [[curctx proto] uid2host [curctx net] $from]] + quoteservpart $tochan [format "(%s) %s!%s@%s" [tnda get "login/[curctx net]/$from"] [% uid2nick $from] [% uid2ident $from] [% uid2host $from]] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.enopriv [tnda get "quoteserv/[curctx net]/operflags"]] } } "vi*" { @@ -249,26 +250,26 @@ proc quoteservdo {n chan from m} { if {![quoteservenabled [lindex $opara 0]]} {return} } set qtn [lindex $para 0] - if {![string is integer $qtn]} {[curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} + if {![string is integer $qtn]} {% privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} set qt [nda get "quoteserv/[curctx net]/quotes/$ndacname/q$qtn"] set qb [nda get "quoteserv/[curctx net]/quotes/$ndacname/u$qtn"] if {$qt != ""} { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] } } "gvi*" { set qtn [lindex $para 0] - if {![string is integer $qtn]} {[curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} + if {![string is integer $qtn]} {% privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.usevalidint]} set qt [nda get "quoteserv/[curctx net]/gquotes/q$qtn"] set qb [nda get "quoteserv/[curctx net]/gquotes/u$qtn"] if {$qt != ""} { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.qheader $qtn $qb] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.quote $qt] } { - [curctx proto] privmsg [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] + % privmsg [tnda get "quoteserv/[curctx net]/ourid"] $chan [gettext quoteserv.noresults] } } "he*" { @@ -282,7 +283,7 @@ proc quoteservdo {n chan from m} { set helplist [tnda get "openconf/[ndcenc qshelp]/n1"] dictassign $helplist main helpfile foreach {helpline} $helpfile { - [curctx proto] notice [curctx sock] [tnda get "quoteserv/[curctx net]/ourid"] $from $helpline + % notice [tnda get "quoteserv/[curctx net]/ourid"] $from $helpline } } } diff --git a/modules/weather.tcl b/modules/weather.tcl @@ -1,13 +1,14 @@ blocktnd weatherserv blocktnd wshelp -source weatherserv.help +#source weatherserv.help -llbind - evnt - confloaded weatherserv.connect +llbind - evnt - alive weatherserv.connect proc weatherserv.connect {arg} { puts stdout [format "there are %s weatherserv blocks" [set blocks [tnda get "openconf/[ndcenc weatherserv]/blocks"]]] for {set i 1} {$i < ($blocks + 1)} {incr i} { + if {[string tolower [lindex [tnda get [format "openconf/%s/hdr%s" [ndcenc weatherserv] $i]] 0]] != [string tolower $arg]} {continue} after 1000 [list weatherserv.oneintro [tnda get [format "openconf/%s/hdr%s" [ndcenc weatherserv] $i]] [tnda get [format "openconf/%s/n%s" [ndcenc weatherserv] $i]]] } } @@ -39,20 +40,20 @@ proc weatherserv.oneintro {headline block} { tnda set "weather/[curctx net]/logchan" $logchan #tnda set "weather/[curctx net]/nspass" $nspass setctx $net - $::nettype($net) sendUid $nsock $nick $ident $host $host [set ourid [$::nettype($net) getfreeuid $net]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes + % sendUid $nick $ident $host $host [set ourid [% getfreeuid]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes tnda set "weather/[curctx net]/ourid" $ourid # llbind $nsock pub - ".metadata" [list weatherserv.pmetadata $net] # llbind $nsock pub - ".rehash" [list weatherserv.crehash $net] if {[string length $nspass] != 0 && [string length $nickserv] != 0} { # only works if nettype is ts6! - if {[string first [weatherserv.find6sid $net $nsserv] [$::nettype($net) nick2uid $net $nickserv]] == 0} { - $::nettype($net) privmsg $nsock $ourid $nickserv $nspass + if {[string first [weatherserv.find6sid $net $nsserv] [% nick2uid $nickserv]] == 0} { + % privmsg $ourid $nickserv $nspass } { - $::nettype($net) privmsg $nsock $ourid $logchan [gettext weatherserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [weatherserv.find6sid $net $nsserv]] + % privmsg $ourid $logchan [gettext weatherserv.impostornickserv $nickserv [$::nettype($net) nick2uid $n $nickserv] $nsserv [weatherserv.find6sid $net $nsserv]] } } - after 650 [list $::nettype($net) putjoin $nsock $ourid $logchan] - after 950 [list $::nettype($net) putmode $nsock $ourid $logchan "+ao" [format "%s %s" [$::nettype($net) intclient2uid $net $ourid] [$::nettype($net) intclient2uid $net $ourid]]] + after 650 [list % putjoin $ourid $logchan] + after 950 [list % putmode $ourid $logchan "+ao" [format "%s %s" [% intclient2uid $ourid] [% intclient2uid $ourid]]] # llbind $nsock msg [tnda get "weather/[curctx net]/ourid"] "metadata" [list weatherserv.metadata $net] # llbind $nsock msg [tnda get "weather/[curctx net]/ourid"] "rehash" [list weatherserv.rehash $net] # llbind $nsock pub - "gettext" [list weatherserv.gettext $net] @@ -65,7 +66,7 @@ proc weatherserv.oneintro {headline block} { puts stdout "to join $chan on [curctx]" if {1!=$is} {continue} weatherjoin [ndadec $chan] 0 -# [curctx proto] putjoin [curctx sock] [tnda get "weather/[curctx net]/ourid"] [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] +# % putjoin [tnda get "weather/[curctx net]/ourid"] [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] # tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname([curctx sock])/ts"] } } @@ -77,16 +78,16 @@ llbind [curctx sock] request "weather" "-" weatherjoin proc weatherjoin {chan {setting 1}} { set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] puts stdout "to join $chan on [curctx]" - [curctx proto] putjoin [curctx sock] [tnda get "weather/[curctx net]/ourid"] $chan - [curctx proto] putmode [curctx sock] [tnda get "weather/[curctx net]/ourid"] $chan "+ao" \ - [format "%s %s" [[curctx proto] intclient2uid [curctx net] [tnda get "weather/[curctx net]/ourid"]]\ - [[curctx proto] intclient2uid [curctx net] [tnda get "weather/[curctx net]/ourid"]]] + % putjoin [tnda get "weather/[curctx net]/ourid"] $chan + % putmode [tnda get "weather/[curctx net]/ourid"] $chan "+ao" \ + [format "%s %s" [% intclient2uid [tnda get "weather/[curctx net]/ourid"]]\ + [% intclient2uid [tnda get "weather/[curctx net]/ourid"]]] if {$setting} {nda set "weather/[curctx net]/regchan/$ndacname" 1} } proc weatherpart {chan {who "the script"} {msg isunused}} { set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] - [curctx proto] putpart [curctx sock] [tnda get "weather/[curctx net]/ourid"] $chan [gettext weather.left $who] + % putpart [tnda get "weather/[curctx net]/ourid"] $chan [gettext weather.left $who] nda set "weather/[curctx net]/regchan/$ndacname" 0 nda unset "weather/[curctx net]/regchan/$ndacname" }