commit a75eea6c8a6234c6ac5890c2f5aecc95c66037c0
parent 8b24bba16430df875e211b86648120f35410f0b3
Author: IRCD <ircd@template.hostname>
Date: Sun, 8 Mar 2015 16:25:50 -0400
Wugh, long time since update.
Diffstat:
17 files changed, 869 insertions(+), 650 deletions(-)
diff --git a/chanserv.conf.example b/chanserv.conf.example
@@ -3,3 +3,5 @@ set cs(ident) "services"
set cs(host) "your.network.name"
set cs(admin) "j4jackj"
# REPLACE THIS! ^^ This user gets +mno set on him every bootup.
+set cs(netname) yournet
+::ts6::login $::sock($cs(netname)) $::numeric $::password $cs(netname)
diff --git a/core/0003-ts6.tcl b/core/0003-ts6.tcl
@@ -1,112 +1,186 @@
-# Because TS6 ircds are highly configurable, we start in Charybdis mode without
-# an idea what modes are permissible. This is to aid ChanServ.
+namespace eval ts6 {
+proc ::ts6::b64e {numb} {
+ set b64 [split "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" {}]
+
+ set res ""
+ while {$numb != 0} {
+ append res [lindex $b64 [expr {$numb % 36}]]
+ set numb [expr {$numb / 36}]
+ }
+ if {[string length $res] == 0} {
+ set res "A"
+ }
+ return [string reverse $res]
+}
+
+proc ::ts6::b64d {numb} {
+ set b64 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+ set numb [string trimleft $numb "A"]
+ set res 0
+ for {set i 0} {$i<[string length $numb]} {incr i} {
+ set new [string first [string index $numb $i] $b64]
+ incr res [expr {$new * (36 * $i)+1}]
+ }
+ return $res
+}
+}
+
+
+if {[info commands putdcc] != [list putdcc]} {
+ proc putdcc {idx text} {
+ puts $idx $text
+ }
+}
+
+if {[info commands putcmdlog] != [list putcmdlog]} {
+ proc putcmdlog {text} {
+ puts -nonewline stdout "(command) "
+ puts stdout $text
+ }
+}
+
namespace eval ts6 {
proc ::ts6::sendUid {sck nick ident host dhost uid {realname "* Unknown *"} {modes "+oiS"} {server ""}} {
- if {""==$server} {set server $::numeric}
+ if {""==$server} {set server $::sid($sck)}
set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $server]]}]]
append sid [::ts6::b64e $server]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- if {!$::ts6(euid)} {
+ if {![tnda get "ts6/$::netname($sck)/euid"]} {
set sl [format ":%s UID %s 1 %s %s %s %s 0 %s%s :%s" $sid $nick [clock format [clock seconds] -format %s] $modes $ident $host $sid $sendnn $realname]
} {
- set sl [format ":%s EUID %s 1 %s %s %s %s 0 %s%s * * :%s" $sid $nick [clock format [clock seconds] -format %s] $modes $ident $host $sid $sendnn $realname]
+ set sl [format ":%s EUID %s 1 %s %s %s %s 0 %s%s %s * :%s" $sid $nick [clock format [clock seconds] -format %s] $modes $ident $dhost $sid $sendnn $host $realname]
}
tnda set "intclient/$::netname($sck)/${sid}${sendnn}" $uid
- puts $sck $sl
- puts stdout $sl
+ tnda set "nick/$::netname($sck)/${sid}${sendnn}" $nick
+ putdcc $sck $sl
}
proc ::ts6::topic {sck uid targ topic} {
- set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
- append sid [::ts6::b64e $::numeric]
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+ append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s%s TOPIC %s :%s" $sid $sendnn $targ $topic]
+ putdcc $sck [format ":%s%s TOPIC %s :%s" $sid $sendnn $targ $topic]
+}
+
+proc ::ts6::setnick {sck uid newnick} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+ append sid [::ts6::b64e $::sid($sck)]
+ set sendid [::ts6::b64e $uid]
+ set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
+ append sendnn $sendid
+ putdcc $sck [format ":%s%s NICK %s :%s" $sid $sendnn $newnick [clock format [clock seconds] -format %s]]
+}
+
+proc ::ts6::sethost {sck targ topic} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+ append sid [::ts6::b64e $::sid($sck)]
+ if {![tnda get "ts6/$::netname($sck)/euid"]} {
+ putdcc $sck [format ":%s ENCAP * CHGHOST %s %s" $sid $targ $topic]
+ } {
+ putdcc $sck [format ":%s CHGHOST %s %s" $sid $targ $topic]
+ }
}
proc ::ts6::sendSid {sck sname sid {realname "In use by Services"}} {
-set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
-append sid [::ts6::b64e $::numeric]
+set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+append sid [::ts6::b64e $::sid($sck)]
set sl [format ":%s SID %s 1 %s :%s" [::ts6::b64e $sid] $sname [::ts6::b64e $sid] $realname]
- puts $sck $sl
+ putdcc $sck $sl
}
proc ::ts6::privmsg {sck uid targ msg} {
-set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
-append sid [::ts6::b64e $::numeric]
+set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s%s PRIVMSG %s :%s" $sid $sendnn $targ $msg]
+ putdcc $sck [format ":%s%s PRIVMSG %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::ts6::metadata {sck targ direction type {msg ""}} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+ append sid [::ts6::b64e $::sid($sck)]
+ if {[string toupper $direction] != "ADD" && [string toupper $direction] != "DELETE"} {putcmdlog "failed METADATA attempt (invalid arguments)";return} ;#no that didn't work
+ if {[string toupper $direction] == "ADD"} {
+ tnda set "metadata/$::netname($sck)/$targ/[ndaenc $type]" $msg
+ putdcc $sck [format ":%s ENCAP * METADATA %s %s %s :%s" $sid [string toupper $direction] $targ [string toupper $type] $msg]
+ }
+ if {[string toupper $direction] == "DELETE"} {
+ tnda set "metadata/$::netname($sck)/$targ/[ndaenc $type]" ""
+ putdcc $sck [format ":%s ENCAP * METADATA %s %s :%s" $sid [string toupper $direction] $targ [string toupper $type]]
+ }
}
proc ::ts6::kick {sck uid targ tn msg} {
-set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
-append sid [::ts6::b64e $::numeric]
+set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s%s KICK %s %s :%s" $sid $sendnn $targ $tn $msg]
+ putdcc $sck [format ":%s%s KICK %s %s :%s" $sid $sendnn $targ $tn $msg]
}
proc ::ts6::notice {sck uid targ msg} {
- set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]];append sid [::ts6::b64e $::numeric]
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
+ set sendid [::ts6::b64e $uid]
+ set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
+ append sendnn $sendid
+ putdcc $sck [format ":%s%s NOTICE %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::ts6::part {sck uid targ msg} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
+ set sendid [::ts6::b64e $uid]
+ set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
+ append sendnn $sendid
+ putdcc $sck [format ":%s%s PART %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::ts6::quit {sck uid msg} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s%s NOTICE %s :%s" $sid $sendnn $targ $msg]
+ putdcc $sck [format ":%s%s QUIT :%s" $sid $sendnn $msg]
+ tnda set "intclient/$::netname($sck)/${sid}${sendnn}" ""
+ tnda set "nick/$::netname($sck)/${sid}${sendnn}" ""
}
proc ::ts6::setacct {sck targ msg} {
- set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]];append sid [::ts6::b64e $::numeric]
- puts $sck [format ":%s ENCAP * SU %s %s" $sid $targ $msg]
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
+ putdcc $sck [format ":%s ENCAP * SU %s %s" $sid $targ $msg]
tnda set "login/$::netname($sck)/$targ" $msg
}
-proc ::ts6::bind {type client comd script} {
- set moretodo 1
- while {0!=$moretodo} {
- set bindnum [rand 1 10000000]
- if {[tnda get "binds/$type/$client/$comd/$bindnum"]!=""} {} {set moretodo 0}
- }
- tnda set "binds/$type/$client/$comd/$::netname($sck)/$bindnum" $script
- return $bindnum
+proc ::ts6::putmotd {sck targ msg} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
+ putdcc $sck [format ":%s 372 %s :- %s" $sid $targ $msg]
}
-proc ::ts6::unbind {type client comd id} {
- tnda set "binds/$type/$client/$comd/$::netname($sck)/$id" ""
+proc ::ts6::putmotdend {sck targ} {
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
+ putdcc $sck [format ":%s 376 %s :End of global MOTD." $sid $targ]
}
proc ::ts6::putmode {sck uid targ mode parm ts} {
- set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]];append sid [::ts6::b64e $::numeric]
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s%s TMODE %s %s %s %s" $sid $sendnn $ts $targ $mode $parm]
- puts stdout [format ":%s%s TMODE %s %s %s %s" $sid $sendnn $ts $targ $mode $parm]
+ putdcc $sck [format ":%s%s TMODE %s %s %s %s" $sid $sendnn $ts $targ $mode $parm]
}
proc ::ts6::putjoin {sck uid targ ts} {
- set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]];append sid [::ts6::b64e $::numeric]
+ set sid [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]];append sid [::ts6::b64e $::sid($sck)]
set sendid [::ts6::b64e $uid]
set sendnn [string repeat "A" [expr {6-[string length $sendid]}]]
append sendnn $sendid
- puts $sck [format ":%s SJOIN %s %s + :@%s%s" $sid $ts $targ $sid $sendnn]
- puts stdout [format ":%s SJOIN %s %s + :@%s%s" $sid $ts $targ $sid $sendnn]
-}
-
-proc ::ts6::callbind {sock type client comd args} {
- puts stdout [tnda get "binds/mode"]
- if {""!=[tnda get "binds/$sock/$type/$client/$comd"]} {
- foreach {id script} [tnda get "binds/$sock/$type/$client/$comd"] {
- $script [lindex $args 0] [lrange $args 1 end]
- };return
- }
- #if {""!=[tnda get "binds/$type/-/$comd"]} {foreach {id script} [tnda get "binds/$type/-/$comd"] {$script [lindex $args 0] [lrange $args 1 end]};return}
+ putdcc $sck [format ":%s SJOIN %s %s + :%s%s" $sid $ts $targ $sid $sendnn]
}
proc ::ts6::irc-main {sck} {
@@ -119,11 +193,11 @@ proc ::ts6::irc-main {sck} {
set gotsplitwhere [string first " :" $line]
if {$gotsplitwhere==-1} {set comd [split $line " "]} {set comd [split [string range $line 0 [expr {$gotsplitwhere - 1}]] " "]}
set payload [split [string range $line [expr {$gotsplitwhere + 2}] end] " "]
- puts stdout [join $comd " "]
- if {[lindex $comd 0] == "PING"} {puts $sck "PONG $::servername :$payload"}
- if {[lindex $comd 0] == "SERVER"} {puts $sck "VERSION"}
+ #putcmdlog [join $comd " "]
+ if {[lindex $comd 0] == "PING"} {putdcc $sck "PONG $::servername :$payload"}
+ if {[lindex $comd 0] == "SERVER"} {putdcc $sck "VERSION"}
switch -nocase -- [lindex $comd $one] {
- "479" {puts stdout $payload}
+ "479" {putcmdlog $payload}
"005" {
foreach {tok} [lrange $comd 3 end] {
@@ -134,55 +208,42 @@ proc ::ts6::irc-main {sck} {
set mod [split $v ")"]
set modechar [split [lindex $mod 1] {}]
set modepref [split [lindex $mod 0] {}]
- puts stdout "$key $val $modechar $modepref"
foreach {c} $modechar {x} $modepref {
- tnda set "ts6/prefix/$c" $x
+ nda set "ts6/$::netname($sck)/prefix/$c" $x
}
- puts stdout [tnda get "ts6/prefix"]
- }
- }
- }
- }
-
- "105" {
- foreach {tok} [lrange $comd [expr {$comd+1}] end] {
- foreach {key val} [split $tok "="] {
- if {$key == "PREFIX"} {
- # We're in luck! Server advertises its PREFIX in VERSION reply to servers.
- set v [string range $val 1 end]
- set mod [split $v ")"]
- set modechar [split [lindex $mod 1] {}]
- set modepref [split [lindex $mod 0] {}]
- foreach {c} $modechar {x} $modepref {
- tnda set "ts6/$::netname($sck)/prefix/$modepref" $modechar
+ foreach {x} $modechar {c} $modepref {
+ nda set "ts6/$::netname($sck)/pfxchar/$c" $x
}
+ putcmdlog [nda get "ts6/$::netname($sck)/prefix"]
+ putcmdlog [nda get "ts6/$::netname($sck)/pfxchar"]
}
}
}
}
"PRIVMSG" {
- if {[string index [lindex $comd 2] 0] == "#"} {
+ if {[string index [lindex $comd 2] 0] == "#" || [string index [lindex $comd 2] 0] == "&" || [string index [lindex $comd 2] 0] == "!" || [string index [lindex $comd 2] 0] == "+" || [string index [lindex $comd 2] 0] == "."} {
set client chan
callbind $sck pub "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
- callbind $sck evnt "-" "chanmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] ts6
+ callbind $sck evnt "-" "chanmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
} {
set client [tnda get "intclient/$::netname($sck)/[lindex $comd 2]"]
callbind $sck msg $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
- callbind $sck "evnt" "-" "privmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] ts6
+ callbind $sck "evnt" "-" "privmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
}
}
"NOTICE" {
- if {[string index [lindex $comd 2] 0] == "#"} {
+ if {![tnda get "ts6/$::netname($sck)/connected"]} {return}
+ if {[string index [lindex $comd 2] 0] == "#" || [string index [lindex $comd 2] 0] == "&" || [string index [lindex $comd 2] 0] == "!" || [string index [lindex $comd 2] 0] == "+" || [string index [lindex $comd 2] 0] == "."} {
set client chan
callbind $sck pubnotc "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
callbind $sck pubnotc-m "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
- callbind $sck "evnt" "-" "channotc" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] ts6
+ callbind $sck "evnt" "-" "channotc" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
} {
set client [tnda get "intclient/$::netname($sck)/[lindex $comd 2]"]
callbind $sck notc $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
- callbind $sck "evnt" "-" "privnotc" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] ts6
+ callbind $sck "evnt" "-" "privnotc" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
}
}
@@ -200,21 +261,21 @@ proc ::ts6::irc-main {sck} {
"JOIN" {
set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 3]]]]
- if {""==[tnda get "channels/$::netname($sck)/$chan/ts"]} {callbind $sck create "-" "-" [lindex $comd 3] [lindex $comd 0]}
- callbind $sck join "-" "-" [lindex $comd 3] [lindex $comd 0]
+ if {""==[tnda get "channels/$::netname($sck)/$chan/ts"]} {callbind $sck create "-" "-" [lindex $comd 3] [lindex $comd 0] $::netname($sck)}
+ callbind $sck join "-" "-" [lindex $comd 3] [lindex $comd 0] $::netname($sck)
tnda set "channels/$::netname($sck)/$chan/ts" [lindex $comd 2]
- tnda set "userchan/[lindex $comd 0]/$chan" 1
+ tnda set "userchan/$::netname($sck)/[lindex $comd 0]/$chan" 1
}
"TMODE" {
- set ctr 3
+ set ctr 4
set state 1
- foreach {c} [split [lindex $comd 3] {}] {
+ foreach {c} [split [lindex $comd 4] {}] {
switch -regexp -- $c {
"\\\+" {set state 1}
"-" {set state 0}
- "[ABCcDdiMmNnOpPQRrSsTtZz]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] $::netname($sck)}
- "[beljfqIaykohv]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] [lindex $comd [incr ctr]] $::netname($sck)}
+ "[ABCcDdiMmNnOpPQRrSsTtZz]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 3] "" $::netname($sck)}
+ "[beljfxqIaykohv]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 3] [lindex $comd [incr ctr]] $::netname($sck)}
}
}
}
@@ -237,26 +298,34 @@ proc ::ts6::irc-main {sck} {
set state uo
foreach {c} [split $nick {}] {
if {[string is integer $c]} {set state un}
- puts stdout "$c $nick"
- if {$state == "uo" && [info exists ::pfx($c)]} {set c $::pfx($c) ; }
+ if {$state == "uo"} {set c [nda get "ts6/$::netname($sck)/pfxchar/$c"] ; }
if {"un"==$state} {append un $c}
if {"uo"==$state} {append uo $c}
}
- puts stdout "$uo $un"
- if {""!=$uo} {tnda set "channels/$::netname($sck)/$chan/modes/$un" $uo}
- callbind $sck join "-" "-" [lindex $comd 3] $un
+ callbind $sck join "-" "-" [lindex $comd 3] $un $::netname($sck)
+ putcmdlog "$un+$uo"
+ if {""!=$uo} {tnda set "channels/$::netname($sck)/$chan/modes/$un" $uo
+ foreach {c} [split $uo {}] {
+ putcmdlog "$un+$c"
+ callbind $sck mode "-" + $c $un [lindex $comd 3] $un $::netname($sck)
+ }
+ }
}
}
"PART" {
- callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 0]
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 0] $::netname($sck)
set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
- tnda set "userchan/[lindex $comd 0]/$chan" 0
+ tnda set "userchan/$::netname($sck)/[lindex $comd 0]/$chan" 0
}
"KICK" {
- callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 3]
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 3] $::netname($sck)
+ }
+
+ "NICK" {
+ tnda set "nick/$::netname($sck)/[lindex $comd 0]" [lindex $comd 2]
}
"EUID" {
@@ -273,20 +342,44 @@ proc ::ts6::irc-main {sck} {
if {"*"!=$realhost} {
tnda set "rhost/$::netname($sck)/[lindex $comd $num]" $realhost
} {
- tnda set "rhost/$::netname($sck)/[lindex $comd $num]" [lindex $comd 6]
+ tnda set "rhost/$::netname($sck)/[lindex $comd $num]" [lindex $comd 7]
}
tnda set "nick/$::netname($sck)/[lindex $comd $num]" [lindex $comd 2]
tnda set "oper/$::netname($sck)/[lindex $comd $num]" $oper
tnda set "ident/$::netname($sck)/[lindex $comd $num]" [lindex $comd 6]
tnda set "vhost/$::netname($sck)/[lindex $comd $num]" [lindex $comd 7]
+ tnda set "rname/$::netname($sck)/[lindex $comd $num]" $payload
+ putcmdlog "New user at $::netname($sck) [lindex $comd $num] [lindex $comd 2]![lindex $comd 6]@[tnda get "rhost/$::netname($sck)/[lindex $comd $num]"] (vhost [tnda get "vhost/$::netname($sck)/[lindex $comd $num]"]) :$payload"
callbind $sck conn "-" "-" [lindex $comd $num]
}
"ENCAP" {
+ putcmdlog [join [list $comd "--" $payload] " "]
switch -nocase -- [lindex $comd 3] {
"SASL" {
#don't bother
}
+ "SU" {
+ if {$payload == ""} {set payload [lindex $comd 5]}
+ tnda set "login/$::netname($sck)/[lindex $comd 4]" $payload
+ if {$payload == ""} {callbind $sck logout "-" "-" [lindex $comd 4]} {callbind $sck login "-" "-" [lindex $comd 4] $payload}
+ }
+ "CERTFP" {
+ tnda set "certfps/$::netname($sck)/[lindex $comd 0]" $payload
+ callbind $sck encap "-" "certfp" [lindex $comd 0] $payload
+ }
+ "METADATA" {
+ switch -nocase -- [lindex $comd 4] {
+ "ADD" {
+ tnda set "metadata/$::netname($sck)/[lindex $comd 5]/[ndaenc [lindex $comd 6]]" $payload
+ callbind $sck encap "-" "metadata.[string tolower [lindex $comd 6]]" [lindex $comd 5] $payload
+ }
+ "DELETE" {
+ tnda set "metadata/$::netname($sck)/[lindex $comd 5]/[ndaenc $payload]" ""
+ callbind $sck encap "-" "metadata.[string tolower $payload]" [lindex $comd 5] ""
+ }
+ }
+ }
}
}
@@ -294,52 +387,176 @@ proc ::ts6::irc-main {sck} {
callbind $sck topic "-" "-" [lindex $comd 2] [join $payload " "]
}
"QUIT" {
+ if {![string is digit [string index [lindex $comd 0] 0]]} {
+ set ocomd [lrange $comd 1 end]
+ set on [lindex $comd 0]
+ set comd [list [::ts6::nick2uid $::netname($sck) $on] {*}$ocomd]
+ putcmdlog "Uh-oh, netsplit! $on -> [::ts6::nick2uid $::netname($sck) $on] has split"
+ }
+ foreach {chan _} [tnda get "userchan/$::netname($sck)/[lindex $comd 0]"] {
+ callbind $sck part "-" "-" [ndadec $chan] [lindex $comd 0] $::netname($sck)
+ tnda set "userchan/$::netname($sck)/[lindex $comd 0]/$chan" 0
+ }
+
tnda set "login/$::netname($sck)/[lindex $comd 0]" ""
tnda set "nick/$::netname($sck)/[lindex $comd 0]" ""
tnda set "oper/$::netname($sck)/[lindex $comd 0]" 0
tnda set "ident/$::netname($sck)/[lindex $comd 0]" ""
tnda set "rhost/$::netname($sck)/[lindex $comd 0]" ""
tnda set "vhost/$::netname($sck)/[lindex $comd 0]" ""
- foreach {chan _} [tnda get "userchan/[lindex $comd 0]"] {
- callbind $sck part "-" "-" [ndadec $chan] [lindex $comd 0]
- tnda set "userchan/[lindex $comd 0]/$chan" 0
- }
+ tnda set "rname/$::netname($sck)/[lindex $comd 0]" ""
+ tnda set "metadata/$::netname($sck)/[lindex $comd 0]" [list]
+ tnda set "certfps/$::netname($sck)/[lindex $comd 0]" ""
+ callbind $sck quit "-" "-" [lindex $comd 0] $::netname($sck)
}
"KILL" {
+ foreach {chan _} [tnda get "userchan/$::netname($sck)/[lindex $comd 2]"] {
+ callbind $sck part "-" "-" [ndadec $chan] [lindex $comd 2]
+ tnda set "userchan/$::netname($sck)/[lindex $comd 2]/$chan" 0
+ }
tnda set "login/$::netname($sck)/[lindex $comd 2]" ""
tnda set "nick/$::netname($sck)/[lindex $comd 2]" ""
tnda set "oper/$::netname($sck)/[lindex $comd 2]" 0
tnda set "ident/$::netname($sck)/[lindex $comd 2]" ""
tnda set "rhost/$::netname($sck)/[lindex $comd 2]" ""
tnda set "vhost/$::netname($sck)/[lindex $comd 2]" ""
+ tnda set "rname/$::netname($sck)/[lindex $comd 2]" ""
+ tnda set "metadata/$::netname($sck)/[lindex $comd 2]" [list]
+ tnda set "certfps/$::netname($sck)/[lindex $comd 2]" ""
+ }
+
+ "ERROR" {
+ putcmdlog "Recv'd an ERROR $payload from $::netname($sck)"
+ }
+
+ "CAPAB" {
+ tnda set "ts6/$::netname($sck)/euid" 0
+ foreach {cw} [split $payload " "] {
+ if {$cw == "EUID"} {tnda set "ts6/$::netname($sck)/euid" 1}
+ }
+ tnda set "ts6/$::netname($sck)/connected" 1
}
"PING" {
- set num [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
- append num [::ts6::b64e $::numeric]
+ set num [string repeat "0" [expr {3-[string length [::ts6::b64e $::sid($sck)]]}]]
+ append num [::ts6::b64e $::sid($sck)]
if {[lindex $comd 3]==""} {set pong [lindex $comd 0]} {set pong [lindex $comd 3]}
- puts $sck ":$num PONG $pong [lindex $comd 2]"
+ putdcc $sck ":$num PONG $pong [lindex $comd 2]"
}
}
}
-proc ::ts6::login {sck {sid $::numeric} {password $::password}} {
- set num [string repeat "0" [expr {3-[string length [::ts6::b64e $::numeric]]}]]
- append num [::ts6::b64e $::numeric]
+proc ::ts6::login {sck {osid "42"} {password "link"} {servname "net"}} {
+ set num [string repeat "0" [expr {3-[string length [::ts6::b64e $osid]]}]]
+ append num [::ts6::b64e $osid]
+ global netname sid sock nettype
+ set netname($sck) $servname
+ set nettype($servname) ts6
+ set sock($servname) $sck
+ set sid($sck) $osid
+ set sid($servname) $osid
+ tnda set "ts6/$::netname($sck)/connected" 0
+ tnda set "ts6/$::netname($sck)/euid" 0
if {![info exists ::ts6(halfops)]} {tnda set "pfx/halfop" v} {tnda set "pfx/halfop" $::ts6(halfops)}
if {![info exists ::ts6(ownermode)]} {tnda set "pfx/owner" o} {tnda set "pfx/owner" $::ts6(ownermode)}
if {![info exists ::ts6(protectmode)]} {tnda set "pfx/protect" o} {tnda set "pfx/protect" $::ts6(protectmode)}
if {![info exists ::ts6(euid)]} {set ::ts6(euid) 1}
- puts $sck "PASS $::password TS 6 :$num"
- puts $sck "CAPAB EUID"
- puts $sck "SERVER $::servername 1 :Services for IRC Networks"
- puts $sck "SVINFO 6 6 0 :[clock format [clock seconds] -format %s]"
- puts $sck ":$sid VERSION"
+ putdcc $sck "PASS $password TS 6 :$num"
+ putdcc $sck "CAPAB :EUID ENCAP IE EX CLUSTER EOPMOD SVS SERVICES"
+ putdcc $sck "SERVER $::servername 1 :chary.tcl for Eggdrop and related bots"
+ putdcc $sck "SVINFO 6 6 0 :[clock format [clock seconds] -format %s]"
+ putdcc $sck ":$num VERSION"
+ bind $sck mode - + ::ts6::checkop
+ bind $sck mode - - ::ts6::checkdeop
}
-
#source services.conf
+
+proc ::ts6::nick2uid {netname nick} {
+ foreach {u n} [tnda get "nick/$netname"] {
+ if {[string tolower $n] == [string tolower $nick]} {return $u}
+ }
+}
+proc ::ts6::intclient2uid {netname nick} {
+ foreach {u n} [tnda get "intclient/$netname"] {
+ if {[string tolower $n] == [string tolower $nick]} {return $u}
+ }
+}
+proc ::ts6::uid2nick {netname u} {
+ return [tnda get "nick/$netname/$u"]
+}
+proc ::ts6::uid2rhost {netname u} {
+ return [tnda get "rhost/$netname/$u"]
+}
+proc ::ts6::uid2host {netname u} {
+ return [tnda get "host/$netname/$u"]
+}
+proc ::ts6::uid2ident {netname u} {
+ return [tnda get "ident/$netname/$u"]
+}
+proc ::ts6::nick2host {netname nick} {
+ return [tnda get "host/$netname/[nick2uid $netname $nick]"]
+}
+proc ::ts6::nick2ident {netname nick} {
+ return [tnda get "ident/$netname/[nick2uid $netname $nick]"]
+}
+proc ::ts6::nick2rhost {netname nick} {
+ return [tnda get "rhost/$netname/[nick2uid $netname $nick]"]
+}
+proc ::ts6::getts {netname chan} {
+ return [tnda get "channels/$netname/[ndaenc $chan]/ts"]
+}
+proc ::ts6::getpfx {netname chan nick} {
+ return [tnda get "channels/$netname/[ndaenc $chan]/modes/[::ts6::nick2uid $netname $nick]"]
+}
+proc ::ts6::getupfx {netname chan u} {
+ return [tnda get "channels/$netname/[ndaenc $chan]/modes/$u"]
+}
+proc ::ts6::getpfxchars {netname modes} {
+ set o ""
+ foreach {c} [split $modes {}] {
+ append o [nda get "ts6/$netname/prefix/$c"]
+ }
+ return $o
+}
+proc ::ts6::getmetadata {netname nick metadatum} {
+ return [tnda get "metadata/$netname/[::ts6::nick2uid $netname $nick]/[ndaenc $metadatum]"]
+}
+proc ::ts6::getcertfp {netname nick} {
+ return [tnda get "certfps/$netname/[::ts6::nick2uid $netname $nick]"]
+}
+
+proc ::ts6::checkop {mc ftp} {
+ set f [lindex $ftp 0]
+ set t [lindex $ftp 1]
+ set p [lindex $ftp 2]
+ set n [lindex $ftp 3]
+ if {[nda get "ts6/$n/pfxchar/$mc"]==""} {return}
+putcmdlog "up $mc $f $t $p $n"
+ set chan [string map {/ [} [::base64::encode [string tolower $t]]]
+ tnda set "channels/$n/$chan/modes/$p" "[string map [list $mc ""] [tnda get "channels/$n/$chan/modes/$p"]]$mc"
+}
+
+proc ::ts6::checkdeop {mc ftp} {
+ set f [lindex $ftp 0]
+ set t [lindex $ftp 1]
+ set p [lindex $ftp 2]
+ set n [lindex $ftp 3]
+ if {[nda get "ts6/$n/pfxchar/$mc"]==""} {return}
+putcmdlog "down $mc $f $t $p $n"
+ set chan [string map {/ [} [::base64::encode [string tolower $t]]]
+ tnda set "channels/$n/$chan/modes/$p" "[string map [list $mc ""] [tnda get "channels/$n/$chan/modes/$p"]]"
+}
+
+proc ::ts6::getfreeuid {net} {
+set work 1
+set cns [list]
+foreach {_ cnum} [tnda get "intclient/$net"] {lappend cns $cnum}
+while {0!=$work} {set num [expr {[rand 300000]+10000}];if {[lsearch -exact $cns $num]==-1} {set work 0}}
+return $num
+}
+
namespace export *
namespace ensemble create
}
diff --git a/core/9999-protocol-common.tcl b/core/9999-protocol-common.tcl
@@ -15,10 +15,8 @@ proc callbind {sock type client comd args} {
puts stdout [tnda get "binds/mode"]
if {""!=[tnda get "binds/$sock/$type/$client/$comd"]} {
foreach {id script} [tnda get "binds/$sock/$type/$client/$comd"] {
- $script [lindex $args 0] [lrange $args 1 end]
+ if {$script != ""} {$script [lindex $args 0] [lrange $args 1 end]}
};return
}
#if {""!=[tnda get "binds/$type/-/$comd"]} {foreach {id script} [tnda get "binds/$type/-/$comd"] {$script [lindex $args 0] [lrange $args 1 end]};return}
}
-
-$maintype login $::sock
diff --git a/core/0003-ts6.tcl b/core/ts6.disabled
diff --git a/modules/0000-eggcompat.tcl b/modules/0000-eggcompat.tcl
@@ -1,8 +1,8 @@
source chanserv.conf
-bind $::sock mode "-" "+" bitchopcheck
-bind $::sock mode "-" "-" protectopcheck
-bind $::sock join "-" "-" autoopcheck
+#bind $::sock($::cs(netname)) mode "-" "+" bitchopcheck
+#bind $::sock($::cs(netname)) mode "-" "-" protectopcheck
+bind $::sock($::cs(netname)) join "-" "-" autoopcheck
proc protectopcheck {mc ftp} {
set f [lindex $ftp 0 0]
@@ -13,18 +13,18 @@ proc protectopcheck {mc ftp} {
if {"v"==$mc && ![channel get $t protectvoice]} {return}
switch -- $mc {
"o" {
- if {[matchattr [tnda get "login/$::netname($::sock)/$p"] omn|omn $t]} {
- $::maintype putmode $::sock 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock)/[ndaenc $t]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] omn|omn $t]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"]
}
}
"h" {
- if {[matchattr [tnda get "login/$::netname($::sock)/$p"] l|l $t]} {
- $::maintype putmode $::sock 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock)/[ndaenc $t]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] l|l $t]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"]
}
}
"v" {
- if {[matchattr [tnda get "login/$::netname($::sock)/$p"] v|v $t]} {
- $::maintype putmode $::sock 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock)/[ndaenc $t]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] v|v $t]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"]
}
}
}
@@ -32,55 +32,55 @@ proc protectopcheck {mc ftp} {
proc autoopcheck {c f} {
puts stdout "$c $f"
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |k $c]} {
- $::maintype putmode $::sock 77 $c +bb "*![tnda get "ident/$::netname($::sock)/$f"]@[tnda get "vhost/$::netname($::sock)/$f"] \$a:[tnda get "login/$::netname($::sock)/$f"]" [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
- $::maintype kick $::sock 77 $c $f "Autokicked (+k attribute)"
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |k $c]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +bb "*![tnda get "ident/$::netname($::sock($::cs(netname)))/$f"]@[tnda get "vhost/$::netname($::sock($::cs(netname)))/$f"] \$a:[tnda get "login/$::netname($::sock($::cs(netname)))/$f"]" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
+ $::maintype kick $::sock($::cs(netname)) 77 $c $f "Autokicked (+k attribute)"
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] n|] && [channel get $c operit]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] n|] && [channel get $c operit]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |n $c] && [channel get $c autoop]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |n $c] && [channel get $c autoop]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] m|] && [channel get $c operit]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] m|] && [channel get $c operit]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |m $c] && [channel get $c autoop]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |m $c] && [channel get $c autoop]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] a|]} {
- $::maintype putmode $::sock 77 $c +o $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] a|]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] o|] && [channel get $c operit]} {
- $::maintype putmode $::sock 77 $c +o $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] o|] && [channel get $c operit]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |o $c] && [channel get $c autoop]} {
- $::maintype putmode $::sock 77 $c +o $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |o $c] && [channel get $c autoop]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] l|] && [channel get $c operit]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] l|] && [channel get $c operit]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |l $c] && [channel get $c autohalfop]} {
- $::maintype putmode $::sock 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |l $c] && [channel get $c autohalfop]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] v|] && [channel get $c operit]} {
- $::maintype putmode $::sock 77 $c +v $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] v|] && [channel get $c operit]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +v $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
- if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |v $c] && [channel get $c autovoice]} {
- $::maintype putmode $::sock 77 $c +v $f [tnda get "channels/$::netname($::sock)/[ndaenc $c]/ts"]
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |v $c] && [channel get $c autovoice]} {
+ $::maintype putmode $::sock($::cs(netname)) 77 $c +v $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"]
return
}
}
@@ -97,33 +97,33 @@ proc bitchopcheck {mc ftp} {
if {"v"==$mc && ![channel get $t voicebitch]} {return}
switch -glob -- $mc {
"q" {
- if {![matchattr [tnda get "login/$::netname($::sock)/$p"] n|n $t]} {
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] n|n $t]} {
puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
- $::maintype putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
}
}
"a" {
- if {![matchattr [tnda get "login/$::netname($::sock)/$p"] mn|mn $t]} {
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] mn|mn $t]} {
puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
- $::maintype putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
}
}
"o" {
- if {![matchattr [tnda get "login/$::netname($::sock)/$p"] aomn|omn $t]} {
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] aomn|omn $t]} {
puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
- $::maintype putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
}
}
"h" {
- if {![matchattr [tnda get "login/$::netname($::sock)/$p"] l|l $t]} {
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] l|l $t]} {
puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
- $::maintype putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
}
}
"v" {
- if {![matchattr [tnda get "login/$::netname($::sock)/$p"] v|v $t]} {
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] v|v $t]} {
puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
- $::maintype putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
}
}
}
@@ -142,20 +142,20 @@ proc ndaenc {n} {
proc isbotnick {n} {return [expr {$n == $::botnick}]}
proc putserv {msg} {
- puts $::sock ":$::botnick $msg"
+ puts $::sock($::cs(netname)) ":$::botnick $msg"
puts stdout ":$::botnick $msg"
}
proc puthelp {msg} {
- puts $::sock ":$::botnick $msg"
+ puts $::sock($::cs(netname)) ":$::botnick $msg"
}
proc putquick {msg} {
- puts $::sock ":$::botnick $msg"
+ puts $::sock($::cs(netname)) ":$::botnick $msg"
}
proc putnow {msg} {
- puts $::sock ":$::botnick $msg"
+ puts $::sock($::cs(netname)) ":$::botnick $msg"
}
proc ndadec {n} {
@@ -166,10 +166,10 @@ proc msgmt {from msg} {
set handle [lindex $msg 0 0]
set attr [lindex $msg 0 1]
set chan [lindex $msg 0 2]
- $::maintype notice $::sock 77 $from "$handle $attr $chan Matchattr result: [matchattr $handle $attr $chan]"
+ $::maintype notice $::sock($::cs(netname)) 77 $from "$handle $attr $chan Matchattr result: [matchattr $handle $attr $chan]"
}
-bind $::sock msg 77 "matchattr" msgmt
+bind $::sock($::cs(netname)) msg 77 "matchattr" msgmt
proc matchattr {handle attr {chan "*"}} {
set handle [string tolower $handle]
@@ -267,21 +267,21 @@ proc validuser {n} {
if {""==[nda get "usernames/$n"]} {return 0} {return 1}
}
-bind $::sock msg 77 "chanset" msgchanset
-bind $::sock msg 77 "chattr" msgchattr
-bind $::sock msg 77 "setxtra" msgxtra
+bind $::sock($::cs(netname)) msg 77 "chanset" msgchanset
+bind $::sock($::cs(netname)) msg 77 "chattr" msgchattr
+bind $::sock($::cs(netname)) msg 77 "setxtra" msgxtra
set botnick $cs(nick)
chattr $cs(admin) +mnolv
proc msgchanset {from msg} {
set ndacname [ndaenc [lindex $msg 0 0]]
set chanset [lindex $msg 0 1]
- if {300>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock)/$from"] m|m [lindex $msg 0 0]]} {
- $::maintype notice $::sock 77 $from "Only channel super-operators (300) and above and network masters may use eggdrop-compatible chansets."
+ if {300>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] m|m [lindex $msg 0 0]]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Only channel super-operators (300) and above and network masters may use eggdrop-compatible chansets."
return
}
channel set [lindex $msg 0 0] $chanset
- $::maintype notice $::sock 77 $from "Eggdrop compatible chanset $chanset set on [lindex $msg 0 0]."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Eggdrop compatible chanset $chanset set on [lindex $msg 0 0]."
}
proc msgchattr {from msg} {
@@ -301,20 +301,20 @@ proc msgchattr {from msg} {
if {$c == "m"} {set c "mn|mn"}
if {$c == "n"} {set c "n|n"}
if {$c == "a"} {set c "mn|"}
- if {![matchattr [tnda get "login/$::netname($::sock)/$from"] $c $chan]} {
- $::maintype notice $::sock 77 $from "You may only give flags you already possess (Any of flags $c required to set $attrs)."
+ if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] $c $chan]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You may only give flags you already possess (Any of flags $c required to set $attrs)."
return
}
}
if {""==$chan} {chattr $hand $attrs} {chattr $hand $attrs $chan}
- $::maintype notice $::sock 77 $from "Global flags for $hand are now [nda get "eggcompat/attrs/global/[string tolower $handle]"]"
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Global flags for $hand are now [nda get "eggcompat/attrs/global/[string tolower $handle]"]"
if {""==[nda get "regchan/$ndacname/levels/[string tolower $hand]"]} {nda set "regchan/$ndacname/levels/[string tolower $hand]" 1}
- if {$ch != ""} {$::maintype notice $::sock 77 $from "Flags on $chan for $hand are now [nda get "eggcompat/attrs/$ndacname/[string tolower $handle]"]"}
+ if {$ch != ""} {$::maintype notice $::sock($::cs(netname)) 77 $from "Flags on $chan for $hand are now [nda get "eggcompat/attrs/$ndacname/[string tolower $handle]"]"}
}
proc nick2hand {nick} {
foreach {uid nic} [tnda get "nick"] {
- if {$nick == $nic} {return [tnda get "login/$::netname($::sock)/$uid"]}
+ if {$nick == $nic} {return [tnda get "login/$::netname($::sock($::cs(netname)))/$uid"]}
}
}
@@ -327,14 +327,14 @@ proc setuser {nick datafield {dataval "body"} val} {
}
proc msgxtra {from msg} {
- if {[set log [tnda get "login/$::netname($::sock)/$from"]]==""} {
- $::maintype notice $::sock 77 $from "Until you've registered with the bot, you have no business setting XTRA values."
+ if {[set log [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]==""} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Until you've registered with the bot, you have no business setting XTRA values."
return
}
set subfield [lindex $msg 0 0]
set value [join [lrange [lindex $msg 0] 1 end] " "]
setuser $log "XTRA" $subfield $value
- $::maintype notice $::sock 77 $from "Set your user record XTRA $subfield to $value."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Set your user record XTRA $subfield to $value."
}
proc chandname2name {channame} {return $channame}
diff --git a/modules/0001-chanserv.tcl b/modules/0001-chanserv.tcl
@@ -0,0 +1,316 @@
+$::maintype sendUid $::sock($::cs(netname)) $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server"
+bind $::sock($::cs(netname)) msg 77 "register" regchan
+bind $::sock($::cs(netname)) msg 77 "adduser" adduserchan
+bind $::sock($::cs(netname)) msg 77 "users" lsuchan
+bind $::sock($::cs(netname)) msg 77 "lsu" lsuchan
+bind $::sock($::cs(netname)) msg 77 "convertop" convertop
+#bind $::sock($::cs(netname)) msg 77 "deluser" deluserchan
+bind $::sock($::cs(netname)) msg 77 "up" upchan
+bind $::sock($::cs(netname)) pub "-" "@up" upchanfant
+bind $::sock($::cs(netname)) pub "-" "@rand" randfant
+bind $::sock($::cs(netname)) pub "-" "@request" requestbot
+bind $::sock($::cs(netname)) msg 77 "down" downchan
+bind $::sock($::cs(netname)) msg 77 "hello" regnick
+bind $::sock($::cs(netname)) msg 77 "chpass" chpassnick
+bind $::sock($::cs(netname)) msg 77 "login" idnick
+bind $::sock($::cs(netname)) msg 77 "help" chanhelp
+bind $::sock($::cs(netname)) msg 77 "topic" chantopic
+bind $::sock($::cs(netname)) msg 77 "cookie" authin
+bind $::sock($::cs(netname)) msg 77 "cauth" cookieauthin
+bind $::sock($::cs(netname)) mode "-" "+" checkop
+bind $::sock($::cs(netname)) mode "-" "-" checkdeop
+bind $::sock($::cs(netname)) topic "-" "-" checktopic
+bind $::sock($::cs(netname)) create "-" "-" checkcreate
+
+proc checktopic {chan topic} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ if {[channel get $chan topiclock]} {$::maintype topic $::sock($::cs(netname)) 77 "$chan" "[nda get "regchan/$ndacname/topic"]"}
+}
+
+proc chantopic {from msg} {
+ set cname [lindex $msg 0 0]
+ set topic [join [lrange [lindex $msg 0] 1 end] " "]
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] lmno|lmno $cname]} {
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You must be at least halfop to change the stored channel topic."
+ return
+ }
+ nda set "regchan/$ndacname/topic" "$topic"
+ $::maintype topic $::sock($::cs(netname)) 77 "$cname" "$topic"
+ $::maintype privmsg $::sock($::cs(netname)) 77 "$cname" "[tnda get "nick/$::netname($::sock($::cs(netname)))/$from"] ([tnda get "login/$::netname($::sock($::cs(netname)))/$from"]) changed topic."
+}
+
+proc authin {from msg} {
+ set uname [lindex $msg 0 0]
+ if {[string first "/" $uname] != -1} {return}
+ $::maintype notice $::sock($::cs(netname)) 77 $from "CHALLENGE [set cookie [b64e [rand 1000000000 9999999999]]] SHA1"
+ tnda set "cookieauth/$from/cookie" $cookie
+ tnda set "cookieauth/$from/name" "$uname"
+}
+
+proc cookieauthin {from msg} {
+ set uname [lindex $msg 0 0]
+ set response [lindex $msg 0 1]
+ if {[string first "/" $uname] != -1} {return}
+ if {$response == ""} {return}
+ set checkresp "[tnda get "cookieauth/$from/name"]:[nda get "usernames/[string tolower $uname]/password"]:[tnda get "cookieauth/$from/cookie"]"
+ set isresp [pwhash "$checkresp"]
+ puts stdout "$response $isresp $checkresp"
+ if {$response == $isresp} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You have successfully logged in as $uname."
+ $::maintype setacct $::sock($::cs(netname)) $from $uname
+ callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname
+ } {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You used the wrong password; try again."
+ }
+}
+
+proc randfant {cname msg} {
+ set from [lindex $msg 0 0]
+ set froni [tnda get "nick/$::netname($::sock($::cs(netname)))/$from"]
+ if {![string is integer [lindex $msg 1 0]] ||![string is integer [lindex $msg 1 1]]} {return}
+ if {(""==[lindex $msg 1 0]) || (""==[lindex $msg 1 1])} {return}
+ if {[lindex $msg 1 0] == [lindex $msg 1 1]} {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\002$froni:\002 Your request would have caused a divide by zero and was not processed.";return}
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\002$froni:\002 Your die rolled [rand [lindex $msg 1 0] [lindex $msg 1 1]]"
+}
+
+proc lsuchan {from msg} {
+ set cname [lindex $msg 0 0]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {[string length [nda get "regchan/$ndacname"]] == 0} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Channel does not exist."
+ return
+ }
+ set xses [nda get "regchan/$ndacname/levels"]
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Access | Flags | Username"
+ $::maintype notice $::sock($::cs(netname)) 77 $from "-------+------------------"
+ foreach {nick lev} $xses {
+ if {$lev == 0} {continue}
+ # Case above? User not actually on access list
+ set nl [format "%3d" $lev]
+ set repeats [string repeat " " [expr {6-[string length [nda get "eggcompat/attrs/$ndacname/$nick"]]}]]
+ $::maintype notice $::sock($::cs(netname)) 77 $from " $nl | $repeats[string range [nda get "eggcompat/attrs/$ndacname/$nick"] 0 5] | $nick"
+ }
+ $::maintype notice $::sock($::cs(netname)) 77 $from "-------+------------------"
+ $::maintype notice $::sock($::cs(netname)) 77 $from " | End of access list"
+}
+
+proc upchanfant {cname msg} {
+ set from [lindex $msg 0 0]
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {(1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]) && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] aolvmn|olvmn $cname]} {
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You fail at life."
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "Channel not registered to you."
+ return
+ }
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]
+ set sm "+"
+ set st ""
+ if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |v $cname]} {set sm v}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |o $cname]} {set sm o}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]}
+ } {
+ if {$lev >= 1} {set sm "v"; append st "v"}
+ if {$lev >= 150} {set sm "h"; append st "l"}
+ if {$lev >= 200} {set sm "o"; append st "o"}
+ if {$lev >= 300} {append st "m"}
+ if {$lev >= 500} {append st "n"}
+ chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +$st $cname
+ }
+ $::maintype putmode $::sock($::cs(netname)) 77 $cname +$sm $from [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"]
+}
+
+proc convertop {from msg} {
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set cname [lindex $msg 0 0]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {500>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You must be the founder to request an oplevel-to-flags conversion."
+ return
+ }
+ foreach {login lev} [nda get "regchan/$ndacname/levels"] {
+ set st ""
+ if {$lev >= 1} {append st "v"}
+ if {$lev >= 150} {append st "l"}
+ if {$lev >= 200} {append st "o"}
+ if {$lev >= 300} {append st "m"}
+ if {$lev >= 500} {append st "n"}
+ chattr $login +$st $cname
+ }
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Converted all access levels to flags."
+ lsuchan $from $msg
+}
+
+proc requestbot {cname msg} {
+ set from [lindex $msg 0 0]
+ set bot [lindex $msg 1 0]
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] lmno|lmno $cname]} {
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You fail at life."
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You must be at least halfop to request $bot."
+ return
+ }
+ callbind $::sock($::cs(netname)) request [string tolower $bot] "-" $cname
+}
+
+foreach {chan _} [nda get "regchan"] {
+ $::maintype putjoin $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] "+o" $::cs(nick) [nda get "regchan/$chan/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] "+nt" "" [nda get "regchan/$chan/ts"]
+ if {[channel get [::base64::decode [string map {[ /} $chan]] topiclock]} {$::maintype topic $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/topic"]}
+}
+
+proc checkop {mc ftp} {
+ set f [lindex $ftp 0 0]
+ set t [lindex $ftp 0 1]
+ set p [lindex $ftp 0 2]
+ if {"o"!=$mc} {return}
+ set chan [string map {/ [} [::base64::encode [string tolower $t]]]
+ tnda set "channels/$chan/modes/$p" "[tnda get "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$p"]o"
+}
+
+proc checkcreate {mc ftp} {
+ set chan [string map {/ [} [::base64::encode [string tolower $mc]]]
+ tnda set "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$ftp" "o"
+ puts stdout "channels/$chan/modes/$ftp"
+}
+
+proc checkdeop {mc ftp} {
+ set f [lindex $ftp 0 0]
+ set t [lindex $ftp 0 1]
+ set p [lindex $ftp 0 2]
+ if {"o"!=$mc} {return}
+ set chan [string map {/ [} [::base64::encode [string tolower $t]]]
+ tnda set "channels/$chan/modes/$p" [string map {o ""} [tnda get "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$p"]]
+}
+
+proc chanhelp {from msg} {
+ set fp [open ./chanserv.help r]
+ set data [split [read $fp] "\r\n"]
+ close $fp
+ foreach {line} $data {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "$line"
+ }
+}
+
+proc regchan {from msg} {
+ putcmdlog "$from $msg regchan"
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set cname [lindex $msg 0 0]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {[string length [nda get "regchan/$ndacname"]] != 0} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Channel already exists."
+ return
+ }
+ if {-1==[string first "o" [ts6 getpfx $::netname($::sock($::cs(netname))) $cname [ts6 uid2nick $::cs(netname) $from]]]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You are not an operator. [ts6 getpfx $::netname($::sock($::cs(netname))) $cname [ts6 uid2nick $::cs(netname) $from]]"
+ return
+ }
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Guess what? :)"
+ nda set "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]" 500
+ nda set "regchan/$ndacname/ts" [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 77 $cname [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"]
+ chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +mno $cname
+ callbind $::sock($::cs(netname)) "reg" "-" "-" $cname [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"]
+}
+
+proc adduserchan {from msg} {
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set cname [lindex $msg 0 0]
+ set adduser [lindex $msg 0 1]
+ set addlevel [lindex $msg 0 2]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {![string is integer $addlevel]} {return}
+ if {$addlevel > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't do that; you're not the channel's Dave";return}
+ if {[nda get "regchan/$ndacname/levels/$adduser"] > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't do that; the person you're changing the level of is more like Dave than you.";return}
+ if {$adduser == [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't change your own level, even if you're downgrading. Sorreh :/$::netname($::sock($::cs(netname)))/";return}
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Guess what? :) User added."
+ nda set "regchan/$ndacname/levels/[string tolower $adduser]" $addlevel
+}
+
+proc upchan {from msg} {
+ puts stdout [nda get regchan]
+ if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return}
+ set cname [lindex $msg 0 0]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] aolvmn|olvmn $cname]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Channel not registered to you."
+ return
+ }
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]
+ set sm "+"
+ set st ""
+ if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |v $cname]} {set sm v}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |o $cname]} {set sm o}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]}
+ if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]}
+ } {
+ if {$lev >= 1} {set sm "v"; append st "v"}
+ if {$lev >= 150} {set sm "h"; append st "l"}
+ if {$lev >= 200} {set sm "o"; append st "o"}
+ if {$lev >= 300} {append st "m"}
+ if {$lev >= 500} {append st "n"}
+ chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +$st $cname
+ }
+ $::maintype putmode $::sock($::cs(netname)) 77 $cname +$sm $from [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"]
+}
+
+proc regnick {from msg} {
+ set uname [lindex $msg 0 0]
+ if {[string first "/" $uname] != -1} {return}
+ set pw [lindex $msg 0 1]
+ if {""!=[nda get "usernames/[string tolower $uname]"]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Account already exists; try LOGIN"
+ return
+ }
+ nda set "usernames/[string tolower $uname]/password" [pwhash $pw]
+ $::maintype setacct $::sock($::cs(netname)) $from $uname
+ callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname
+}
+
+proc chpassnick {from msg} {
+ set uname [lindex $msg 0 0]
+ if {[string first "/" $uname] != -1} {return}
+ set pw [lindex $msg 0 1]
+ set newpw [lindex $msg 0 2]
+ set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"]
+ set ispw [pwhash $pw]
+
+ if {$ispw != [nda get "usernames/[string tolower $uname]/password"]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life."
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Wrong pass."
+ return
+ }
+ nda set "usernames/[string tolower $uname]/password" [pwhash $newpw]
+ $::maintype notice $::sock($::cs(netname)) 77 $from "Password changed."
+}
+
+proc idnick {from msg} {
+ set uname [lindex $msg 0 0]
+ if {[string first "/" $uname] != -1} {return}
+ set pw [lindex $msg 0 1]
+ set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"]
+ set ispw [pwhash $pw]
+ if {$ispw == [nda get "usernames/[string tolower $uname]/password"]} {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You have successfully logged in as $uname."
+ $::maintype setacct $::sock($::cs(netname)) $from $uname
+ callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname
+ } {
+ $::maintype notice $::sock($::cs(netname)) 77 $from "You cannot log in as $uname. You have the wrong password."
+ }
+}
diff --git a/modules/0002-chanserv-thcserv.tcl b/modules/0002-chanserv-thcserv.tcl
@@ -1,19 +1,19 @@
-bind $::sock pub "-" "!lag" publag
-bind $::sock pub "-" "!weed" pubweed
-bind $::sock pub "-" "!coffee" pubcoffee
-bind $::sock notc 77 "ping" lagresp
+bind $::sock($::cs(netname)) pub "-" "!lag" publag
+bind $::sock($::cs(netname)) pub "-" "!weed" pubweed
+bind $::sock($::cs(netname)) pub "-" "!coffee" pubcoffee
+bind $::sock($::cs(netname)) notc 77 "ping" lagresp
proc publag {cname msg} {
set from [lindex $msg 0 0]
- $::maintype privmsg $::sock 77 $from "\001PING [clock clicks -milliseconds] $cname \001"
+ $::maintype privmsg $::sock($::cs(netname)) 77 $from "\001PING [clock clicks -milliseconds] $cname \001"
}
proc pubcoffee {cname msg} {
switch [expr {int(rand()*4)}] {
- 0 {$::maintype privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of espresso\001"}
- 1 {$::maintype privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of Latte\001"}
- 2 {$::maintype privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of instant coffee\001"}
- 3 {$::maintype privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of cappucino\001"}
+ 0 {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of espresso\001"}
+ 1 {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of Latte\001"}
+ 2 {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of instant coffee\001"}
+ 3 {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of cappucino\001"}
}
}
@@ -21,16 +21,16 @@ proc pubweed {cname msg} {
set payload [lindex $msg 1 0]
switch [expr {int(rand()*4)}] {
0 {
- $::maintype privmsg $::sock 77 $cname "\001ACTION packs a bowl of nugs and hands a bong to $payload\001"
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION packs a bowl of nugs and hands a bong to $payload\001"
}
1 {
- $::maintype privmsg $::sock 77 $cname "\001ACTION rolls a joint and hands to $payload\001"
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION rolls a joint and hands to $payload\001"
}
2 {
- $::maintype privmsg $::sock 77 $cname "\001ACTION fills the hookah with dried nugs and hands to $payload\001"
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION fills the hookah with dried nugs and hands to $payload\001"
}
3 {
- $::maintype privmsg $::sock 77 $cname "\001ACTION passes $payload the vape pen\001"
+ $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\001ACTION passes $payload the vape pen\001"
}
}
}
@@ -38,6 +38,6 @@ proc pubweed {cname msg} {
proc lagresp {from msg} {
set ms [lindex $msg 0 0]
set chan [lindex $msg 0 1]
- set ni [tnda get "nick/$::netname($::sock)/$from"]
- $::maintype privmsg $::sock 77 $chan "$ni, your lag is [expr {[clock clicks -milliseconds] - $ms}] milliseconds according to your client and our measurements."
+ set ni [tnda get "nick/$::netname($::sock($::cs(netname)))/$from"]
+ $::maintype privmsg $::sock($::cs(netname)) 77 $chan "$ni, your lag is [expr {[clock clicks -milliseconds] - $ms}] milliseconds according to your client and our measurements."
}
diff --git a/modules/0003-weather.tcl b/modules/0003-weather.tcl
@@ -1,15 +1,15 @@
-$::maintype sendUid $::sock "W" "weather" "services." "services." 57 "Weather Services"
+$::maintype sendUid $::sock($::cs(netname)) "W" "weather" "services." "services." 57 "Weather Services"
foreach {chan is} [nda get "weather/regchan"] {
if {1!=$is} {continue}
- $::maintype putjoin $::sock 57 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 57 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"]
}
-bind $::sock request "w" "-" weatherjoin
-bind $::sock request "weather" "-" weatherjoin
+bind $::sock($::cs(netname)) request "w" "-" weatherjoin
+bind $::sock($::cs(netname)) request "weather" "-" weatherjoin
proc weatherjoin {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- $::maintype putjoin $::sock 57 $chan [nda get "regchan/$ndacname/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 57 $chan [nda get "regchan/$ndacname/ts"]
nda set "weather/regchan/$ndacname" 1
}
@@ -44,14 +44,14 @@ namespace eval wunderground {
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
- bind $::sock pub "-" [string trimleft $wunderground::cmdchar]weather wunderground::tclservwe
- bind $::sock pub "-" [string trimleft $wunderground::cmdchar]wz wunderground::tclservwe
- bind $::sock pub "-" [string trimleft $wunderground::cmdchar]forecast wunderground::tclservfc
+ bind $::sock($::cs(netname)) pub "-" [string trimleft $wunderground::cmdchar]weather wunderground::tclservwe
+ bind $::sock($::cs(netname)) pub "-" [string trimleft $wunderground::cmdchar]wz wunderground::tclservwe
+ bind $::sock($::cs(netname)) pub "-" [string trimleft $wunderground::cmdchar]forecast wunderground::tclservfc
}
proc wunderground::tclservwe {cname msg} {
- set nick [tnda get "nick/$::netname($::sock)/[lindex $msg 0 0]"]
- set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/$::netname($::sock)/[lindex $msg 0 0]"]"
+ set nick [tnda get "nick/$::netname($::sock($::cs(netname)))/[lindex $msg 0 0]"]
+ set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/$::netname($::sock($::cs(netname)))/[lindex $msg 0 0]"]"
set comd "weather"
set hand ""
set text [join [lindex $msg 1] " "]
@@ -59,8 +59,8 @@ proc wunderground::tclservwe {cname msg} {
}
proc wunderground::tclservfc {cname msg} {
- set nick [tnda get "nick/$::netname($::sock)/[lindex $msg 0 0]"]
- set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/$::netname($::sock)/[lindex $msg 0 0]"]"
+ set nick [tnda get "nick/$::netname($::sock($::cs(netname)))/[lindex $msg 0 0]"]
+ set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/$::netname($::sock($::cs(netname)))/[lindex $msg 0 0]"]"
set comd "forecast"
set hand ""
set text [join [lindex $msg 1] " "]
@@ -190,7 +190,7 @@ proc wunderground::msg {chan logo textf text} {
set counter 0
while {$counter <= [llength $text]} {
if {[lindex $text $counter] != ""} {
- $::maintype privmsg $::sock 57 $chan "${logo} ${textf}[string map {\\\" \"} [lindex $text $counter]]"
+ $::maintype privmsg $::sock($::cs(netname)) 57 $chan "${logo} ${textf}[string map {\\\" \"} [lindex $text $counter]]"
}
incr counter
}
diff --git a/modules/0004-limitserv.tcl b/modules/0004-limitserv.tcl
@@ -1,41 +1,41 @@
-$::maintype sendUid $::sock "L" "limitserv" "services." "services." 47 "Channel Limit Adjustment Services"
+$::maintype sendUid $::sock($::cs(netname)) "L" "limitserv" "services." "services." 47 "Channel Limit Adjustment Services"
foreach {chan is} [nda get "limitserv/regchan"] {
if {1!=$is} {continue}
- $::maintype putjoin $::sock 47 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 47 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"]
}
-bind $::sock request "l" "-" limitservjoin
-bind $::sock request "limitserv" "-" limitservjoin
-bind $::sock join "-" "-" limitservup
-bind $::sock part "-" "-" limitservdown
-bind $::sock pub "-" "!dolimit" limitservdochan
+bind $::sock($::cs(netname)) request "l" "-" limitservjoin
+bind $::sock($::cs(netname)) request "limitserv" "-" limitservjoin
+bind $::sock($::cs(netname)) join "-" "-" limitservup
+bind $::sock($::cs(netname)) part "-" "-" limitservdown
+bind $::sock($::cs(netname)) pub "-" "!dolimit" limitservdochan
after 300000 {limitservdo}
proc limitservup {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- if {""==[tnda get "limitserv/$::netname($::sock)/$ndacname"]} {set i 1} {set i [expr {[tnda get "limitserv/$::netname($::sock)/$ndacname"] + 1}]}
- tnda set "limitserv/$::netname($::sock)/$ndacname" $i
+ if {""==[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$ndacname"]} {set i 1} {set i [expr {[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$ndacname"] + 1}]}
+ tnda set "limitserv/$::netname($::sock($::cs(netname)))/$ndacname" $i
# intlimitservdochan $chan
}
proc limitservdown {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- if {""==[tnda get "limitserv/$::netname($::sock)/$ndacname"]} {set i 0} {set i [expr {[tnda get "limitserv/$::netname($::sock)/$ndacname"] - 1}]}
- tnda set "limitserv/$::netname($::sock)/$ndacname" $i
+ if {""==[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$ndacname"]} {set i 0} {set i [expr {[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$ndacname"] - 1}]}
+ tnda set "limitserv/$::netname($::sock($::cs(netname)))/$ndacname" $i
# intlimitservdochan $chan
}
proc limitservjoin {chan ft} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- $::maintype putjoin $::sock 47 $chan [nda get "regchan/$ndacname/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 47 $chan [nda get "regchan/$ndacname/ts"]
nda set "limitserv/regchan/$ndacname" 1
}
proc limitservdo {} {
foreach {chan is} [nda get "limitserv/regchan"] {
if {1!=$is} {continue}
- $::maintype putmode $::sock 47 [::base64::decode [string map {[ /} $chan]] "+l" [expr {[tnda get "limitserv/$::netname($::sock)/$chan"] + 10}] [nda get "regchan/$chan/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 47 [::base64::decode [string map {[ /} $chan]] "+l" [expr {[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$chan"] + 10}] [nda get "regchan/$chan/ts"]
}
after 300000 {limitservdo}
}
@@ -43,14 +43,14 @@ proc limitservdo {} {
proc limitservdochan {cname msg} {
set chan [string map {/ [} [::base64::encode [string tolower $cname]]]
set from [lindex $msg 0 0]
- if {150>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]} {
- $::maintype privmsg $::sock 47 $cname "You must be at least halfop to manually trigger autolimit on the channel."
+ if {150>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} {
+ $::maintype privmsg $::sock($::cs(netname)) 47 $cname "You must be at least halfop to manually trigger autolimit on the channel."
return
}
- $::maintype putmode $::sock 47 $cname "+l" [expr {[tnda get "limitserv/$::netname($::sock)/$chan"] + 14}] [nda get "regchan/$chan/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 47 $cname "+l" [expr {[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$chan"] + 14}] [nda get "regchan/$chan/ts"]
}
proc intlimitservdochan {cname} {
set chan [string map {/ [} [::base64::encode [string tolower $cname]]]
- $::maintype putmode $::sock 47 $cname "+l" [expr {[tnda get "limitserv/$::netname($::sock)/$chan"] + 14}] [nda get "regchan/$chan/ts"]
+ $::maintype putmode $::sock($::cs(netname)) 47 $cname "+l" [expr {[tnda get "limitserv/$::netname($::sock($::cs(netname)))/$chan"] + 14}] [nda get "regchan/$chan/ts"]
}
diff --git a/modules/0007-quote.tcl b/modules/0007-quote.tcl
@@ -1,17 +1,17 @@
-$::maintype sendUid $::sock "Q" "quoteserv" "services." "services." 107 "Quote Storage Services"
+$::maintype sendUid $::sock($::cs(netname)) "Q" "quoteserv" "services." "services." 107 "Quote Storage Services"
foreach {chan is} [nda get "quoteserv/regchan"] {
if {1!=$is} {continue}
- $::maintype putjoin $::sock 107 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 107 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"]
}
-bind $::sock request "q" "-" quoteservjoin
-bind $::sock request "quoteserv" "-" quoteservjoin
-bind $::sock pub "-" "!quote" quoteservdo
-bind $::sock pub "-" "!q" quoteservdo
+bind $::sock($::cs(netname)) request "q" "-" quoteservjoin
+bind $::sock($::cs(netname)) request "quoteserv" "-" quoteservjoin
+bind $::sock($::cs(netname)) pub "-" "!quote" quoteservdo
+bind $::sock($::cs(netname)) pub "-" "!q" quoteservdo
proc quoteservjoin {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- $::maintype putjoin $::sock 107 $chan [nda get "regchan/$ndacname/ts"]
+ $::maintype putjoin $::sock($::cs(netname)) 107 $chan [nda get "regchan/$ndacname/ts"]
nda set "quoteserv/regchan/$ndacname" 1
}
@@ -31,37 +31,37 @@ proc quoteservdo {chan msg} {
"sea*" {
set ptn "*[join $para " "]*"
set qts [quotesearch $chan $ptn]
- if {[llength $qts]} {$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Found quotes numbered #[join $qts ",#"]"} {
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
+ if {[llength $qts]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Found quotes numbered #[join $qts ",#"]"} {
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
}
}
"vi*1st*ma*" {
set ptn "*[join $para " "]*"
set qts [quotesearch $chan $ptn]
- if {[llength $qts]} {set qtn [lindex $qts 0];$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:";$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] [nda get "quoteserv/quotes/$ndacname/$qtn"]"} {
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
+ if {[llength $qts]} {set qtn [lindex $qts 0];$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Quote number #$qtn:";$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] [nda get "quoteserv/quotes/$ndacname/$qtn"]"} {
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
}
}
"ad*" {
set qt [join $para " "]
set qtn [expr {([llength [nda get "quoteserv/quotes/$ndacname"]]/2)+3}]
nda set "quoteserv/quotes/$ndacname/$qtn" $qt
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Added quote number #$qtn to database."
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Added quote number #$qtn to database."
}
"de*" {
set qtn "[lindex $para 0]"
- if {![string is integer $qtn]} {$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
- if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]} {$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Check your privilege."}
+ if {![string is integer $qtn]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
+ if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Check your privilege."}
nda set "quoteserv/quotes/$ndacname/$qtn" ""
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database."
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database."
}
"vi*" {
set qtn "[lindex $para 0]"
- if {![string is integer $qtn]} {$::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
+ if {![string is integer $qtn]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
set qt [nda get "quoteserv/quotes/$ndacname/$qtn"]
if {$qt != ""} {
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:"
- $::maintype privmsg $::sock 107 $chan "\[\002Quotes\002\] $qt"
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Quote number #$qtn:"
+ $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] $qt"
}
}
"he*" {
@@ -73,7 +73,7 @@ proc quoteservdo {chan msg} {
!quote del - Delete quote. Requires halfops or above.
End of help for Q.}
foreach {helpline} [split $helpfile "\r\n"] {
- $::maintype notice $::sock 107 $from $helpline
+ $::maintype notice $::sock($::cs(netname)) 107 $from $helpline
}
}
}
diff --git a/modules/0008-relayserv.tcl b/modules/0008-relayserv.tcl
@@ -1,11 +1,11 @@
# This is the fun part.
-$::maintype sendUid $::sock "R" "relay" "services." "services." 117 "Relay Services"
-bind $::sock msg 117 "reqlink" reqlinkmsg
+$::maintype sendUid $::sock($::cs(netname)) "R" "relay" "services." "services." 117 "Relay Services"
+bind $::sock($::cs(netname)) msg 117 "reqlink" reqlinkmsg
proc allocuuid {relay} {
# Allocate a UID and increment.
- if {""==[tnda get "uids/relays/$relay"]} {tnda set "uids/relays/$relay" 1} {tnda set "uids/relays/$relay" [expr {[tnda get "uids/relays/$::netname($::sock)/$relay"]+1}]}
+ if {""==[tnda get "uids/relays/$relay"]} {tnda set "uids/relays/$relay" 1} {tnda set "uids/relays/$relay" [expr {[tnda get "uids/relays/$::netname($::sock($::cs(netname)))/$relay"]+1}]}
return [tnda get "uids/relays/$relay"]
}
diff --git a/modules/0009-gateway.tcl b/modules/0009-gateway.tcl
@@ -1,71 +0,0 @@
-$::maintype sendUid $sock syn syn channels. channels. 1444 "Tin"
-bind $::sock msg 1444 "addgwcloak" addgwcloak
-bind $::sock msg 1444 "addaccloak" addaccloak
-bind $::sock conn - - dogwcloak
-bind $::sock motd - - dogwcloak
-bind $::sock msg 1444 "motd" dogwcloak
-
-proc addgwcloak {from msg} {
- set uname [tnda get "login/$::netname($::sock)/$from"]
- if {$::synpass != [lindex $msg 0 2]} {
- $::maintype notice $::sock 1444 $from "SYNTAX: /msg syn addgwcloak match cloak syn-password"
- $::maintype notice $::sock 1444 $from "FORMATCHAR: %i = realhost"
- return
- }
- if {""==[lindex $msg 0 0]} {
- $::maintype notice $::sock 1444 $from "SYNTAX: /msg syn addgwcloak match cloak"
- $::maintype notice $::sock 1444 $from "FORMATCHAR: %i = realhost"
- return
-
- }
- if {""==[lindex $msg 0 1]} {
- $::maintype notice $::sock 1444 $from "SYNTAX: /msg syn addgwcloak match cloak"
- $::maintype notice $::sock 1444 $from "FORMATCHAR: %i = realhost"
- return
-
- }
- nda set "gwcloaks/[lindex $msg 0 0]" [lindex $msg 0 1]
-}
-
-proc dogwcloak {unick n} {
- doinsecurehost $unick
- set fp [open ./services.motd r]
- set fl [read $fp]
-# set fl ""
- close $fp
- foreach {l} [split $fl "\r\n"] {
- $::maintype putmotd $::sock $unick "$l"
- }
- $::maintype putmotdend $::sock $unick
- set match [tnda get "rhost/$::netname($::sock)/$unick"]
- foreach {mask cloak} [nda get "gwcloaks"] {
- if {[string match -nocase $mask "[tnda get "nick/$::netname($::sock)/$unick"]![tnda get "ident/$::netname($::sock)/$unick"]@[tnda get "rhost/$::netname($::sock)/$unick"]"]} {set match $cloak}
- }
- set cloake [string map [list "::" "-" ":" "."] [string map [list "%i" [tnda get "rhost/$::netname($::sock)/$unick"]] $match]]
- $::maintype notice $::sock 1444 $unick "$cloake should be your vHost."
- $::maintype sethost $::sock 1444 $unick "$cloake"
- $::maintype putwallop $::sock "CONNECT: [tnda get "nick/$::netname($::sock)/$unick"]![tnda get "ident/$::netname($::sock)/$unick"]@[tnda get "rhost/$::netname($::sock)/$unick"] ($cloake)"
-}
-
-proc doinsecurehost {unick} {
- package require ip
- set rhostname [tnda get "rhost/$::netname($::sock)/$unick"]
- if {![string match "*:*" $rhostname] && [catch {::ip::toInteger $rhostname}]} {
- if {![catch "exec php ./dnslib.php [string trim $rhostname] A . 0 $unick" reho]} {set rhostname [lindex [split [string trim $reho] " "] 1]} elseif {![catch "exec php ./dnslib.php [string trim $rhostname] AAAA . 0 $unick" reho]} {set rhostname [lindex [split [string trim $reho] " "] 1]} {puts stdout "gave up $rhostname $unick";return}
- # If we returned then we gave up.
- }
- if {[string match "*:*" $rhostname]} {return;}
- foreach {dnsbl} $::dnsbls {
- set fp [open |[list php ./dnslib.php [string trim $rhostname] A $dnsbl 1 $unick] r]
- set reho [read $fp]
- catch "close $fp"
- set reho [string trim $reho]
- if {[lindex [split $reho " "] 0] == $unick} {set result [lindex [split $reho " "] 1]} {puts stdout "gave up $rhostname $unick results /$reho/";return}
- # If we returned then we gave up.
- if {$result!="" && $result != 0 && $result != 1} {$::maintype kill $::sock 1444 $unick "(DNSBL::$::dname($dnsbl) match - if this is in error contact j4jackj)"}
- }
-}
-
-set dname(dnsbl.dronebl.org) DroneBL
-set dname(6667.141.117.162.69.ip-port.exitlist.torproject.org) Tor
-set dnsbls [list dnsbl.dronebl.org 6667.141.117.162.69.ip-port.exitlist.torproject.org]
diff --git a/modules/bmotion.disabled b/modules/bmotion.disabled
@@ -1,4 +1,4 @@
-#p10 sendUid $::sock "g" "bmotion" "services." "services." 27 "A test of ported BMotion to TCLServ"
+#p10 sendUid $::sock($::cs(netname)) "g" "bmotion" "services." "services." 27 "A test of ported BMotion to TCLServ"
set bmnumeric 77
mysrc ./scripts/bmotion/bMotion.tcl
puts stdout "loaded bmotion... i think"
diff --git a/modules/disabled.chanserv b/modules/disabled.chanserv
@@ -1,314 +0,0 @@
-$::maintype sendUid $sock $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server"
-bind $::sock msg 77 "register" regchan
-bind $::sock msg 77 "adduser" adduserchan
-bind $::sock msg 77 "users" lsuchan
-bind $::sock msg 77 "lsu" lsuchan
-bind $::sock msg 77 "convertop" convertop
-#bind $::sock msg 77 "deluser" deluserchan
-bind $::sock msg 77 "up" upchan
-bind $::sock pub "-" "@up" upchanfant
-bind $::sock pub "-" "@rand" randfant
-bind $::sock pub "-" "@request" requestbot
-bind $::sock msg 77 "down" downchan
-bind $::sock msg 77 "hello" regnick
-bind $::sock msg 77 "chpass" chpassnick
-bind $::sock msg 77 "login" idnick
-bind $::sock msg 77 "help" chanhelp
-bind $::sock msg 77 "topic" chantopic
-bind $::sock msg 77 "cookie" authin
-bind $::sock msg 77 "cauth" cookieauthin
-bind $::sock mode "-" "+" checkop
-bind $::sock mode "-" "-" checkdeop
-bind $::sock topic "-" "-" checktopic
-bind $::sock create "-" "-" checkcreate
-
-proc checktopic {chan topic} {
- set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- if {[channel get $chan topiclock]} {$::maintype topic $::sock 77 "$chan" "[nda get "regchan/$ndacname/topic"]"}
-}
-
-proc chantopic {from msg} {
- set cname [lindex $msg 0 0]
- set topic [join [lrange [lindex $msg 0] 1 end] " "]
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock)/$from"] lmno|lmno $cname]} {
- $::maintype privmsg $::sock 77 $cname "You must be at least halfop to change the stored channel topic."
- return
- }
- nda set "regchan/$ndacname/topic" "$topic"
- $::maintype topic $::sock 77 "$cname" "$topic"
- $::maintype privmsg $::sock 77 "$cname" "[tnda get "nick/$::netname($::sock)/$from"] ([tnda get "login/$::netname($::sock)/$from"]) changed topic."
-}
-
-proc authin {from msg} {
- set uname [lindex $msg 0 0]
- if {[string first "/" $uname] != -1} {return}
- $::maintype notice $::sock 77 $from "CHALLENGE [set cookie [b64e [rand 1000000000 9999999999]]] SHA1"
- tnda set "cookieauth/$from/cookie" $cookie
- tnda set "cookieauth/$from/name" "$uname"
-}
-
-proc cookieauthin {from msg} {
- set uname [lindex $msg 0 0]
- set response [lindex $msg 0 1]
- if {[string first "/" $uname] != -1} {return}
- if {$response == ""} {return}
- set checkresp "[tnda get "cookieauth/$from/name"]:[nda get "usernames/[string tolower $uname]/password"]:[tnda get "cookieauth/$from/cookie"]"
- set isresp [pwhash "$checkresp"]
- puts stdout "$response $isresp $checkresp"
- if {$response == $isresp} {
- $::maintype notice $::sock 77 $from "You have successfully logged in as $uname."
- $::maintype setacct $::sock $from $uname
- callbind $::sock evnt "-" "login" $from $uname
- } {
- $::maintype notice $::sock 77 $from "You used the wrong password; try again."
- }
-}
-
-proc randfant {cname msg} {
- set from [lindex $msg 0 0]
- set froni [tnda get "nick/$::netname($::sock)/$from"]
- if {![string is integer [lindex $msg 1 0]] ||![string is integer [lindex $msg 1 1]]} {return}
- if {(""==[lindex $msg 1 0]) || (""==[lindex $msg 1 1])} {return}
- if {[lindex $msg 1 0] == [lindex $msg 1 1]} {$::maintype privmsg $::sock 77 $cname "\002$froni:\002 Your request would have caused a divide by zero and was not processed.";return}
- $::maintype privmsg $::sock 77 $cname "\002$froni:\002 Your die rolled [rand [lindex $msg 1 0] [lindex $msg 1 1]]"
-}
-
-proc lsuchan {from msg} {
- set cname [lindex $msg 0 0]
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {[string length [nda get "regchan/$ndacname"]] == 0} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "Channel does not exist."
- return
- }
- set xses [nda get "regchan/$ndacname/levels"]
- $::maintype notice $::sock 77 $from "Access | Flags | Username"
- $::maintype notice $::sock 77 $from "-------+------------------"
- foreach {nick lev} $xses {
- if {$lev == 0} {continue}
- # Case above? User not actually on access list
- set nl [format "%3d" $lev]
- set repeats [string repeat " " [expr {6-[string length [nda get "eggcompat/attrs/$ndacname/$nick"]]}]]
- $::maintype notice $::sock 77 $from " $nl | $repeats[string range [nda get "eggcompat/attrs/$ndacname/$nick"] 0 5] | $nick"
- }
- $::maintype notice $::sock 77 $from "-------+------------------"
- $::maintype notice $::sock 77 $from " | End of access list"
-}
-
-proc upchanfant {cname msg} {
- set from [lindex $msg 0 0]
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {(1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]) && ![matchattr [tnda get "login/$::netname($::sock)/$from"] aolvmn|olvmn $cname]} {
- $::maintype privmsg $::sock 77 $cname "You fail at life."
- $::maintype privmsg $::sock 77 $cname "Channel not registered to you."
- return
- }
- set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]
- set sm "+"
- set st ""
- if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock)/$from"]"]} {
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |v $cname]} {set sm v}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |o $cname]} {set sm o}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]}
- } {
- if {$lev >= 1} {set sm "v"; append st "v"}
- if {$lev >= 150} {set sm "h"; append st "l"}
- if {$lev >= 200} {set sm "o"; append st "o"}
- if {$lev >= 300} {append st "m"}
- if {$lev >= 500} {append st "n"}
- chattr [tnda get "login/$::netname($::sock)/$from"] +$st $cname
- }
- $::maintype putmode $::sock 77 $cname +$sm $from [tnda get "channels/$::netname($::sock)/$ndacname/ts"]
-}
-
-proc convertop {from msg} {
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set cname [lindex $msg 0 0]
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {500>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "You must be the founder to request an oplevel-to-flags conversion."
- return
- }
- foreach {login lev} [nda get "regchan/$ndacname/levels"] {
- set st ""
- if {$lev >= 1} {append st "v"}
- if {$lev >= 150} {append st "l"}
- if {$lev >= 200} {append st "o"}
- if {$lev >= 300} {append st "m"}
- if {$lev >= 500} {append st "n"}
- chattr $login +$st $cname
- }
- $::maintype notice $::sock 77 $from "Converted all access levels to flags."
- lsuchan $from $msg
-}
-
-proc requestbot {cname msg} {
- set from [lindex $msg 0 0]
- set bot [lindex $msg 1 0]
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock)/$from"] lmno|lmno $cname]} {
- $::maintype privmsg $::sock 77 $cname "You fail at life."
- $::maintype privmsg $::sock 77 $cname "You must be at least halfop to request $bot."
- return
- }
- callbind $::sock request [string tolower $bot] "-" $cname
-}
-
-foreach {chan _} [nda get "regchan"] {
- $::maintype putjoin $::sock 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
- $::maintype putmode $::sock 77 [::base64::decode [string map {[ /} $chan]] "+nt" "" [nda get "regchan/$chan/ts"]
- if {[channel get [::base64::decode [string map {[ /} $chan]] topiclock]} {$::maintype topic $::sock 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/topic"]}
-}
-
-proc checkop {mc ftp} {
- set f [lindex $ftp 0 0]
- set t [lindex $ftp 0 1]
- set p [lindex $ftp 0 2]
- if {"o"!=$mc} {return}
- set chan [string map {/ [} [::base64::encode [string tolower $t]]]
- tnda set "channels/$chan/modes/$p" "[tnda get "channels/$chan/modes/$::netname($::sock)/$::netname($::sock)/$p"]o"
-}
-
-proc checkcreate {mc ftp} {
- set chan [string map {/ [} [::base64::encode [string tolower $mc]]]
- tnda set "channels/$chan/modes/$::netname($::sock)/$ftp" "o"
- puts stdout "channels/$chan/modes/$ftp"
-}
-
-proc checkdeop {mc ftp} {
- set f [lindex $ftp 0 0]
- set t [lindex $ftp 0 1]
- set p [lindex $ftp 0 2]
- if {"o"!=$mc} {return}
- set chan [string map {/ [} [::base64::encode [string tolower $t]]]
- tnda set "channels/$chan/modes/$p" [string map {o ""} [tnda get "channels/$chan/modes/$::netname($::sock)/$::netname($::sock)/$p"]]
-}
-
-proc chanhelp {from msg} {
- set fp [open ./chanserv.help r]
- set data [split [read $fp] "\r\n"]
- close $fp
- foreach {line} $data {
- $::maintype notice $::sock 77 $from "$line"
- }
-}
-
-proc regchan {from msg} {
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set cname [lindex $msg 0 0]
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {[string length [nda get "regchan/$ndacname"]] != 0} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "Channel already exists."
- return
- }
- if {-1==[string first "o" [tnda get "channels/$::netname($::sock)/$ndacname/modes/$from"]]} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "You are not an operator."
- return
- }
- $::maintype notice $::sock 77 $from "Guess what? :)"
- nda set "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock)/$from"]" 500
- nda set "regchan/$ndacname/ts" [tnda get "channels/$::netname($::sock)/$ndacname/ts"]
- $::maintype putjoin $::sock 77 $cname [tnda get "channels/$::netname($::sock)/$ndacname/ts"]
- chattr [tnda get "login/$::netname($::sock)/$from"] +mno $cname
- callbind $::sock "reg" "-" "-" $cname [tnda get "channels/$::netname($::sock)/$ndacname/ts"]
-}
-
-proc adduserchan {from msg} {
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set cname [lindex $msg 0 0]
- set adduser [lindex $msg 0 1]
- set addlevel [lindex $msg 0 2]
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {![string is integer $addlevel]} {return}
- if {$addlevel > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock)/$from"]"]} {$::maintype notice $::sock 77 $from "You can't do that; you're not the channel's Dave";return}
- if {[nda get "regchan/$ndacname/levels/$adduser"] > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock)/$from"]"]} {$::maintype notice $::sock 77 $from "You can't do that; the person you're changing the level of is more like Dave than you.";return}
- if {$adduser == [tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You can't change your own level, even if you're downgrading. Sorreh :/$::netname($::sock)/";return}
- $::maintype notice $::sock 77 $from "Guess what? :) User added."
- nda set "regchan/$ndacname/levels/[string tolower $adduser]" $addlevel
-}
-
-proc upchan {from msg} {
- puts stdout [nda get regchan]
- if {""==[tnda get "login/$::netname($::sock)/$from"]} {$::maintype notice $::sock 77 $from "You fail at life.";return}
- set cname [lindex $msg 0 0]
- set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock)/$from"] aolvmn|olvmn $cname]} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "Channel not registered to you."
- return
- }
- set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]
- set sm "+"
- set st ""
- if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock)/$from"]"]} {
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |v $cname]} {set sm v}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |o $cname]} {set sm o}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]}
- if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]}
- } {
- if {$lev >= 1} {set sm "v"; append st "v"}
- if {$lev >= 150} {set sm "h"; append st "l"}
- if {$lev >= 200} {set sm "o"; append st "o"}
- if {$lev >= 300} {append st "m"}
- if {$lev >= 500} {append st "n"}
- chattr [tnda get "login/$::netname($::sock)/$from"] +$st $cname
- }
- $::maintype putmode $::sock 77 $cname +$sm $from [tnda get "channels/$::netname($::sock)/$ndacname/ts"]
-}
-
-proc regnick {from msg} {
- set uname [lindex $msg 0 0]
- if {[string first "/" $uname] != -1} {return}
- set pw [lindex $msg 0 1]
- if {""!=[nda get "usernames/[string tolower $uname]"]} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "Account already exists; try LOGIN"
- return
- }
- nda set "usernames/[string tolower $uname]/password" [pwhash $pw]
- $::maintype setacct $::sock $from $uname
- callbind $::sock evnt "-" "login" $from $uname
-}
-
-proc chpassnick {from msg} {
- set uname [lindex $msg 0 0]
- if {[string first "/" $uname] != -1} {return}
- set pw [lindex $msg 0 1]
- set newpw [lindex $msg 0 2]
- set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"]
- set ispw [pwhash $pw]
-
- if {$ispw != [nda get "usernames/[string tolower $uname]/password"]} {
- $::maintype notice $::sock 77 $from "You fail at life."
- $::maintype notice $::sock 77 $from "Wrong pass."
- return
- }
- nda set "usernames/[string tolower $uname]/password" [pwhash $newpw]
- $::maintype notice $::sock 77 $from "Password changed."
-}
-
-proc idnick {from msg} {
- set uname [lindex $msg 0 0]
- if {[string first "/" $uname] != -1} {return}
- set pw [lindex $msg 0 1]
- set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"]
- set ispw [pwhash $pw]
- if {$ispw == [nda get "usernames/[string tolower $uname]/password"]} {
- $::maintype notice $::sock 77 $from "You have successfully logged in as $uname."
- $::maintype setacct $::sock $from $uname
- callbind $::sock evnt "-" "login" $from $uname
- } {
- $::maintype notice $::sock 77 $from "You cannot log in as $uname. You have the wrong password."
- }
-}
diff --git a/modules/gateway.disabled b/modules/gateway.disabled
@@ -0,0 +1,71 @@
+$::maintype sendUid $::sock($::cs(netname)) syn syn channels. channels. 1444 "Tin"
+bind $::sock($::cs(netname)) msg 1444 "addgwcloak" addgwcloak
+bind $::sock($::cs(netname)) msg 1444 "addaccloak" addaccloak
+bind $::sock($::cs(netname)) conn - - dogwcloak
+bind $::sock($::cs(netname)) motd - - dogwcloak
+bind $::sock($::cs(netname)) msg 1444 "motd" dogwcloak
+
+proc addgwcloak {from msg} {
+ set uname [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]
+ if {$::synpass != [lindex $msg 0 2]} {
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "SYNTAX: /msg syn addgwcloak match cloak syn-password"
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "FORMATCHAR: %i = realhost"
+ return
+ }
+ if {""==[lindex $msg 0 0]} {
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "SYNTAX: /msg syn addgwcloak match cloak"
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "FORMATCHAR: %i = realhost"
+ return
+
+ }
+ if {""==[lindex $msg 0 1]} {
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "SYNTAX: /msg syn addgwcloak match cloak"
+ $::maintype notice $::sock($::cs(netname)) 1444 $from "FORMATCHAR: %i = realhost"
+ return
+
+ }
+ nda set "gwcloaks/[lindex $msg 0 0]" [lindex $msg 0 1]
+}
+
+proc dogwcloak {unick n} {
+# doinsecurehost $unick
+ set fp [open ./services.motd r]
+ set fl [read $fp]
+# set fl ""
+ close $fp
+ foreach {l} [split $fl "\r\n"] {
+ $::maintype putmotd $::sock($::cs(netname)) $unick "$l"
+ }
+ $::maintype putmotdend $::sock($::cs(netname)) $unick
+ set match [tnda get "rhost/$::netname($::sock($::cs(netname)))/$unick"]
+ foreach {mask cloak} [nda get "gwcloaks"] {
+ if {[string match -nocase $mask "[tnda get "nick/$::netname($::sock($::cs(netname)))/$unick"]![tnda get "ident/$::netname($::sock($::cs(netname)))/$unick"]@[tnda get "rhost/$::netname($::sock($::cs(netname)))/$unick"]"]} {set match $cloak}
+ }
+ set cloake [string map [list "::" "-" ":" "."] [string map [list "%i" [tnda get "rhost/$::netname($::sock($::cs(netname)))/$unick"]] $match]]
+ $::maintype notice $::sock($::cs(netname)) 1444 $unick "$cloake should be your vHost."
+ $::maintype sethost $::sock($::cs(netname)) 1444 $unick "$cloake"
+ $::maintype putwallop $::sock($::cs(netname)) "CONNECT: [tnda get "nick/$::netname($::sock($::cs(netname)))/$unick"]![tnda get "ident/$::netname($::sock($::cs(netname)))/$unick"]@[tnda get "rhost/$::netname($::sock($::cs(netname)))/$unick"] ($cloake)"
+}
+
+proc doinsecurehost {unick} {
+ package require ip
+ set rhostname [tnda get "rhost/$::netname($::sock($::cs(netname)))/$unick"]
+ if {![string match "*:*" $rhostname] && [catch {::ip::toInteger $rhostname}]} {
+ if {![catch "exec php ./dnslib.php [string trim $rhostname] A . 0 $unick" reho]} {set rhostname [lindex [split [string trim $reho] " "] 1]} elseif {![catch "exec php ./dnslib.php [string trim $rhostname] AAAA . 0 $unick" reho]} {set rhostname [lindex [split [string trim $reho] " "] 1]} {puts stdout "gave up $rhostname $unick";return}
+ # If we returned then we gave up.
+ }
+ if {[string match "*:*" $rhostname]} {return;}
+ foreach {dnsbl} $::dnsbls {
+ set fp [open |[list php ./dnslib.php [string trim $rhostname] A $dnsbl 1 $unick] r]
+ set reho [read $fp]
+ catch "close $fp"
+ set reho [string trim $reho]
+ if {[lindex [split $reho " "] 0] == $unick} {set result [lindex [split $reho " "] 1]} {puts stdout "gave up $rhostname $unick results /$reho/";return}
+ # If we returned then we gave up.
+ if {$result!="" && $result != 0 && $result != 1} {$::maintype kill $::sock($::cs(netname)) 1444 $unick "(DNSBL::$::dname($dnsbl) match - if this is in error contact j4jackj)"}
+ }
+}
+
+set dname(dnsbl.dronebl.org) DroneBL
+set dname(6667.141.117.162.69.ip-port.exitlist.torproject.org) Tor
+set dnsbls [list dnsbl.dronebl.org 6667.141.117.162.69.ip-port.exitlist.torproject.org]
diff --git a/modules/trigserv.disabled b/modules/trigserv.disabled
@@ -1,9 +1,9 @@
-sendUid $::sock "T" "trigserv" "services." "services." 37 "Channel Spam Reduction and Trigger Services"
-#putmode $::sock 37 "T" "-d" "" ""
+sendUid $::sock($::cs(netname)) "T" "trigserv" "services." "services." 37 "Channel Spam Reduction and Trigger Services"
+#putmode $::sock($::cs(netname)) 37 "T" "-d" "" ""
foreach {chan is} [nda get "trigserv/regchan"] {
if {1!=$is} {continue}
- putjoin $::sock 37 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
+ putjoin $::sock($::cs(netname)) 37 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"]
}
bind request "t" "-" trigservjoin
bind request "trigserv" "-" trigservjoin
@@ -22,7 +22,7 @@ proc ndadec {n} {
proc trigservjoin {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- putjoin $::sock 37 $chan [nda get "regchan/$ndacname/ts"]
+ putjoin $::sock($::cs(netname)) 37 $chan [nda get "regchan/$ndacname/ts"]
nda set "trigserv/regchan/$ndacname" 1
}
@@ -33,19 +33,19 @@ proc trigservdochan {cname msg} {
set trigtype [lindex $msg 1 1]
set trigcriteria [lindex $msg 1 2]
set trigaction [lrange [lindex $msg 1] 3 end]
- if {200>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]} {
- privmsg $::sock 37 $cname "You must be at least op to set a trigger on the channel."
+ if {200>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} {
+ privmsg $::sock($::cs(netname)) 37 $cname "You must be at least op to set a trigger on the channel."
return
}
nda set "trigserv/trig/$chan/[ndaenc $trigtype]/[ndaenc $trigname]/[ndaenc $trigcriteria]" $trigaction
}
proc trigservdecay {target} {
- tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock)/$::netname($::sock)/$target"] - 1}]
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$target"] - 1}]
}
proc trigservincr {target} {
- tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock)/$::netname($::sock)/$target"] + 1}]
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$target"] + 1}]
}
proc trigservtest {cname msg} {
@@ -67,17 +67,17 @@ proc trigservcriterion {chan type tname criterion action trigcmd trigline from}
switch -nocase -- [lindex $criterion 0] {
"flood" {
trigservincr $chan
- puts stdout [tnda get "trigserv/flood/$::netname($::sock)/$chan"]
+ puts stdout [tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$chan"]
after [expr {[lindex $criterion 2] * 1000}] trigservdecay $chan
- if {[tnda get "trigserv/flood/$::netname($::sock)/$chan"] >= [lindex $criterion 1]} {
- privmsg $::sock 37 [ndadec $chan] "Message flood detected; setting +mi for 60 seconds"
- putmode $::sock 37 [ndadec $chan] "+mi" "" [tnda get "channels/$chan/$::netname($::sock)/ts"]
- after 60000 {putmode $::sock 37 [ndadec $chan] "-mi" "" [tnda get "channels/$chan/$::netname($::sock)/ts"]}
+ if {[tnda get "trigserv/flood/$::netname($::sock($::cs(netname)))/$chan"] >= [lindex $criterion 1]} {
+ privmsg $::sock($::cs(netname)) 37 [ndadec $chan] "Message flood detected; setting +mi for 60 seconds"
+ putmode $::sock($::cs(netname)) 37 [ndadec $chan] "+mi" "" [tnda get "channels/$chan/$::netname($::sock($::cs(netname)))/ts"]
+ after 60000 {putmode $::sock($::cs(netname)) 37 [ndadec $chan] "-mi" "" [tnda get "channels/$chan/$::netname($::sock($::cs(netname)))/ts"]}
}
}
"cmd" {
if {$trigcmd == [lindex $criterion 1]} {
- privmsg $::sock 37 [ndadec $chan] [join [list "\002[tnda get "nick/$::netname($::sock)/$from"]\002:" $action] " "]
+ privmsg $::sock($::cs(netname)) 37 [ndadec $chan] [join [list "\002[tnda get "nick/$::netname($::sock($::cs(netname)))/$from"]\002:" $action] " "]
}
}
}
diff --git a/services.conf.example b/services.conf.example
@@ -1,7 +1,7 @@
set numeric "53"
set servername "channels."
set password "laoo,rpe"
-set maintype p10
-set sock [connect 127.0.0.1 4400 ::p10::irc-main]
+set maintype ts6
+set sock [connect 127.0.0.1 4400 ::ts6::irc-main]
set netname($sock) "ast"
# Set a short network name; used for relaybawts