nope.egg.nope (14007B)
1 #source chanserv.conf 2 3 #bind $::sock($::cs(netname)) mode "-" "+" bitchopcheck 4 #bind $::sock($::cs(netname)) mode "-" "-" protectopcheck 5 #bind $::sock($::cs(netname)) join "-" "-" autoopcheck 6 7 proc protectopcheck {mc f t p} { 8 if {"o"==$mc && ![channel get $t protectop]} {return} 9 if {"h"==$mc && ![channel get $t protecthalfop]} {return} 10 if {"v"==$mc && ![channel get $t protectvoice]} {return} 11 switch -- $mc { 12 "o" { 13 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] omn|omn $t]} { 14 $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"] 15 } 16 } 17 "h" { 18 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] l|l $t]} { 19 $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"] 20 } 21 } 22 "v" { 23 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] v|v $t]} { 24 $::maintype putmode $::sock($::cs(netname)) 77 $t +$mc "$p" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $t]/ts"] 25 } 26 } 27 } 28 } 29 30 proc finduserbyid {n} { 31 tnda get "login/$::netname($::sock($::cs(netname)))/$f" 32 } 33 34 proc autoopcheck {c f} { 35 set globe 0 36 if {[channel get $c operit]} {set globe 1} 37 if {[channel get $c autoop]} {set auto nmo} {set auto ""} 38 if {[channel get $c autohalfop]} {append auto l} 39 if {[channel get $c autovoice]} {append auto v} 40 tcs:opcheck $c $f $globe $auto 41 } 42 43 proc tcs:opcheck {c f {globe 0} {auto nmolv}} { 44 # puts stdout "$c $f" 45 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |k $c]} { 46 # obviously optimised for charybdis... ??? 47 $::maintype putmode $::sock($::cs(netname)) 77 $c +b "*![tnda get "ident/$::netname($::sock($::cs(netname)))/$f"]@[tnda get "vhost/$::netname($::sock($::cs(netname)))/$f"]" [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 48 $::maintype kick $::sock($::cs(netname)) 77 $c $f "Autokicked (+k attribute)" 49 return 50 } 51 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] n|] && $globe} { 52 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 53 return 54 } 55 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |n $c] && ([string first "o" $auto] != -1)} { 56 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/owner"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 57 return 58 } 59 60 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] m|] && $globe} { 61 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 62 return 63 } 64 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |m $c] && ([string first "o" $auto] != -1)} { 65 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/protect"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 66 return 67 } 68 69 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] a|]} { 70 $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 71 return 72 } 73 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] o|] && $globe} { 74 $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 75 return 76 } 77 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |o $c] && ([string first "o" $auto] != -1)} { 78 $::maintype putmode $::sock($::cs(netname)) 77 $c +o $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 79 return 80 } 81 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] l|] && $globe} { 82 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 83 return 84 } 85 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |l $c] && ([string first "h" $auto] != -1)} { 86 $::maintype putmode $::sock($::cs(netname)) 77 $c +[tnda get "pfx/halfop"] $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 87 return 88 } 89 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] v|] && $globe} { 90 $::maintype putmode $::sock($::cs(netname)) 77 $c +v $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 91 return 92 } 93 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$f"] |v $c] && ([string first "v" $auto] != -1)} { 94 $::maintype putmode $::sock($::cs(netname)) 77 $c +v $f [tnda get "channels/$::netname($::sock($::cs(netname)))/[ndaenc $c]/ts"] 95 return 96 } 97 } 98 99 proc bitchopcheck {mc ftp} { 100 set f [lindex $ftp 0] 101 set t [lindex $ftp 1] 102 set p [lindex $ftp 2] 103 puts stdout "$ftp" 104 if {[tnda get "pfx/owner"]==$mc && ![channel get $t bitch]} {return} {if {[tnda get "pfx/owner"] != q} {set mc q}} 105 if {[tnda get "pfx/protect"]==$mc && ![channel get $t bitch]} {return} {if {[tnda get "pfx/protect"] != a} set mc a}} 106 if {"o"==$mc && ![channel get $t bitch]} {return} 107 if {"h"==$mc && ![channel get $t halfbitch]} {return} 108 if {"v"==$mc && ![channel get $t voicebitch]} {return} 109 switch -glob -- $mc { 110 "q" { 111 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] n|n $t]} { 112 puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]" 113 $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"] 114 } 115 } 116 "a" { 117 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] mn|mn $t]} { 118 puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]" 119 $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"] 120 } 121 } 122 "o" { 123 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] aomn|omn $t]} { 124 puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]" 125 $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"] 126 } 127 } 128 "h" { 129 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] l|l $t]} { 130 puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]" 131 $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"] 132 } 133 } 134 "v" { 135 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$p"] v|v $t]} { 136 puts stdout "M $t -$mc $p [nda get "regchan/[ndaenc $t]/ts"]" 137 $::maintype putmode $::sock($::cs(netname)) 77 $t "-$mc" "$p" [nda get "regchan/[ndaenc $t]/ts"] 138 } 139 } 140 } 141 } 142 143 proc utimer {seconds tcl-command} {after [expr $seconds * 1000] ${tcl-command}} 144 proc timer {minutes tcl-command} {after [expr $minutes * 60 * 1000] ${tcl-command}} 145 proc utimers {} {set t {}; foreach a [after info] {lappend t "0 [lindex [after info $a] 0] $a"}; return $t} 146 proc timers {} {set t {}; foreach a [after info] {lappend t "0 [lindex [after info $a] 0] $a"}; return $t} 147 proc killtimer id {return [after cancel $id]} 148 proc killutimer id {return [after cancel $id]} 149 150 proc isbotnick {n} {return [expr {$n == $::botnick}]} 151 152 153 set globctx "" 154 155 proc setctx {ctx} { 156 global globctx 157 if {[catch [list set ::sock($ctx)] erre] > 0} {return} ; # silently crap out 158 set globctx $ctx 159 } 160 161 proc curctx {type} { 162 if {$::globctx == ""} {return ""} 163 switch -exact -- [format ".%s" [string tolower $type]] { 164 .sock { 165 return $::sock($::globctx) 166 } 167 .net { 168 return $::globctx 169 } 170 .proto { 171 return $::nettype($::globctx) 172 } 173 } 174 } 175 176 foreach {pname} [list putserv puthelp putquick putnow] { 177 proc $pname {msg} { 178 puts [curctx sock] [[curctx proto] formprefix [curctx net] $msg] 179 } 180 } 181 182 proc msgmt {from msg} { 183 set handle [lindex $msg 0] 184 set attr [lindex $msg 1] 185 set chan [lindex $msg 2] 186 $::maintype notice $::sock($::cs(netname)) 77 $from "$handle $attr $chan Matchattr result: [matchattr $handle $attr $chan]" 187 } 188 189 #bind $::sock($::cs(netname)) msg 77 "matchattr" msgmt 190 191 proc matchattr {handle attr {chan "*"}} { 192 set handle [string tolower $handle] 193 if {-1!=[string first "&" $attr]} {set and 1} {set and 0} 194 set gattr [lindex [split $attr "&|"] 0] 195 set cattr [lindex [split $attr "&|"] 1] 196 set isattrg 0 197 foreach {c} [split [nda get "eggcompat/attrs/global/$handle"] {}] { 198 foreach {k} [split $gattr {}] { 199 if {$c == $k} {set isattrg 1} 200 } 201 } 202 set isattrc 0 203 if {"*"!=$chan} { 204 foreach {c} [split [nda get "eggcompat/attrs/[ndaenc $chan]/$handle"] {}] { 205 foreach {k} [split $cattr {}] { 206 if {$c == $k} {set isattrc 1} 207 } 208 } 209 } 210 if {$and && ($isattrg == $isattrc) && ($isattrc == 1)} {return 1} 211 if {!$and && ($isattrg || $isattrc)} {return 1} 212 return 0 213 } 214 215 proc chattr {handle attr {chan "*"}} { 216 set handle [string tolower $handle] 217 if {$chan == "*"} { 218 set del [list] 219 set app "" 220 set state app 221 foreach {c} [split $attr {}] { 222 if {"+"==$c} {set state app;continue} 223 if {"-"==$c} {set state del;continue} 224 if {$state=="del"} { 225 lappend del $c "" 226 } 227 if {$state=="app"} { 228 lappend del $c "" 229 append app $c 230 } 231 } 232 nda set "eggcompat/attrs/global/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/global/$handle"]] $app] ""] 233 } { 234 set del [list] 235 set app "" 236 set state app 237 foreach {c} [split $attr {}] { 238 if {"+"==$c} {set state app;continue} 239 if {"-"==$c} {set state del;continue} 240 if {$state=="del"} { 241 lappend del $c "" 242 } 243 if {$state=="app"} { 244 lappend del $c "" 245 append app $c 246 } 247 } 248 puts stdout [ndaenc $chan] 249 nda set "eggcompat/attrs/[ndaenc $chan]/$handle" [join [concat [string map $del [nda get "eggcompat/attrs/[ndaenc $chan]/$handle"]] $app] ""] 250 } 251 } 252 253 proc channels {} { 254 foreach {chan _} [nda get "regchan"] { 255 lappend ret $chan 256 } 257 return $ret 258 } 259 260 namespace eval channel { 261 proc ::channel::get {chan flag} { 262 if {[::set enda [nda get "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flag]]"]]!=""} {return $enda} {return 0} 263 } 264 proc ::channel::set {chan flags} { 265 if {[llength $flags] != 1} { 266 foreach {flag} $flags { 267 ::set bit [string index $flag 0] 268 if {$bit=="+"} {::set bitt 1} {::set bitt 0} 269 ::set flag [string range $flag 1 end] 270 nda set "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flag]]" $bitt 271 } 272 } { 273 ::set bit [string index $flags 0] 274 if {$bit=="+"} {::set bitt 1} {::set bitt 0} 275 ::set flag [string range $flags 1 end] 276 nda set "eggcompat/chansets/[ndaenc $chan]/[ndaenc [string map {+ ""} $flags]]" $bitt 277 } 278 } 279 namespace export * 280 namespace ensemble create 281 } 282 283 proc validuser {n} { 284 if {""==[nda get "usernames/$n"]} {return 0} {return 1} 285 } 286 287 #bind $::sock($::cs(netname)) msg 77 "chanset" msgchanset 288 #bind $::sock($::cs(netname)) msg 77 "chattr" msgchattr 289 #bind $::sock($::cs(netname)) msg 77 "setxtra" msgxtra 290 #set botnick $cs(nick) 291 #chattr $cs(admin) +mnolv 292 293 proc msgchanset {from msg} { 294 set ndacname [ndaenc [lindex $msg 0 0]] 295 set chanset [lindex $msg 0 1] 296 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]]} { 297 $::maintype notice $::sock($::cs(netname)) 77 $from "Only channel super-operators (300) and above and network masters may use eggdrop-compatible chansets." 298 return 299 } 300 channel set [lindex $msg 0 0] $chanset 301 $::maintype notice $::sock($::cs(netname)) 77 $from "Eggdrop compatible chanset $chanset set on [lindex $msg 0 0]." 302 } 303 304 proc msgchattr {from msg} { 305 set ndacname [ndaenc [lindex $msg 0 2]] 306 set handle [lindex $msg 0 0] 307 set hand [lindex $msg 0 0] 308 set attrs [lindex $msg 0 1] 309 set chan [lindex $msg 0 2] 310 set ch [lindex $msg 0 2] 311 foreach {c} [split $attrs {}] { 312 if {$c == "+"} {continue} 313 if {$c == "-"} {continue} 314 if {$c == "k"} {set c "mn|mnol"} 315 if {$c == "v"} {set c "mn|lmno"} 316 if {$c == "l"} {set c "mn|mno"} 317 if {$c == "o"} {set c "mn|omn"} 318 if {$c == "m"} {set c "mn|mn"} 319 if {$c == "n"} {set c "n|n"} 320 if {$c == "a"} {set c "mn|"} 321 if {![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] $c $chan]} { 322 $::maintype notice $::sock($::cs(netname)) 77 $from "You may only give flags you already possess (Any of flags $c required to set $attrs)." 323 return 324 } 325 } 326 if {""==$chan} {chattr $hand $attrs} {chattr $hand $attrs $chan} 327 $::maintype notice $::sock($::cs(netname)) 77 $from "Global flags for $hand are now [nda get "eggcompat/attrs/global/[string tolower $handle]"]" 328 if {""==[nda get "regchan/$ndacname/levels/[string tolower $hand]"]} {nda set "regchan/$ndacname/levels/[string tolower $hand]" 1} 329 if {$ch != ""} {$::maintype notice $::sock($::cs(netname)) 77 $from "Flags on $chan for $hand are now [nda get "eggcompat/attrs/$ndacname/[string tolower $handle]"]"} 330 } 331 332 proc nick2hand {nick} { 333 foreach {uid nic} [tnda get "nick"] { 334 if {$nick == $nic} {return [tnda get "login/$::netname($::sock($::cs(netname)))/$uid"]} 335 } 336 } 337 338 proc getuser {nick datafield {dataval "body"}} { 339 return [nda get "usernames/$nick/setuser/[ndaenc $datafield]/[ndaenc $dataval]"] 340 } 341 342 proc setuser {nick datafield {dataval "body"} val} { 343 return [nda set "usernames/$nick/setuser/[ndaenc $datafield]/[ndaenc $dataval]" $val] 344 } 345 346 proc msgxtra {from msg} { 347 if {[set log [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]==""} { 348 $::maintype notice $::sock($::cs(netname)) 77 $from "Until you've registered with the bot, you have no business setting XTRA values." 349 return 350 } 351 set subfield [lindex $msg 0 0] 352 set value [join [lrange [lindex $msg 0] 1 end] " "] 353 setuser $log "XTRA" $subfield $value 354 $::maintype notice $::sock($::cs(netname)) 77 $from "Set your user record XTRA $subfield to $value." 355 } 356 357 proc chandname2name {channame} {return $channame} 358 proc channame2dname {channame} {return $channame} 359 360 proc islinked {bot} {return 0}