chanserv.disabled (17590B)
1 $::maintype sendUid $::sock($::cs(netname)) $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server" 2 bind $::sock($::cs(netname)) msg 77 "register" regchan 3 bind $::sock($::cs(netname)) msg 77 "adduser" adduserchan 4 bind $::sock($::cs(netname)) msg 77 "users" lsuchan 5 bind $::sock($::cs(netname)) msg 77 "lsu" lsuchan 6 bind $::sock($::cs(netname)) msg 77 "convertop" convertop 7 #bind $::sock($::cs(netname)) msg 77 "deluser" deluserchan 8 bind $::sock($::cs(netname)) msg 77 "up" upchan 9 bind $::sock($::cs(netname)) pub "-" "@up" upchanfant 10 bind $::sock($::cs(netname)) pub "-" "@rand" randfant 11 bind $::sock($::cs(netname)) pub "-" "@request" requestbot 12 bind $::sock($::cs(netname)) msg 77 "down" downchan 13 bind $::sock($::cs(netname)) msg 77 "hello" regnick 14 bind $::sock($::cs(netname)) msg 77 "chpass" chpassnick 15 bind $::sock($::cs(netname)) msg 77 "login" idnick 16 bind $::sock($::cs(netname)) msg 77 "help" chanhelp 17 bind $::sock($::cs(netname)) msg 77 "topic" chantopic 18 bind $::sock($::cs(netname)) msg 77 "cookie" authin 19 bind $::sock($::cs(netname)) msg 77 "cauth" cookieauthin 20 bind $::sock($::cs(netname)) mode "-" "+" checkop 21 bind $::sock($::cs(netname)) mode "-" "-" checkdeop 22 bind $::sock($::cs(netname)) topic "-" "-" checktopic 23 bind $::sock($::cs(netname)) create "-" "-" checkcreate 24 25 proc checktopic {chan topic} { 26 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 27 if {[channel get $chan topiclock]} {$::maintype topic $::sock($::cs(netname)) 77 "$chan" "[nda get "regchan/$ndacname/topic"]"} 28 } 29 30 proc chantopic {from msg} { 31 set cname [lindex $msg 0 0] 32 set topic [join [lrange [lindex $msg 0] 1 end] " "] 33 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 34 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 35 if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] lmno|lmno $cname]} { 36 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You must be at least halfop to change the stored channel topic." 37 return 38 } 39 nda set "regchan/$ndacname/topic" "$topic" 40 $::maintype topic $::sock($::cs(netname)) 77 "$cname" "$topic" 41 $::maintype privmsg $::sock($::cs(netname)) 77 "$cname" "[tnda get "nick/$::netname($::sock($::cs(netname)))/$from"] ([tnda get "login/$::netname($::sock($::cs(netname)))/$from"]) changed topic." 42 } 43 44 proc authin {from msg} { 45 set uname [lindex $msg 0 0] 46 if {[string first "/" $uname] != -1} {return} 47 $::maintype notice $::sock($::cs(netname)) 77 $from "CHALLENGE [set cookie [b64e [rand 1000000000 9999999999]]] SHA1" 48 tnda set "cookieauth/$from/cookie" $cookie 49 tnda set "cookieauth/$from/name" "$uname" 50 } 51 52 proc cookieauthin {from msg} { 53 set uname [lindex $msg 0 0] 54 set response [lindex $msg 0 1] 55 if {[string first "/" $uname] != -1} {return} 56 if {$response == ""} {return} 57 set checkresp "[tnda get "cookieauth/$from/name"]:[nda get "usernames/[string tolower $uname]/password"]:[tnda get "cookieauth/$from/cookie"]" 58 set isresp [pwhash "$checkresp"] 59 puts stdout "$response $isresp $checkresp" 60 if {$response == $isresp} { 61 $::maintype notice $::sock($::cs(netname)) 77 $from "You have successfully logged in as $uname." 62 $::maintype setacct $::sock($::cs(netname)) $from $uname 63 callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname 64 } { 65 $::maintype notice $::sock($::cs(netname)) 77 $from "You used the wrong password; try again." 66 } 67 } 68 69 proc randfant {cname msg} { 70 set from [lindex $msg 0 0] 71 set froni [tnda get "nick/$::netname($::sock($::cs(netname)))/$from"] 72 if {![string is integer [lindex $msg 1 0]] ||![string is integer [lindex $msg 1 1]]} {return} 73 if {(""==[lindex $msg 1 0]) || (""==[lindex $msg 1 1])} {return} 74 if {[lindex $msg 1 0] == [lindex $msg 1 1]} {$::maintype privmsg $::sock($::cs(netname)) 77 $cname "\002$froni:\002 Your request would have caused a divide by zero and was not processed.";return} 75 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "\002$froni:\002 Your die rolled [rand [lindex $msg 1 0] [lindex $msg 1 1]]" 76 } 77 78 proc lsuchan {from msg} { 79 set cname [lindex $msg 0 0] 80 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 81 if {[string length [nda get "regchan/$ndacname"]] == 0} { 82 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 83 $::maintype notice $::sock($::cs(netname)) 77 $from "Channel does not exist." 84 return 85 } 86 set xses [nda get "regchan/$ndacname/levels"] 87 $::maintype notice $::sock($::cs(netname)) 77 $from "Access | Flags | Username" 88 $::maintype notice $::sock($::cs(netname)) 77 $from "-------+------------------" 89 foreach {nick lev} $xses { 90 if {$lev == 0} {continue} 91 # Case above? User not actually on access list 92 set nl [format "%3d" $lev] 93 set repeats [string repeat " " [expr {6-[string length [nda get "eggcompat/attrs/$ndacname/$nick"]]}]] 94 $::maintype notice $::sock($::cs(netname)) 77 $from " $nl | $repeats[string range [nda get "eggcompat/attrs/$ndacname/$nick"] 0 5] | $nick" 95 } 96 $::maintype notice $::sock($::cs(netname)) 77 $from "-------+------------------" 97 $::maintype notice $::sock($::cs(netname)) 77 $from " | End of access list" 98 } 99 100 proc upchanfant {cname msg} { 101 set from [lindex $msg 0 0] 102 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 103 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 104 if {(1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]) && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] aolvmn|olvmn $cname]} { 105 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You fail at life." 106 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "Channel not registered to you." 107 return 108 } 109 set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] 110 set sm "+" 111 set st "" 112 if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} { 113 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |v $cname]} {set sm v} 114 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]} 115 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |o $cname]} {set sm o} 116 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]} 117 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]} 118 } { 119 if {$lev >= 1} {set sm "v"; append st "v"} 120 if {$lev >= 150} {set sm "h"; append st "l"} 121 if {$lev >= 200} {set sm "o"; append st "o"} 122 if {$lev >= 300} {append st "m"} 123 if {$lev >= 500} {append st "n"} 124 chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +$st $cname 125 } 126 $::maintype putmode $::sock($::cs(netname)) 77 $cname +$sm $from [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"] 127 } 128 129 proc convertop {from msg} { 130 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 131 set cname [lindex $msg 0 0] 132 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 133 if {500>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} { 134 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 135 $::maintype notice $::sock($::cs(netname)) 77 $from "You must be the founder to request an oplevel-to-flags conversion." 136 return 137 } 138 foreach {login lev} [nda get "regchan/$ndacname/levels"] { 139 set st "" 140 if {$lev >= 1} {append st "v"} 141 if {$lev >= 150} {append st "l"} 142 if {$lev >= 200} {append st "o"} 143 if {$lev >= 300} {append st "m"} 144 if {$lev >= 500} {append st "n"} 145 chattr $login +$st $cname 146 } 147 $::maintype notice $::sock($::cs(netname)) 77 $from "Converted all access levels to flags." 148 lsuchan $from $msg 149 } 150 151 proc requestbot {cname msg} { 152 set from [lindex $msg 0 0] 153 set bot [lindex $msg 1 0] 154 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 155 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 156 if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] lmno|lmno $cname]} { 157 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You fail at life." 158 $::maintype privmsg $::sock($::cs(netname)) 77 $cname "You must be at least halfop to request $bot." 159 return 160 } 161 callbind $::sock($::cs(netname)) request [string tolower $bot] "-" $cname 162 } 163 164 foreach {chan _} [nda get "regchan"] { 165 $::maintype putjoin $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] 166 tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"] 167 $::maintype putmode $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] "+o" $::cs(nick) [nda get "regchan/$chan/ts"] 168 $::maintype putmode $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] "+nt" "" [nda get "regchan/$chan/ts"] 169 if {[channel get [::base64::decode [string map {[ /} $chan]] topiclock]} {$::maintype topic $::sock($::cs(netname)) 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/topic"]} 170 } 171 172 proc checkop {mc ftp} { 173 set f [lindex $ftp 0 0] 174 set t [lindex $ftp 0 1] 175 set p [lindex $ftp 0 2] 176 if {"o"!=$mc} {return} 177 set chan [string map {/ [} [::base64::encode [string tolower $t]]] 178 tnda set "channels/$chan/modes/$p" "[tnda get "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$p"]o" 179 } 180 181 proc checkcreate {mc ftp} { 182 set chan [string map {/ [} [::base64::encode [string tolower $mc]]] 183 tnda set "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$ftp" "o" 184 puts stdout "channels/$chan/modes/$ftp" 185 } 186 187 proc checkdeop {mc ftp} { 188 set f [lindex $ftp 0 0] 189 set t [lindex $ftp 0 1] 190 set p [lindex $ftp 0 2] 191 if {"o"!=$mc} {return} 192 set chan [string map {/ [} [::base64::encode [string tolower $t]]] 193 tnda set "channels/$chan/modes/$p" [string map {o ""} [tnda get "channels/$chan/modes/$::netname($::sock($::cs(netname)))/$::netname($::sock($::cs(netname)))/$p"]] 194 } 195 196 proc chanhelp {from msg} { 197 set fp [open ./chanserv.help r] 198 set data [split [read $fp] "\r\n"] 199 close $fp 200 foreach {line} $data { 201 $::maintype notice $::sock($::cs(netname)) 77 $from "$line" 202 } 203 } 204 205 proc regchan {from msg} { 206 putcmdlog "$from $msg regchan" 207 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 208 set cname [lindex $msg 0 0] 209 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 210 if {[string length [nda get "regchan/$ndacname"]] != 0} { 211 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 212 $::maintype notice $::sock($::cs(netname)) 77 $from "Channel already exists." 213 return 214 } 215 if {-1==[string first "o" [ts6 getpfx $::netname($::sock($::cs(netname))) $cname [ts6 uid2nick $::cs(netname) $from]]]} { 216 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 217 $::maintype notice $::sock($::cs(netname)) 77 $from "You are not an operator. [ts6 getpfx $::netname($::sock($::cs(netname))) $cname [ts6 uid2nick $::cs(netname) $from]]" 218 return 219 } 220 $::maintype notice $::sock($::cs(netname)) 77 $from "Guess what? :)" 221 nda set "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]" 500 222 nda set "regchan/$ndacname/ts" [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"] 223 $::maintype putjoin $::sock($::cs(netname)) 77 $cname [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"] 224 chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +mno $cname 225 callbind $::sock($::cs(netname)) "reg" "-" "-" $cname [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"] 226 } 227 228 proc adduserchan {from msg} { 229 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 230 set cname [lindex $msg 0 0] 231 set adduser [lindex $msg 0 1] 232 set addlevel [lindex $msg 0 2] 233 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 234 if {![string is integer $addlevel]} {return} 235 if {$addlevel > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't do that; you're not the channel's Dave";return} 236 if {[nda get "regchan/$ndacname/levels/$adduser"] > [nda get "regchan/$ndacname/levels/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't do that; the person you're changing the level of is more like Dave than you.";return} 237 if {$adduser == [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You can't change your own level, even if you're downgrading. Sorreh :/";return} 238 $::maintype notice $::sock($::cs(netname)) 77 $from "Guess what? :) User added." 239 nda set "regchan/$ndacname/levels/[string tolower $adduser]" $addlevel 240 } 241 242 proc upchan {from msg} { 243 puts stdout [nda get regchan] 244 if {""==[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]} {$::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life.";return} 245 set cname [lindex $msg 0 0] 246 set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]] 247 if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] && ![matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] aolvmn|olvmn $cname]} { 248 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 249 $::maintype notice $::sock($::cs(netname)) 77 $from "Channel not registered to you." 250 return 251 } 252 set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"] 253 set sm "+" 254 set st "" 255 if {""!=[nda get "eggcompat/attrs/$ndacname/[tnda get "login/$::netname($::sock($::cs(netname)))/$from"]"]} { 256 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |v $cname]} {set sm v} 257 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |l $cname]} {set sm [tnda get "pfx/halfop"]} 258 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |o $cname]} {set sm o} 259 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |m $cname]} {set sm [tnda get "pfx/protect"]} 260 if {[matchattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] |n $cname]} {set sm [tnda get "pfx/owner"]} 261 } { 262 if {$lev >= 1} {set sm "v"; append st "v"} 263 if {$lev >= 150} {set sm "h"; append st "l"} 264 if {$lev >= 200} {set sm "o"; append st "o"} 265 if {$lev >= 300} {append st "m"} 266 if {$lev >= 500} {append st "n"} 267 chattr [tnda get "login/$::netname($::sock($::cs(netname)))/$from"] +$st $cname 268 } 269 $::maintype putmode $::sock($::cs(netname)) 77 $cname +$sm $from [tnda get "channels/$::netname($::sock($::cs(netname)))/$ndacname/ts"] 270 } 271 272 proc regnick {from msg} { 273 set uname [lindex $msg 0 0] 274 if {[string first "/" $uname] != -1} {return} 275 set pw [lindex $msg 0 1] 276 if {""!=[nda get "usernames/[string tolower $uname]"]} { 277 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 278 $::maintype notice $::sock($::cs(netname)) 77 $from "Account already exists; try LOGIN" 279 return 280 } 281 nda set "usernames/[string tolower $uname]/password" [pwhash $pw] 282 $::maintype setacct $::sock($::cs(netname)) $from $uname 283 callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname 284 } 285 286 proc chpassnick {from msg} { 287 set uname [lindex $msg 0 0] 288 if {[string first "/" $uname] != -1} {return} 289 set pw [lindex $msg 0 1] 290 set newpw [lindex $msg 0 2] 291 set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"] 292 set ispw [pwhash $pw] 293 294 if {$ispw != [nda get "usernames/[string tolower $uname]/password"]} { 295 $::maintype notice $::sock($::cs(netname)) 77 $from "You fail at life." 296 $::maintype notice $::sock($::cs(netname)) 77 $from "Wrong pass." 297 return 298 } 299 nda set "usernames/[string tolower $uname]/password" [pwhash $newpw] 300 $::maintype notice $::sock($::cs(netname)) 77 $from "Password changed." 301 } 302 303 proc idnick {from msg} { 304 set uname [lindex $msg 0 0] 305 if {[string first "/" $uname] != -1} {return} 306 set pw [lindex $msg 0 1] 307 set checkpw [split [nda get "usernames/[string tolower $uname]/password"] "/"] 308 set ispw [pwhash $pw] 309 if {$ispw == [nda get "usernames/[string tolower $uname]/password"]} { 310 $::maintype notice $::sock($::cs(netname)) 77 $from "You have successfully logged in as $uname." 311 $::maintype setacct $::sock($::cs(netname)) $from $uname 312 callbind $::sock($::cs(netname)) evnt "-" "login" $from $uname 313 } { 314 $::maintype notice $::sock($::cs(netname)) 77 $from "You cannot log in as $uname. You have the wrong password." 315 } 316 }