commit 9206db0a3929202a8ff4559b429322dcd490c267
parent d1382373a43c5fc545e8d92b6f9c8653389d4639
Author: Jaffa Cake <j4jackj@template.hostname>
Date: Sun, 10 Aug 2014 04:55:16 -0400
Holy.... don't even go there.
Diffstat:
17 files changed, 1176 insertions(+), 503 deletions(-)
diff --git a/b64.tcl b/b64.tcl
@@ -22,3 +22,57 @@ proc b64d {numb} {
}
return $res
}
+
+namespace eval unreal {
+proc ::unreal::b64e {numb} {
+ set b64 [split "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz{}" {}]
+
+ set res ""
+ while {$numb != 0} {
+ append res [lindex $b64 [expr {$numb % 64}]]
+ set numb [expr {$numb>>6}]
+ }
+ if {[string length $res] == 0} {
+ set res "A"
+ }
+ return [string reverse $res]
+}
+
+proc ::unreal::b64d {numb} {
+ set b64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz{}"
+ 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<<(6*$i)}]
+ }
+ return $res
+}
+}
+
+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
+}
+}
diff --git a/chanserv.help b/chanserv.help
@@ -0,0 +1,54 @@
+ ____ _ ____ _ _ _
+ / ___| |__ __ _ _ __ / ___| ___ _ ____ __ | | | | ___| |_ __
+| | | '_ \ / _` | '_ \\___ \ / _ \ '__\ \ / / | |_| |/ _ \ | '_ \
+| |___| | | | (_| | | | |___) | __/ | \ V / | _ | __/ | |_) |
+ \____|_| |_|\__,_|_| |_|____/ \___|_| \_/ |_| |_|\___|_| .__/
+ |_|
+
+Welcome to ChanServ (or whoever you messaged), your trusty
+channel protection bot.
+
+Commands available:
+
+hello username password
+ Create an account. You are automatically logged in.
+
+login username password
+ Log into an existing account.
+
+convertop channel
+ Convert access list levels to flags. Mostly useful for
+ generating proper autoop lists.
+
+chattr username flags channel
+ Change a flag on a user in a channel (or if you are an
+ ircop and no channel is specified, the bot itself)
+
+chanset channel eggdrop-style chanset
+ Change a chanset. Chansets are settings on a channel
+ that change chanserv's behaviour.
+ Currently available chansets:
+ autoop Automatically give operator to all channel
+ operators on the chattr list.
+ autohalfop Automatically give half operator to all channel
+ half operators on the chattr list.
+ ... and so on with voice and the various bitches, with a new one:
+ operit Automatically op all IRC operators, halfop
+ all network halfops and voice all network voices.
+
+lsu channel
+ View the userlist for a channel.
+
+up channel
+ Gives you the appropriate privileges for your current login
+ name on the channel.
+
+
+Channel commands available
+
+@up
+ Gives you appropriate privileges for the current channel.
+
+@request funserv bot
+ Request the named service bot to the current channel. You
+ need at least halfop.
diff --git a/core/0000-conn.tcl b/core/0000-conn.tcl
@@ -7,3 +7,5 @@ proc connect {addr port script} {
fileevent $sck readable [concat $script $sck]
return $sck
}
+
+source services.conf
diff --git a/core/0001-p10.tcl b/core/0001-p10.tcl
@@ -1,279 +0,0 @@
-proc sendUid {sck nick ident host dhost uid {realname "* Unknown *"}} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- set sl [format "%s N %s 1 %s %s %s +oik AAAAAA %s%s :%s" $sid $nick [clock format [clock seconds] -format %s] $ident $host $sid $sendnn $realname]
- tnda set "intclient/${sid}${sendnn}" $uid
- puts $sck $sl
- puts stdout $sl
-}
-
-proc privmsg {sck uid targ msg} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- puts $sck [format "%s%s P %s :%s" $sid $sendnn $targ $msg]
- puts stdout [format "%s%s P %s :%s" $sid $sendnn $targ $msg]
-}
-
-proc kick {sck uid targ tn msg} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- puts $sck [format "%s%s K %s %s :%s" $sid $sendnn $targ $tn $msg]
-}
-
-proc notice {sck uid targ msg} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- puts $sck [format "%s%s O %s :%s" $sid $sendnn $targ $msg]
-}
-
-proc setacct {sck targ msg} {
- global sid
- puts $sck [format "%s AC %s R %s" $sid $targ $msg]
- tnda set "login/$targ" $msg
-}
-
-proc 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/$bindnum" $script
- return $bindnum
-}
-
-proc unbind {type client comd id} {
- tnda set "binds/$type/$client/$comd/$id" ""
-}
-
-proc putmode {sck uid targ mode parm ts} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- puts $sck [format "%s%s M %s %s %s" $sid $sendnn $targ $mode $parm $ts]
-}
-
-proc putjoin {sck uid targ ts} {
- global sid
- set sendid [b64e $uid]
- set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
- append sendnn $sendid
- puts $sck [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
- puts stdout [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
-
-}
-
-proc callbind {type client comd args} {
- if {""!=[tnda get "binds/$type/$client/$comd"]} {foreach {id script} [tnda get "binds/$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}
-}
-
-proc p10-main {sck} {
- global sid sock
- if {[eof $sck]} {puts stderr "duckfuck.";exit}
- gets $sck line
- set line [string trim $line "\r\n"]
- 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 " "]
- switch -nocase -- [lindex $comd 1] {
- "P" {
- if {[string index [lindex $comd 2] 0] == "#"} {
- set client chan
- callbind pub "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
- callbind evnt "-" "chanmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
- } {
- set client [tnda get "intclient/[lindex $comd 2]"]
- callbind msg $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
- }
- }
-
- "O" {
- if {[string index [lindex $comd 2] 0] == "#"} {
- set client chan
- callbind pubnotc "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
- callbind pubnotc-m "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
- } {
- set client [tnda get "intclient/[lindex $comd 2]"]
- callbind notc $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
- }
- }
-
- "M" {
- if {[string length [lindex $comd 0]] != 2} {if {[lindex $comd 2] == [tnda get "nick/[lindex $comd 0]"]} {
- foreach {c} [split [lindex $comd 3] {}] {
- switch -- $c {
- "+" {set state 1}
- "-" {set state 0}
- "o" {tnda set "oper/[lindex $comd 0]" $state}
- }
- }
- } } {
- set ctr 3
- foreach {c} [split [lindex $comd 3] {}] {
- switch -regexp -- $c {
- "\\\+" {set state 1}
- "\\\-" {set state 0}
- "[aCcDdiMmNnOpQRrSsTtZz]" {callbind mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2]}
- "[belLkohv]" {callbind mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] [lindex $comd [incr ctr]]}
- }
- }
- }
- }
-
- "C" {
- callbind create "-" "-" [lindex $comd 2] [lindex $comd 0]
- callbind join "-" "-" [lindex $comd 2] [lindex $comd 0]
- set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
- tnda set "channels/$chan/ts" [lindex $comd 3]
- }
-
- "OM" {
- if {[string length [lindex $comd 0]] != 2} {if {[lindex $comd 2] == [tnda get "nick/[lindex $comd 0]"]} {
- foreach {c} [split [lindex $comd 3] {}] {
- switch -- $c {
- "+" {set state 1}
- "-" {set state 0}
- "o" {tnda set "oper/[lindex $comd 0]" $state}
- }
- }
- } } {
- set ctr 3
- foreach {c} [split [lindex $comd 3] {}] {
- switch -regexp -- $c {
- "\\\+" {set state 1}
- "\\\-" {set state 0}
- "[aCcDdiMmNnOpQRrSsTtZz]" {callbind mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2]}
- "[belLkohv]" {callbind mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] [lindex $comd [incr ctr]]}
- }
- }
- }
- }
-
- "B" {
- puts $sck "$sid EB"
- set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
- puts stdout "$chan"
- if {[string index [lindex $comd 4] 0] == "+"} {
- set four 5
- if {[string match "*l*" [lindex $comd 4]]} {incr four}
- if {[string match "*L*" [lindex $comd 4]]} {incr four}
- if {[string match "*k*" [lindex $comd 4]]} {incr four}
- } {
- set four 4
- }
- tnda set "channels/$chan/ts" [lindex $comd 3]
- foreach {nick} [split [lindex $comd $four] ","] {
- set n [split $nick ":"]
- set un [lindex $n 0]
- set uo [lindex $n 1]
- if {""!=$uo} {tnda set "channels/$chan/modes/$un" $uo}
- callbind join "-" "-" [lindex $comd 2] $un
- }
-
- }
-
- "J" {
- callbind join "-" "-" [lindex $comd 2] [lindex $comd 0]
- }
-
- "L" {
- callbind part "-" "-" [lindex $comd 2] [lindex $comd 0]
- }
-
- "EB" {
- puts $sck "$sid EA"
- }
-
- "N" {
- if {[llength $comd] >= 5} {
- set num 8
- set ctr 1
- set oper 0
- set loggedin ""
- set fakehost ""
- set modes ""
- if {[string index [lindex $comd 7] 0] == "+"} {set modes [string range [lindex $comd 7] 1 end]; incr num}
- foreach {c} [split $modes {}] {
- puts stdout "$ctr $comd"
- switch -exact -- $c {
- "o" {set oper 1}
- "r" {incr ctr;incr num; set loggedin [lindex $comd [expr {$ctr+6}]]}
- "C" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
- "c" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
- "f" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
- "h" {incr ctr;incr num; set fakehost [lindex [split [lindex $comd [expr {$ctr+7}]] "@"] 1]}
- }
- }
-
- if {""!=$loggedin} {
- tnda set "login/[lindex $comd $num]" $loggedin
- }
-
- if {""!=$fakehost} {
- tnda set "vhost/[lindex $comd $num]" $fakehost
- }
-
- puts $sck "$sid O #o :conn $line"
-
- tnda set "nick/[lindex $comd $num]" [lindex $comd 2]
- tnda set "oper/[lindex $comd $num]" $oper
- tnda set "ident/[lindex $comd $num]" [lindex $comd 5]
- tnda set "rhost/[lindex $comd $num]" [lindex $comd 6]
- callbind conn "-" "-" [lindex $comd $num]
- } {
- puts $sck "$sid O #o :nch [tnda get "nick/[lindex $comd 0]"] [lindex $comd 2]"
- callbind nch "-" "-" [lindex $comd $num] [tnda get "nick/[lindex $comd 0]"] [lindex $comd 2]
- tnda set "nick/[lindex $comd 0]" [lindex $comd 2]
- }
- }
-
- "Q" {
- tnda set "login/[lindex $comd 0]" ""
- tnda set "nick/[lindex $comd 0]" ""
- tnda set "oper/[lindex $comd 0]" 0
- tnda set "ident/[lindex $comd 0]" ""
- tnda set "rhost/[lindex $comd 0]" ""
- tnda set "vhost/[lindex $comd 0]" ""
- }
-
- "D" {
- tnda set "login/[lindex $comd 2]" ""
- tnda set "nick/[lindex $comd 2]" ""
- tnda set "oper/[lindex $comd 2]" 0
- tnda set "ident/[lindex $comd 2]" ""
- tnda set "rhost/[lindex $comd 2]" ""
- tnda set "vhost/[lindex $comd 2]" ""
- }
-
- "G" {
- puts $sck "$sid Z [lindex $comd 3] [lindex $comd 2] [lindex $comd 4]"
- }
- }
-}
-
-proc p10-burst {sck} {
- global servername sid password
- set sid [string repeat "A" [expr {2-[b64e $::numeric]}]]
- append sid [b64e $::numeric]
- puts $sck "PASS :$password"
- puts $sck "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks"
- puts stdout "PASS :$password"
- puts stdout "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks"
-}
-
-
-source services.conf
-
-set sid [string repeat "A" [expr {2-[b64e $numeric]}]]
-append sid [b64e $numeric]
diff --git a/core/0002-p10.tcl b/core/0002-p10.tcl
@@ -0,0 +1,291 @@
+
+namespace eval p10 {
+set sid [string repeat "A" [expr {2-[b64e $::numeric]}]]
+append sid [b64e $::numeric]
+
+proc ::p10::sendUid {sck nick ident host dhost uid {realname "* Unknown *"} {modes "+oik"} {server ""}} {
+ if {""==$server} {set server $::numeric}
+ set sid [string repeat "A" [expr {2-[string length [b64e $server]]}]]
+ append sid [b64e $server]
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ set sl [format "%s N %s 1 %s %s %s %s AAAAAA %s%s :%s" $sid $nick [clock format [clock seconds] -format %s] $ident $host $modes $sid $sendnn $realname]
+ tnda set "intclient/$::netname($sck)/${sid}${sendnn}" $uid
+ puts $sck $sl
+}
+
+proc ::p10::sendSid {sck sname sid {realname "In use by Services"}} {
+ set sl [format "%s S %s 2 %s %s P10 %s]]] 0 :%s" [b64e $::sid] $sname [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] [b64e $sid] $realname]
+ puts $sck $sl
+}
+
+proc ::p10::privmsg {sck uid targ msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s P %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::p10::kick {sck uid targ tn msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s K %s %s :%s" $sid $sendnn $targ $tn $msg]
+}
+
+proc ::p10::notice {sck uid targ msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s O %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::p10::setacct {sck targ msg} {
+ global sid
+ puts $sck [format "%s AC %s R %s" $sid $targ $msg]
+ tnda set "login/$::netname($sck)/$targ" $msg
+}
+
+proc ::p10::bind {sock type client comd script} {
+ set moretodo 1
+ while {0!=$moretodo} {
+ set bindnum [rand 1 10000000]
+ if {[tnda get "binds/$sock/$type/$client/$comd/$bindnum"]!=""} {} {set moretodo 0}
+ }
+ tnda set "binds/$sock/$type/$client/$comd/$bindnum" $script
+ puts stdout "binds/$sock/$type/$client/$comd/$bindnum [tnda get "binds/$sock/$type/$client/$comd"]"
+ return $bindnum
+}
+
+proc ::p10::unbind {sock type client comd id} {
+ tnda set "binds/$sock/$type/$client/$comd/$id" ""
+}
+
+proc ::p10::putmode {sck uid targ mode parm ts} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s M %s %s %s" $sid $sendnn $targ $mode $parm $ts]
+}
+
+proc ::p10::putjoin {sck uid targ ts} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
+ puts stdout [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
+
+}
+
+proc ::p10::callbind {sock type client comd args} {
+ puts stdout "[tnda get "binds/$sock/$type/$client/$comd"]"
+ 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}
+}
+
+proc ::p10::irc-main {sck} {
+ global sid sock
+ if {[eof $sck]} {puts stderr "duckfuck.";exit}
+ gets $sck line
+ set line [string trim $line "\r\n"]
+ 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 " "]
+ switch -nocase -- [lindex $comd 1] {
+ "P" {
+ if {[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] p10
+ callbind $sck evnt "-" "chanmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] p10
+ } {
+ 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] p10
+ callbind $sck "evnt" "-" "privmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] p10
+ }
+ }
+
+ "O" {
+ if {[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] p10
+ callbind $sck pubnotc-m "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end] p10
+ callbind $sck "evnt" "-" "channotc" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end] p10
+ } {
+ 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] p10
+ }
+ }
+
+ "M" {
+ if {[string index [lindex $comd 2] 0] != "#"} {if {[lindex $comd 2] == [tnda get "nick/$::netname($sck)/[lindex $comd 0]"]} {
+ foreach {c} [split [lindex $comd 3] {}] {
+ switch -- $c {
+ "+" {set state 1}
+ "-" {set state 0}
+ "o" {tnda set "oper/$::netname($sck)/[lindex $comd 0]" $state}
+ }
+ }
+ } } {
+ set ctr 3
+ foreach {c} [split [lindex $comd 3] {}] {
+ switch -regexp -- $c {
+ "\\\+" {set state 1}
+ "-" {set state 0}
+ "[aCcDdiMmNnOpQRrSsTtZz]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] $::netname($sck)}
+ "[belLkohv]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] [lindex $comd [incr ctr]] $::netname($sck)}
+ }
+ }
+ }
+ }
+
+ "C" {
+ callbind $sck create "-" "-" [lindex $comd 2] [lindex $comd 0] $::netname($sck)
+ callbind $sck join "-" "-" [lindex $comd 2] [lindex $comd 0] $::netname($sck)
+ set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
+ tnda set "channels/$::netname($sck)/$chan/$::netname($sck)/ts" [lindex $comd 3]
+ }
+
+ "OM" {
+ set ctr 3
+ foreach {c} [split [lindex $comd 3] {}] {
+ switch -regexp -- $c {
+ "\\\+" {set state 1}
+ "\\\-" {set state 0}
+ "[aCcDdiMmNnOpQRrSsTtZz]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2]}
+ "[belLkohv]" {callbind $sck mode "-" [expr {$state ? "+" : "-"}] $c [lindex $comd 0] [lindex $comd 2] [lindex $comd [incr ctr]]}
+ }
+ }
+ }
+
+ "B" {
+ puts $sck "$sid EB"
+ set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
+ puts stdout "$chan"
+ if {[string index [lindex $comd 4] 0] == "+"} {
+ set four 5
+ if {[string match "*l*" [lindex $comd 4]]} {incr four}
+ if {[string match "*L*" [lindex $comd 4]]} {incr four}
+ if {[string match "*k*" [lindex $comd 4]]} {incr four}
+ } {
+ set four 4
+ }
+ tnda set "channels/$::netname($sck)/$chan/$::netname($sck)/ts" [lindex $comd 3]
+ foreach {nick} [split [lindex $comd $four] ","] {
+ set n [split $nick ":"]
+ set un [lindex $n 0]
+ set uo [lindex $n 1]
+ if {""!=$uo} {tnda set "channels/$::netname($sck)/$chan/modes/$::netname($sck)/$un" $uo}
+ callbind $sck join "-" "-" [lindex $comd 2] $un
+ }
+
+ }
+
+ "J" {
+ callbind $sck join "-" "-" [lindex $comd 2] [lindex $comd 0]
+ }
+
+ "L" {
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 0]
+ }
+
+ "K" {
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 3]
+ }
+
+ "EB" {
+ puts $sck "$sid EA"
+ }
+
+ "N" {
+ if {[llength $comd] >= 5} {
+ set num 8
+ set ctr 1
+ set oper 0
+ set loggedin ""
+ set fakehost ""
+ set modes ""
+ if {[string index [lindex $comd 7] 0] == "+"} {set modes [string range [lindex $comd 7] 1 end]; incr num}
+ foreach {c} [split $modes {}] {
+ puts stdout "$ctr $comd"
+ switch -exact -- $c {
+ "o" {set oper 1}
+ "r" {incr ctr;incr num; set loggedin [lindex $comd [expr {$ctr+6}]]}
+ "C" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
+ "c" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
+ "f" {incr ctr;incr num; set fakehost [lindex $comd [expr {$ctr+6}]]}
+ "h" {incr ctr;incr num; set fakehost [lindex [split [lindex $comd [expr {$ctr+7}]] "@"] 1]}
+ }
+ }
+
+ if {""!=$loggedin} {
+ tnda set "login/$::netname($sck)/[lindex $comd $num]" $loggedin
+ }
+
+ if {""!=$fakehost} {
+ tnda set "vhost/$::netname($sck)/[lindex $comd $num]" $fakehost
+ }
+
+ 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 5]
+ tnda set "rhost/$::netname($sck)/[lindex $comd $num]" [lindex $comd 6]
+ callbind $sck conn "-" "-" [lindex $comd $num]
+ } {
+ callbind $sck nch "-" "-" [lindex $comd 0] [tnda get "nick/$::netname($sck)/[lindex $comd 0]"] [lindex $comd 2]
+ tnda set "nick/$::netname($sck)/[lindex $comd 0]" [lindex $comd 2]
+ }
+ }
+
+ "Q" {
+ 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]" ""
+ }
+
+ "D" {
+ 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]" ""
+ }
+
+ "G" {
+ puts $sck "$sid Z [lindex $comd 3] [lindex $comd 2] [lindex $comd 4]"
+ }
+ }
+}
+
+proc ::p10::login {sck} {
+ global servername sid password
+ set sid [string repeat "A" [expr {2-[b64e $::numeric]}]]
+ append sid [b64e $::numeric]
+ puts $sck "PASS :$password"
+ puts $sck "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks ($::netname($sck))"
+ puts stdout "PASS :$password"
+ puts stdout "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks"
+}
+
+
+#source services.conf
+namespace export *
+namespace ensemble create
+}
+
+#p10 login $::sock
diff --git a/core/0003-ts6.tcl b/core/0003-ts6.tcl
@@ -0,0 +1,301 @@
+# Because TS6 ircds are highly configurable, we start in Charybdis mode without
+# an idea what modes are permissible. This is to aid ChanServ.
+if {![info exists ::ts6(halfops)]} {set halfops 0} {set halfops $::ts6(halfops)}
+if {![info exists ::ts6(euid)]} {set ::ts6(euid) 1}
+
+namespace eval ts6 {
+set sid [string repeat "0" [expr {3-[string length [b64e $::numeric]]}]]
+append sid [b64e $::numeric]
+
+proc ::ts6::sendUid {sck nick ident host dhost uid {realname "* Unknown *"} {modes "+oiS"} {server ""}} {
+ if {""==$server} {set server $::numeric}
+ set sid [string repeat "0" [expr {3-[string length [b64e $server]]}]]
+ append sid [b64e $server]
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ if {!$::ts6(euid)} {
+ set sl [format ":%s UID %s 1 %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 0 %s%s * * :%s" $sid $nick [clock format [clock seconds] -format %s] $modes $ident $host $sid $sendnn $realname]
+ }
+ tnda set "intclient/$::netname($sck)/$::netname($::sock)/${sid}${sendnn}" $uid
+ puts $sck $sl
+}
+
+proc ::ts6::sendSid {sck sname sid {realname "In use by Services"}} {
+ set sl [format ":%s SID %s 1 %s :%s" [b64e $::sid] $sname [b64e $sid] $realname]
+ puts $sck $sl
+}
+
+proc ::ts6::privmsg {sck uid targ msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format ":%s%s PRIVMSG %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::ts6::kick {sck uid targ tn msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format ":%s%s KICK %s %s :%s" $sid $sendnn $targ $tn $msg]
+}
+
+proc ::ts6::notice {sck uid targ msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format ":%s%s NOTICE %s :%s" $sid $sendnn $targ $msg]
+}
+
+proc ::ts6::setacct {sck targ msg} {
+ global sid
+ puts $sck [format ":%s ENCAP * SU %s %s" $sid $targ $msg]
+ tnda set "login/$::netname($sck)/$::netname($::sock)/$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($::sock)/$bindnum" $script
+ return $bindnum
+}
+
+proc ::ts6::unbind {type client comd id} {
+ tnda set "binds/$type/$client/$comd/$::netname($::sock)/$id" ""
+}
+
+proc ::ts6::putmode {sck uid targ mode parm ts} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s M %s %s %s" $sid $sendnn $targ $mode $parm $ts]
+}
+
+proc ::ts6::putjoin {sck uid targ ts} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
+ puts stdout [format "%s B %s %s %s%s:o" $sid $targ $ts $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}
+}
+
+proc ::ts6::irc-main {sck} {
+ global sid sock
+ if {[eof $sck]} {close $sck}
+ gets $sck line
+ set line [string trim $line "\r\n"]
+ set one [string match ":*" $line]
+ set gotsplitwhere [string first " :" $line]
+ if {$gotsplitwhere==-1} {set comd [split $line " "]} {set comd [split [string range $line 1 [expr {$gotsplitwhere - 1}]] " "]}
+ set payload [split [string range $line [expr {$gotsplitwhere + 2}] end] " "]
+ puts stdout [join $comd " "]
+ switch -nocase -- [lindex $comd $one] {
+ "005" {
+ 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 0] {}]
+ set modepref [split [lindex $mod 1] {}]
+ foreach {c} $modechar {x} $modepref {
+ tnda set "ts6/$::netname($sck)/prefix/$::netname($::sock)/$modepref" $modechar
+ }
+ }
+ }
+ }
+ }
+
+ "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 0] {}]
+ set modepref [split [lindex $mod 1] {}]
+ foreach {c} $modechar {x} $modepref {
+ tnda set "ts6/$::netname($sck)/prefix/$::netname($::sock)/$modepref" $modechar
+ }
+ }
+ }
+ }
+ }
+
+ "PRIVMSG" {
+ if {[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
+ } {
+ 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
+ }
+ }
+
+ "NOTICE" {
+ if {[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
+ } {
+ 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
+ }
+ }
+
+ "MODE" {
+ if {[lindex $comd 3] == [tnda get "nick/$::netname($sck)/[lindex $comd 0]"]} {
+ foreach {c} [split [lindex $comd 4] {}] {
+ switch -- $c {
+ "+" {set state 1}
+ "-" {set state 0}
+ "o" {tnda set "oper/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" $state}
+ }
+ }
+ }
+ }
+
+ "JOIN" {
+ set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
+ if {""==[tnda get "channels/$::netname($sck)/$chan/ts"]} {callbind $sck create "-" "-" [lindex $comd 2] [lindex $comd 0]}
+ callbind $sck join "-" "-" [lindex $comd 2] [lindex $comd 0]
+ tnda set "channels/$::netname($sck)/$chan/$::netname($::sock)/ts" [lindex $comd 3]
+ }
+
+ "TMODE" {
+ set ctr 3
+ foreach {c} [split [lindex $comd 3] {}] {
+ switch -regexp -- $c {
+ "\\\+" {set state 1}
+ "\\\-" {set state 0}
+ "[CcDdiMmNnOpPQRrSsTtZz]" {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)}
+ }
+ }
+ }
+
+ "SJOIN" {
+ set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 3]]]]
+ if {[string index [lindex $comd 4] 0] == "+"} {
+ set four 5
+ if {[string match "*l*" [lindex $comd 4]]} {incr four}
+ if {[string match "*f*" [lindex $comd 4]]} {incr four}
+ if {[string match "*j*" [lindex $comd 4]]} {incr four}
+ if {[string match "*k*" [lindex $comd 4]]} {incr four}
+ } {
+ set four 4
+ }
+ tnda set "channels/$::netname($sck)/$chan/$::netname($::sock)/ts" [lindex $comd 2]
+ foreach {nick} [split [lindex $comd $four] " "] {
+ set un ""
+ set uo ""
+ set state uo
+ foreach {c} [split $nick {}] {
+ if {[string is integer $c]} {set state un}
+ if {$state == "uo"} {set c [tnda get "ts6/$::netname($sck)/prefixe/$c"]}
+ append $state $c
+ }
+ if {""!=$uo} {tnda set "channels/$::netname($sck)/$chan/modes/$::netname($::sock)/$un" $uo}
+ callbind $sck join "-" "-" [lindex $comd 3] $un
+ }
+
+ }
+
+ "PART" {
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 0]
+ }
+
+ "KICK" {
+ callbind $sck part "-" "-" [lindex $comd 2] [lindex $comd 3]
+ }
+
+ "EUID" {
+ set num 9
+ set ctr 1
+ set oper 0
+ set loggedin [lindex $comd 11]
+ set realhost [lindex $comd 10]
+ set modes [lindex $comd 4]
+ if {[string match "*o*" $modes]} {set oper 1}
+ if {"*"!=$loggedin} {
+ tnda set "login/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" $loggedin
+ }
+ if {"*"!=$realhost} {
+ tnda set "rhost/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" $realhost
+ } {
+ tnda set "rhost/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" [lindex $comd 6]
+ }
+ tnda set "nick/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" [lindex $comd 2]
+ tnda set "oper/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" $oper
+ tnda set "ident/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" [lindex $comd 5]
+ tnda set "vhost/$::netname($sck)/$::netname($::sock)/[lindex $comd $num]" [lindex $comd 6]
+ callbind $sck conn "-" "-" [lindex $comd $num]
+ }
+
+ "QUIT" {
+ tnda set "login/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" ""
+ tnda set "nick/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" ""
+ tnda set "oper/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" 0
+ tnda set "ident/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" ""
+ tnda set "rhost/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" ""
+ tnda set "vhost/$::netname($sck)/$::netname($::sock)/[lindex $comd 0]" ""
+ }
+
+ "KILL" {
+ tnda set "login/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" ""
+ tnda set "nick/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" ""
+ tnda set "oper/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" 0
+ tnda set "ident/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" ""
+ tnda set "rhost/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" ""
+ tnda set "vhost/$::netname($sck)/$::netname($::sock)/[lindex $comd 2]" ""
+ }
+
+ "PING" {
+ puts $sck ":$sid PONG [lindex $comd 3] [lindex $comd 2]"
+ }
+ }
+}
+
+proc ::ts6::login {sck {sid $::numeric} {password $::password}} {
+ set num [string repeat "0" [expr {3-[string length [b64e $sid]]}]]
+ append num [b64e $::numeric]
+ puts $sck "PASS $password TS 6 :$num"
+ 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"
+}
+
+
+#source services.conf
+namespace export *
+namespace ensemble create
+}
+
+#ts6 login $::sock
diff --git a/core/9999-protocol-common.tcl b/core/9999-protocol-common.tcl
@@ -0,0 +1,24 @@
+proc bind {sock type client comd script} {
+ set moretodo 1
+ while {0!=$moretodo} {
+ set bindnum [rand 1 10000000]
+ if {[tnda get "binds/$sock/$type/$client/$comd/$bindnum"]!=""} {} {set moretodo 0}
+ }
+ tnda set "binds/$sock/$type/$client/$comd/$bindnum" $script
+ return $bindnum
+}
+
+proc unbind {sock type client comd id} {
+ tnda set "binds/$sock/$type/$client/$comd/$id" ""
+}
+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]
+ };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/modules/0001-chanserv.tcl b/modules/0001-chanserv.tcl
@@ -1,88 +1,148 @@
source chanserv.conf
-sendUid $sock $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server"
-bind msg 77 "register" regchan
-bind msg 77 "adduser" adduserchan
-bind msg 77 "users" lsuchan
-bind msg 77 "lsu" lsuchan
-#bind msg 77 "deluser" deluserchan
-bind msg 77 "up" upchan
-bind pub "-" "@up" upchanfant
-bind pub "-" "@rand" randfant
-bind pub "-" "@request" requestbot
-bind msg 77 "down" downchan
-bind msg 77 "hello" regnick
-bind msg 77 "chpass" chpassnick
-bind msg 77 "login" idnick
-bind msg 77 "help" chanhelp
-bind mode "-" "+" checkop
-bind mode "-" "-" checkdeop
-bind create "-" "-" checkcreate
+$::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 "cookie" authin
+bind $::sock msg 77 "cauth" cookieauthin
+bind $::sock mode "-" "+" checkop
+bind $::sock mode "-" "-" checkdeop
+bind $::sock create "-" "-" checkcreate
+
+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/$from"]
+ 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]} {privmsg $::sock 77 $cname "\002$froni:\002 Your request would have caused a divide by zero and was not processed.";return}
- privmsg $::sock 77 $cname "\002$froni:\002 Your die rolled [rand [lindex $msg 1 0] [lindex $msg 1 1]]"
+ 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} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "Channel does not exist."
+ $::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"]
- notice $::sock 77 $from "Access | Username"
- notice $::sock 77 $from "-------+------------"
+ $::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]
- notice $::sock 77 $from " $nl | $nick"
+ 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"
}
- notice $::sock 77 $from "-------+------------"
- notice $::sock 77 $from " | End of access list"
+ $::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/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ 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/$from"]]"]} {
- privmsg $::sock 77 $cname "You fail at life."
- privmsg $::sock 77 $cname "Channel not registered to you."
+ if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"] && ![string match "\[olvmn\]" [nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock)/$from"]"]]} {
+ $::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/$from"]]"]
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]
set sm "+"
set st ""
- if {$lev >= 1} {set sm "v"}
- if {$lev >= 150} {set sm "h"}
- if {$lev >= 200} {set sm "o"}
- putmode $::sock 77 $cname $sm $from [tnda get "channels/$ndacname/ts"]
+ 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 h}
+ if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |omn $cname]} {set sm o}
+ } {
+ 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/$ndacname/$::netname($::sock)/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/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ 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/$from"]]"]} {
- privmsg $::sock 77 $cname "You fail at life."
- privmsg $::sock 77 $cname "You must be at least halfop to request $bot."
+ if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$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 request [string tolower $bot] "-" $cname
+ callbind $::sock request [string tolower $bot] "-" $cname
}
foreach {chan _} [nda get "regchan"] {
- putjoin $::sock 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
- putmode $::sock 77 [::base64::decode [string map {[ /} $chan]] "+nt" "" [nda get "regchan/$chan/ts"]
+ $::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"]
}
proc checkop {mc ftp} {
@@ -91,12 +151,12 @@ proc checkop {mc ftp} {
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/$p"]o"
+ 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/$ftp" "o"
+ tnda set "channels/$chan/modes/$::netname($::sock)/$ftp" "o"
puts stdout "channels/$chan/modes/$ftp"
}
@@ -106,74 +166,80 @@ proc checkdeop {mc ftp} {
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/$p"]]
+ tnda set "channels/$chan/modes/$p" [string map {o ""} [tnda get "channels/$chan/modes/$::netname($::sock)/$::netname($::sock)/$p"]]
}
proc chanhelp {from msg} {
- notice $::sock 77 $from " --- ChanServ Help ---"
- notice $::sock 77 $from "ChanServ provides channel auto op and basic protection (depending on loaded scripts)"
- notice $::sock 77 $from "to registered channels."
- notice $::sock 77 $from " -!- Commands available -!-"
- notice $::sock 77 $from "register <channel> - Register a channel to your username. "
- notice $::sock 77 $from "adduser <channel> <user name> <add level> - Add a username to the channel access list."
- notice $::sock 77 $from "up <channel> - (@up) Ops you if you have level on the channel for this username."
- notice $::sock 77 $from "down <channel> - Removes all channel user modes affecting your nick."
- notice $::sock 77 $from "hello <username> <password> - Register a username."
- notice $::sock 77 $from "login <username> <password> - Log in to a username."
+ 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/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ 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} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "Channel already exists."
+ $::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/$ndacname/modes/$from"]]} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "You are not an operator."
+ if {-1==[string first "o" [tnda get "channels/$ndacname/modes/$::netname($::sock)/$from"]]} {
+ $::maintype notice $::sock 77 $from "You fail at life."
+ $::maintype notice $::sock 77 $from "You are not an operator."
return
}
- notice $::sock 77 $from "Guess what? :)"
- nda set "regchan/$ndacname/levels/[tnda get "login/$from"]" 500
- nda set "regchan/$ndacname/ts" [tnda get "channels/$ndacname/ts"]
- putjoin $::sock 77 $cname [tnda get "channels/$ndacname/ts"]
- callbind "reg" "-" "-" $cname [tnda get "channels/$ndacname/ts"]
+ $::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/$ndacname/$::netname($::sock)/ts"]
+ $::maintype putjoin $::sock 77 $cname [tnda get "channels/$ndacname/$::netname($::sock)/ts"]
+ chattr [tnda get "login/$::netname($::sock)/$from"] +mno $cname
+ callbind $::sock "reg" "-" "-" $cname [tnda get "channels/$ndacname/$::netname($::sock)/ts"]
}
proc adduserchan {from msg} {
- if {""==[tnda get "login/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ 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/$from"]"]} {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/$from"]"]} {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/$from"]} {notice $::sock 77 $from "You can't change your own level, even if you're downgrading. Sorreh :/";return}
- notice $::sock 77 $from "Guess what? :) User added."
+ 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/$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/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ 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/$from"]]"]} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "Channel not registered to you."
+ if {1>[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 "Channel not registered to you."
return
}
- set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock)/$from"]]"]
set sm "+"
set st ""
- if {$lev >= 1} {set sm "v"}
- if {$lev >= 150} {set sm "h"}
- if {$lev >= 200} {set sm "o"}
- putmode $::sock 77 $cname $sm $from [tnda get "channels/$ndacname/ts"]
+ 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 h}
+ if {[matchattr [tnda get "login/$::netname($::sock)/$from"] |omn $cname]} {set sm o}
+ } {
+ 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/$ndacname/$::netname($::sock)/ts"]
}
proc regnick {from msg} {
@@ -181,13 +247,13 @@ proc regnick {from msg} {
if {[string first "/" $uname] != -1} {return}
set pw [lindex $msg 0 1]
if {""!=[nda get "usernames/[string tolower $uname]"]} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "Account already exists; try LOGIN"
+ $::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]
- setacct $::sock $from $uname
- callbind evnt "-" "login" $from $uname
+ $::maintype setacct $::sock $from $uname
+ callbind $::sock evnt "-" "login" $from $uname
}
proc chpassnick {from msg} {
@@ -199,12 +265,12 @@ proc chpassnick {from msg} {
set ispw [pwhash $pw]
if {$ispw != [nda get "usernames/[string tolower $uname]/password"]} {
- notice $::sock 77 $from "You fail at life."
- notice $::sock 77 $from "Wrong pass."
+ $::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]
- notice $::sock 77 $from "Password changed."
+ $::maintype notice $::sock 77 $from "Password changed."
}
proc idnick {from msg} {
@@ -214,10 +280,10 @@ proc idnick {from msg} {
set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"]
set ispw [pwhash $pw]
if {$ispw == [nda get "usernames/[string tolower $uname]/password"]} {
- notice $::sock 77 $from "You have successfully logged in as $uname."
- setacct $::sock $from $uname
- callbind evnt "-" "login" $from $uname
+ $::maintype notice $::sock 77 $from "You have successfully logged in as $uname."
+ $::maintype setacct $::sock $from $uname
+ callbind $::sock evnt "-" "login" $from $uname
} {
- notice $::sock 77 $from "You cannot log in as $uname. You have the wrong password."
+ $::maintype notice $::sock 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 pub "-" "!lag" publag
-bind pub "-" "!weed" pubweed
-bind pub "-" "!coffee" pubcoffee
-bind notc 77 "ping" lagresp
+bind $::sock pub "-" "!lag" publag
+bind $::sock pub "-" "!weed" pubweed
+bind $::sock pub "-" "!coffee" pubcoffee
+bind $::sock notc 77 "ping" lagresp
proc publag {cname msg} {
set from [lindex $msg 0 0]
- privmsg $::sock 77 $from "\001PING [clock clicks -milliseconds] $cname \001"
+ p10 privmsg $::sock 77 $from "\001PING [clock clicks -milliseconds] $cname \001"
}
proc pubcoffee {cname msg} {
switch [expr {int(rand()*4)}] {
- 0 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of espresso\001"}
- 1 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of Latte\001"}
- 2 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of instant coffee\001"}
- 3 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of cappucino\001"}
+ 0 {p10 privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of espresso\001"}
+ 1 {p10 privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of Latte\001"}
+ 2 {p10 privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of instant coffee\001"}
+ 3 {p10 privmsg $::sock 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 {
- privmsg $::sock 77 $cname "\001ACTION packs a bowl of nugs and hands a bong to $payload\001"
+ p10 privmsg $::sock 77 $cname "\001ACTION packs a bowl of nugs and hands a bong to $payload\001"
}
1 {
- privmsg $::sock 77 $cname "\001ACTION rolls a joint and hands to $payload\001"
+ p10 privmsg $::sock 77 $cname "\001ACTION rolls a joint and hands to $payload\001"
}
2 {
- privmsg $::sock 77 $cname "\001ACTION fills the hookah with dried nugs and hands to $payload\001"
+ p10 privmsg $::sock 77 $cname "\001ACTION fills the hookah with dried nugs and hands to $payload\001"
}
3 {
- privmsg $::sock 77 $cname "\001ACTION passes $payload the vape pen\001"
+ p10 privmsg $::sock 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/$from"]
- 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)/$from"]
+ p10 privmsg $::sock 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 @@
-sendUid $::sock "W" "weather" "services." "services." 57 "Weather Services"
+p10 sendUid $::sock "W" "weather" "services." "services." 57 "Weather Services"
foreach {chan is} [nda get "weather/regchan"] {
if {1!=$is} {continue}
- putjoin $::sock 57 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+ p10 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"]
}
-bind request "w" "-" weatherjoin
-bind request "weather" "-" weatherjoin
+bind $::sock request "w" "-" weatherjoin
+bind $::sock request "weather" "-" weatherjoin
proc weatherjoin {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- putjoin $::sock 57 $chan [nda get "regchan/$ndacname/ts"]
+ p10 putjoin $::sock 57 $chan [nda get "regchan/$ndacname/ts"]
nda set "weather/regchan/$ndacname" 1
}
@@ -44,14 +44,14 @@ namespace eval wunderground {
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
- bind pub "-" [string trimleft $wunderground::cmdchar]weather wunderground::tclservwe
- bind pub "-" [string trimleft $wunderground::cmdchar]wz wunderground::tclservwe
- bind pub "-" [string trimleft $wunderground::cmdchar]forecast wunderground::tclservfc
+ 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
}
proc wunderground::tclservwe {cname msg} {
- set nick [tnda get "nick/[lindex $msg 0 0]"]
- set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/[lindex $msg 0 0]"]"
+ 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 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/[lindex $msg 0 0]"]
- set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/[lindex $msg 0 0]"]"
+ 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 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] != ""} {
- privmsg $::sock 57 $chan "${logo} ${textf}[string map {\\\" \"} [lindex $text $counter]]"
+ p10 privmsg $::sock 57 $chan "${logo} ${textf}[string map {\\\" \"} [lindex $text $counter]]"
}
incr counter
}
diff --git a/modules/0004-limitserv.tcl b/modules/0004-limitserv.tcl
@@ -1,39 +1,39 @@
-sendUid $::sock "L" "limitserv" "services." "services." 47 "Channel Limit Adjustment Services"
+p10 sendUid $::sock "L" "limitserv" "services." "services." 47 "Channel Limit Adjustment Services"
foreach {chan is} [nda get "limitserv/regchan"] {
if {1!=$is} {continue}
- putjoin $::sock 47 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+ p10 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"]
}
-bind request "l" "-" limitservjoin
-bind request "limitserv" "-" limitservjoin
-bind join "-" "-" limitservup
-bind part "-" "-" limitservdown
-bind pub "-" "!dolimit" limitservdochan
+bind $::sock request "l" "-" limitservjoin
+bind $::sock request "limitserv" "-" limitservjoin
+bind $::sock join "-" "-" limitservup
+bind $::sock part "-" "-" limitservdown
+bind $::sock pub "-" "!dolimit" limitservdochan
after 60000 {limitservdo}
proc limitservup {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- if {""==[tnda get "limitserv/$ndacname"]} {set i 1} {set i [expr {[tnda get "limitserv/$ndacname"] + 1}]}
- tnda set "limitserv/$ndacname" $i
+ 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
}
proc limitservdown {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- if {""==[tnda get "limitserv/$ndacname"]} {set i 0} {set i [expr {[tnda get "limitserv/$ndacname"] - 1}]}
- tnda set "limitserv/$ndacname" $i
+ 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
}
-proc limitservjoin {chan msg} {
+proc limitservjoin {chan ft} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- putjoin $::sock 47 $chan [nda get "regchan/$ndacname/ts"]
+ p10 putjoin $::sock 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}
- putmode $::sock 47 [::base64::decode [string map {[ /} $chan]] "+l" [expr {[tnda get "limitserv/$chan"] + 10}] [nda get "regchan/$chan/ts"]
+ p10 putmode $::sock 47 [::base64::decode [string map {[ /} $chan]] "+l" [expr {[tnda get "limitserv/$::netname($::sock)/$chan"] + 10}] [nda get "regchan/$chan/$::netname($::sock)/ts"]
}
after 60000 {limitservdo}
}
@@ -41,9 +41,9 @@ 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/$from"]]"]} {
- 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)/$from"]]"]} {
+ p10 privmsg $::sock 47 $cname "You must be at least halfop to manually trigger autolimit on the channel."
return
}
- putmode $::sock 47 $cname "+l" [expr {[tnda get "limitserv/$chan"] + 10}] [nda get "regchan/$chan/ts"]
+ p10 putmode $::sock 47 $cname "+l" [expr {[tnda get "limitserv/$::netname($::sock)/$chan"] + 10}] [nda get "regchan/$chan/$::netname($::sock)/ts"]
}
diff --git a/modules/0005-eggcompat.tcl b/modules/0005-eggcompat.tcl
@@ -1,3 +1,91 @@
+bind $::sock mode "-" "+" bitchopcheck
+bind $::sock mode "-" "-" protectopcheck
+bind $::sock join "-" "-" autoopcheck
+
+proc protectopcheck {mc ftp} {
+ set f [lindex $ftp 0 0]
+ set t [lindex $ftp 0 1]
+ set p [lindex $ftp 0 2]
+ if {"o"==$mc && ![channel get $t protectop]} {return}
+ if {"h"==$mc && ![channel get $t protecthalfop]} {return}
+ if {"v"==$mc && ![channel get $t protectvoice]} {return}
+ switch -- $mc {
+ "o" {
+ if {[matchattr [tnda get "login/$::netname($::sock)/$p"] |omn $t]} {
+ p10 putmode $::sock 77 $t +$mc "$p" [tnda get "channels/[ndaenc $t]/$::netname($::sock)/ts"]
+ }
+ }
+ "h" {
+ if {[matchattr [tnda get "login/$::netname($::sock)/$p"] |l $t]} {
+ p10 putmode $::sock 77 $t +$mc "$p" [tnda get "channels/[ndaenc $t]/$::netname($::sock)/ts"]
+ }
+ }
+ "v" {
+ if {[matchattr [tnda get "login/$::netname($::sock)/$p"] |v $t]} {
+ p10 putmode $::sock 77 $t +$mc "$p" [tnda get "channels/[ndaenc $t]/$::netname($::sock)/ts"]
+ }
+ }
+ }
+}
+
+proc autoopcheck {c ft} {
+ set f [lindex $ft 0];set t [lindex $ft 1]
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] omn|] && [channel get $c operit]} {
+ p10 putmode $::sock 77 $c +o $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |omn $c] && [channel get $c autoop]} {
+ p10 putmode $::sock 77 $c +o $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] l|] && [channel get $c operit]} {
+ p10 putmode $::sock 77 $c +h $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |l $c] && [channel get $c autohalfop]} {
+ p10 putmode $::sock 77 $c +h $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] v|] && [channel get $c operit]} {
+ p10 putmode $::sock 77 $c +v $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+ if {[matchattr [tnda get "login/$::netname($::sock)/$f"] |v $c] && [channel get $c autovoice]} {
+ p10 putmode $::sock 77 $c +v $f [tnda get "channels/[ndaenc $c]/$::netname($::sock)/ts"]
+ return
+ }
+}
+
+proc bitchopcheck {mc ftp} {
+ set f [lindex $ftp 0]
+ set t [lindex $ftp 1]
+ set p [lindex $ftp 2]
+ puts stdout "$ftp"
+ if {"o"==$mc && ![channel get $t bitch]} {return}
+ if {"h"==$mc && ![channel get $t halfbitch]} {return}
+ if {"v"==$mc && ![channel get $t voicebitch]} {return}
+ switch -glob -- $mc {
+ "o" {
+ if {![matchattr [tnda get "login/$::netname($::sock)/$p"] |omn $t]} {
+ puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
+ p10 putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ }
+ }
+ "h" {
+ if {![matchattr [tnda get "login/$::netname($::sock)/$p"] |l $t]} {
+ puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
+ p10 putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ }
+ }
+ "v" {
+ if {![matchattr [tnda get "login/$::netname($::sock)/$p"] |v $t]} {
+ puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]"
+ p10 putmode $::sock 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"]
+ }
+ }
+ }
+}
+
proc utimer {seconds tcl-command} {after [expr $seconds * 1000] ${tcl-command}}
proc timer {minutes tcl-command} {after [expr $minutes * 60 * 1000] ${tcl-command}}
proc utimers {} {set t {}; foreach a [after info] {lappend t "0 [lindex [after info $a] 0] $a"}; return $t}
@@ -31,58 +119,74 @@ proc ndadec {n} {
return [::base64::decode [string map {[ /} $n]]
}
+proc msgmt {from msg} {
+ set handle [lindex $msg 0 0]
+ set attr [lindex $msg 0 1]
+ set chan [lindex $msg 0 2]
+ p10 notice $::sock 77 $from "$handle $attr $chan Matchattr result: [matchattr $handle $attr $chan]"
+}
+
+bind $::sock msg 77 "matchattr" msgmt
+
proc matchattr {handle attr {chan "*"}} {
- if {$chan == "*"} {
- set isattr 0
- foreach {c} [split [nda get "eggcompat/attrs/global/$handle"] {}] {
- foreach {k} [split $attr {}] {
- if {$c == $k} {set isattr 1}
- }
+ set handle [string tolower $handle]
+ if {-1!=[string first "&" $attr]} {set and 1} {set and 0}
+ set gattr [lindex [split $attr "&|"] 0]
+ set cattr [lindex [split $attr "&|"] 1]
+ set isattrg 0
+ foreach {c} [split [nda get "eggcompat/attrs/global/$handle"] {}] {
+ foreach {k} [split $gattr {}] {
+ if {$c == $k} {set isattrg 1}
}
- } {
- set isattr 0
+ }
+ set isattrc 0
+ if {"*"!=$chan} {
foreach {c} [split [nda get "eggcompat/attrs/[ndaenc $chan]/$handle"] {}] {
- foreach {k} [split $attr {}] {
- if {$c == $k} {set isattr 1}
+ foreach {k} [split $cattr {}] {
+ if {$c == $k} {set isattrc 1}
}
}
}
- return $isattr
+ if {$and && ($isattrg == $isattrc) && ($isattrc == 1)} {return 1}
+ if {!$and && ($isattrg || $isattrc)} {return 1}
+ return 0
}
proc chattr {handle attr {chan "*"}} {
+ set handle [string tolower $handle]
if {$chan == "*"} {
+ set del [list]
+ set app ""
+ set state app
foreach {c} [split $attr {}] {
- switch -glob -- $c {
- "+" {set state app}
- "-" {set state del}
- "*" {
- if {$state=="del"} {
- lappend del $c ""
- }
- if {$state=="app"} {
- append app $c
- }
- }
+ if {"+"==$c} {set state app;continue}
+ if {"-"==$c} {set state del;continue}
+ if {$state=="del"} {
+ lappend del $c ""
+ }
+ if {$state=="app"} {
+ lappend del $c ""
+ append app $c
}
}
- nda set "eggcompat/attrs/global/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/global/$handle"] $app]] ""]
+ nda set "eggcompat/attrs/global/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/global/$handle"]] $app] ""]
} {
+ set del [list]
+ set app ""
+ set state app
foreach {c} [split $attr {}] {
- switch -glob -- $c {
- "+" {set state app}
- "-" {set state del}
- "*" {
- if {$state=="del"} {
- lappend del $c ""
- }
- if {$state=="app"} {
- append app $c
- }
- }
+ if {"+"==$c} {set state app;continue}
+ if {"-"==$c} {set state del;continue}
+ if {$state=="del"} {
+ lappend del $c ""
+ }
+ if {$state=="app"} {
+ lappend del $c ""
+ append app $c
}
}
- nda set "eggcompat/attrs/[ndaenc $chan]/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/[ndaenc $chan]/$handle"] $app]] ""]
+ puts stdout [ndaenc $chan]
+ nda set "eggcompat/attrs/[ndaenc $chan]/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/[ndaenc $chan]/$handle"]] $app] ""]
}
}
@@ -97,11 +201,20 @@ namespace eval channel {
proc ::channel::get {chan flag} {
if {[::set enda [nda get "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flag]]"]]!=""} {return $enda} {return 0}
}
- proc ::channel::set {chan flag} {
- ::set bit [string index $flag 0]
- if {$bit=="+"} {::set bitt 1} {::set bitt 0}
- ::set flag [string range $flag 1 end]
- return [nda set "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flag]]" $bitt]
+ proc ::channel::set {chan flags} {
+ if {[llength $flags] != 1} {
+ foreach {flag} $flags {
+ ::set bit [string index $flag 0]
+ if {$bit=="+"} {::set bitt 1} {::set bitt 0}
+ ::set flag [string range $flag 1 end]
+ nda set "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flag]]" $bitt
+ }
+ } {
+ ::set bit [string index $flags 0]
+ if {$bit=="+"} {::set bitt 1} {::set bitt 0}
+ ::set flag [string range $flags 1 end]
+ nda set "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flags]]" $bitt
+ }
}
namespace export *
namespace ensemble create
@@ -111,23 +224,55 @@ proc validuser {n} {
if {""==[nda get "usernames/$n"]} {return 0} {return 1}
}
-bind msg 77 "chanset" msgchanset
-bind msg 77 "setxtra" msgxtra
+bind $::sock msg 77 "chanset" msgchanset
+bind $::sock msg 77 "chattr" msgchattr
+bind $::sock 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"]]"]} {
- notice $::sock 77 $from "Only channel super-operators (300) and above may use eggdrop-compatible chansets."
+ 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]]} {
+ p10 notice $::sock 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
- notice $::sock 77 $from "Eggdrop compatible chanset $chanset set on [lindex $msg 0 0]."
+ p10 notice $::sock 77 $from "Eggdrop compatible chanset $chanset set on [lindex $msg 0 0]."
+}
+
+proc msgchattr {from msg} {
+ set ndacname [ndaenc [lindex $msg 0 2]]
+ set handle [lindex $msg 0 0]
+ set hand [lindex $msg 0 0]
+ set attrs [lindex $msg 0 1]
+ set chan [lindex $msg 0 2]
+ set ch [lindex $msg 0 2]
+ if {$chan==""} {
+ set chan "*"
+ set ch "global"
+ }
+ foreach {c} [split $attrs {}] {
+ if {$c == "+"} {continue}
+ if {$c == "-"} {continue}
+ if {$c == "v"} {set $c "mn|lmno"}
+ if {$c == "l"} {set $c "mn|mno"}
+ if {$c == "o"} {set $c "mn|omn"}
+ if {$c == "m"} {set $c "mn|mn"}
+ if {$c == "n"} {set $c "n|n"}
+ if {![matchattr [tnda get "login/$::netname($::sock)/$from"] $c $chan]} {
+ p10 notice $::sock 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}
+ p10 notice $::sock 77 $from "Global flags for $hand are now [nda get "eggcompat/attrs/global/[string tolower $handle]"]"
+ if {$ch != "global"} {p10 notice $::sock 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/$uid"]}
+ if {$nick == $nic} {return [tnda get "login/$::netname($::sock)/$uid"]}
}
}
@@ -140,14 +285,14 @@ proc setuser {nick datafield {dataval "body"} val} {
}
proc msgxtra {from msg} {
- if {[set log [tnda get "login/$from"]]==""} {
- 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)/$from"]]==""} {
+ p10 notice $::sock 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
- notice $::sock 77 $from "Set your user record XTRA $subfield to $value."
+ p10 notice $::sock 77 $from "Set your user record XTRA $subfield to $value."
}
proc chandname2name {channame} {return $channame}
diff --git a/modules/0006.disabled b/modules/0006.disabled
@@ -1,4 +0,0 @@
-#sendUid $::sock "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/0007-quote.tcl b/modules/0007-quote.tcl
@@ -1,17 +1,17 @@
-sendUid $::sock "Q" "quoteserv" "services." "services." 107 "Quote Storage Services"
+p10 sendUid $::sock "Q" "quoteserv" "services." "services." 107 "Quote Storage Services"
foreach {chan is} [nda get "quoteserv/regchan"] {
if {1!=$is} {continue}
- putjoin $::sock 107 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+ p10 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"]
}
-bind request "q" "-" quoteservjoin
-bind request "quoteserv" "-" quoteservjoin
-bind pub "-" "!quote" quoteservdo
-bind pub "-" "!q" quoteservdo
+bind $::sock request "q" "-" quoteservjoin
+bind $::sock request "quoteserv" "-" quoteservjoin
+bind $::sock pub "-" "!quote" quoteservdo
+bind $::sock pub "-" "!q" quoteservdo
proc quoteservjoin {chan msg} {
set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
- putjoin $::sock 107 $chan [nda get "regchan/$ndacname/ts"]
+ p10 putjoin $::sock 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]} {privmsg $::sock 107 $chan "\[\002Quotes\002\] Found quotes numbered #[join $qts ",#"]"} {
- privmsg $::sock 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
+ if {[llength $qts]} {p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Found quotes numbered #[join $qts ",#"]"} {
+ p10 privmsg $::sock 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];privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:";privmsg $::sock 107 $chan "\[\002Quotes\002\] [nda get "quoteserv/quotes/$ndacname/$qtn"]"} {
- privmsg $::sock 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
+ if {[llength $qts]} {set qtn [lindex $qts 0];p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:";p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] [nda get "quoteserv/quotes/$ndacname/$qtn"]"} {
+ p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] No quotes found for pattern"
}
}
"ad*" {
set qt [join $para " "]
- set qtn [expr {([llength [nda get "quoteserv/quotes/$ndacname"]]/2)+2}]
+ set qtn [expr {([llength [nda get "quoteserv/quotes/$ndacname"]]/2)+3}]
nda set "quoteserv/quotes/$ndacname/$qtn" $qt
- privmsg $::sock 107 $chan "\[\002Quotes\002\] Added quote number #$qtn to database."
+ p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Added quote number #$qtn to database."
}
"de*" {
set qtn "[lindex $para 0]"
- if {![string is integer $qtn]} {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/$from"]]"]} {privmsg $::sock 107 $chan "\[\002Quotes\002\] Check your privilege."}
+ if {![string is integer $qtn]} {p10 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"]]"]} {p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Check your privilege."}
nda set "quoteserv/quotes/$ndacname/$qtn" ""
- privmsg $::sock 107 $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database."
+ p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database."
}
"vi*" {
set qtn "[lindex $para 0]"
- if {![string is integer $qtn]} {privmsg $::sock 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
+ if {![string is integer $qtn]} {p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"}
set qt [nda get "quoteserv/quotes/$ndacname/$qtn"]
if {$qt != ""} {
- privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:"
- privmsg $::sock 107 $chan "\[\002Quotes\002\] $qt"
+ p10 privmsg $::sock 107 $chan "\[\002Quotes\002\] Quote number #$qtn:"
+ p10 privmsg $::sock 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"] {
- notice $::sock 107 $from $helpline
+ p10 notice $::sock 107 $from $helpline
}
}
}
diff --git a/modules/0008-relayserv.tcl b/modules/0008-relayserv.tcl
@@ -0,0 +1,15 @@
+# This is the fun part.
+
+$::maintype sendUid $::sock "R" "relay" "services." "services." 117 "Relay Services"
+bind $::sock 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}]}
+ return [tnda get "uids/relays/$relay"]
+}
+
+proc reqlinkmsg {from msg} {
+ return
+ # do nothing for now
+}
diff --git a/modules/bmotion.disabled b/modules/bmotion.disabled
@@ -0,0 +1,4 @@
+#p10 sendUid $::sock "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/trigserv.disabled b/modules/trigserv.disabled
@@ -3,7 +3,7 @@ sendUid $::sock "T" "trigserv" "services." "services." 37 "Channel Spam Reductio
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/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock)/ts"]
}
bind request "t" "-" trigservjoin
bind request "trigserv" "-" trigservjoin
@@ -33,7 +33,7 @@ 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/$from"]]"]} {
+ 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."
return
}
@@ -41,11 +41,11 @@ proc trigservdochan {cname msg} {
}
proc trigservdecay {target} {
- tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$target"] - 1}]
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock)/$::netname($::sock)/$target"] - 1}]
}
proc trigservincr {target} {
- tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$target"] + 1}]
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$::netname($::sock)/$::netname($::sock)/$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/$chan"]
+ puts stdout [tnda get "trigserv/flood/$::netname($::sock)/$chan"]
after [expr {[lindex $criterion 2] * 1000}] trigservdecay $chan
- if {[tnda get "trigserv/flood/$chan"] >= [lindex $criterion 1]} {
+ 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/ts"]
- after 60000 {putmode $::sock 37 [ndadec $chan] "-mi" "" [tnda get "channels/$chan/ts"]}
+ 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"]}
}
}
"cmd" {
if {$trigcmd == [lindex $criterion 1]} {
- privmsg $::sock 37 [ndadec $chan] [join [list "\002[tnda get "nick/$from"]\002:" $action] " "]
+ privmsg $::sock 37 [ndadec $chan] [join [list "\002[tnda get "nick/$::netname($::sock)/$from"]\002:" $action] " "]
}
}
}