/usr/lib/sbnc/scripts/account.tcl is in sbnc-tcl 1.2-25.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | # shroudBNC - an object-oriented framework for IRC
# Copyright (C) 2005 Gunnar Beutner
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# configuration variables: ::account354
foreach user [split $::account354] {
setctx $user
bind join - * auth:join
bind raw - 315 auth:raw315
bind raw - 354 auth:raw354
bind evnt - init-server auth:connect
}
internaltimer 180 1 auth:pulse 180
internaltimer 240 1 auth:pulse 240
proc auth:connect {type} {
namespace eval [getns] {
if {![info exists inwho]} { set inwho 0 }
if {![info exists accounttimer]} { set accounttimer 0 }
if {![info exists accountwait]} { set accountwait 0 }
if {![info exists authchans]} { set authchans {} }
}
upvar [getns]::inwho inwho
upvar [getns]::accounttimer accounttimer
upvar [getns]::accountwait accountwait
upvar [getns]::authchans authchans
set inwho 0
set authchans [list]
set accounttimer 0
set accountwait 0
internalkilltimer auth:jointimer [getctx]
}
proc auth:join {nick host hand chan} {
namespace eval [getns] {
if {![info exists inwho]} { set inwho 0 }
if {![info exists whonicks]} { set whonicks {} }
if {![info exists accounttimer]} { set accounttimer 0 }
if {![info exists accountwait]} { set accountwait 0 }
}
upvar [getns]::inwho inwho
upvar [getns]::accounttimer accounttimer
upvar [getns]::accountwait accountwait
if {[isbotnick $nick]} {
auth:enqueuewho $chan
} else {
set account [getchanlogin $nick]
if {$account == ""} {
if {$accounttimer != 0} {
incr accountwait
if {$accountwait > 2} {
return
}
}
internalkilltimer auth:jointimer [getctx]
internaltimer 3 0 auth:jointimer [getctx]
set accounttimer 1
} else {
bncsettag $chan $nick account $account
sbnc:callbinds "account" - $chan "$chan $host" $nick $host $hand $chan
}
}
}
proc auth:enqueuewho {names} {
namespace eval [getns] {
if {![info exists authchans]} { set authchans [list] }
if {![info exists inwho]} { set inwho 0 }
}
upvar [getns]::authchans authchans
upvar [getns]::inwho inwho
set current [list]
set outnames [list]
foreach cur $authchans {
foreach item [split $cur ","] {
lappend current [string tolower $item]
}
}
set allowedchans [split [string tolower [getbncuser [getctx] tag whochans]] ","]
foreach name [split $names ","] {
set name [string tolower $name]
if {[llength $allowedchans] == 0 || ([string first [string index $name 0] [getisupport CHANTYPES]] == -1 || [lsearch -exact $allowedchans $name] != -1)} {
if {[lsearch -exact $current $name] == -1} {
lappend outnames $name
}
}
}
if {[llength $outnames] == 0} { return }
if {$inwho} {
lappend authchans [join $outnames ","]
} else {
set inwho 1
puthelp "WHO [join $outnames ","] n%nat,23"
}
}
proc auth:dequeuewho {} {
namespace eval [getns] {
if {![info exists authchans]} { set authchans [list] }
}
upvar [getns]::authchans authchans
set chan [lindex $authchans 0]
set authchans [lrange $authchans 1 end]
if {$chan == ""} { return }
set result [list]
foreach item [split $chan] {
set account [getchanlogin $item]
if {$account != "" && $account != 0} {
lappend result $item
}
}
return $result
}
proc auth:raw315 {source raw text} {
namespace eval [getns] {
if {![info exists inwho]} { set inwho 0 }
}
upvar [getns]::inwho inwho
if {$inwho} {
haltoutput
}
set chan [auth:dequeuewho]
if {$chan != ""} {
puthelp "WHO $chan n%nat,23"
set inwho 1
} else {
set inwho 0
}
}
proc auth:raw354 {source raw text} {
set pieces [split $text]
if {[lindex $pieces 1] != 23} { return }
set nick [lindex $pieces 2]
set site [getchanhost $nick]
set host [lindex $pieces 2]!$site
set hand [finduser $host]
haltoutput
foreach chan [internalchannels] {
if {[onchan $nick $chan]} {
set old [bncgettag $chan $nick account]
bncsettag $chan $nick account [lindex $pieces 3]
if {$old == "" || ($old == 0 && [lindex $pieces 3] != 0)} {
sbnc:callbinds "account" - $chan "$chan $host" $nick $site $hand $chan
}
}
}
}
# it's possible that the same nick gets /who'd twice (during the same call of auth:jointimer). fix?
proc auth:jointimer {context} {
setctx $context
namespace eval [getns] {
if {![info exists accounttimer]} { set accounttimer 0 }
if {![info exists accountwait]} { set accountwait 0 }
if {![info exists inwho]} { set inwho 0 }
}
upvar [getns]::accounttimer accounttimer
upvar [getns]::accountwait accountwait
upvar [getns]::inwho inwho
set accounttimer 0
set accountwait 0
set nicks ""
foreach chan [internalchannels] {
foreach nick [internalchanlist $chan] {
if {[bncgettag $chan $nick account] == ""} {
lappend nicks $nick
}
set l [join [sbnc:uniq $nicks] ","]
if {[string length $l] > 350} {
auth:enqueuewho $l
set nicks [list]
}
}
}
if {$nicks != ""} {
auth:enqueuewho [join [sbnc:uniq $nicks] ","]
}
}
proc auth:pulse {reason} {
global account354
foreach user [split $account354] {
if {![bncvaliduser $user]} {
continue
}
setctx $user
set nicks ""
set allowedchans [split [string tolower [getbncuser [getctx] tag whochans]] ","]
namespace eval [getns] {
if {![info exists inwho]} { set inwho 0 }
}
upvar [getns]::inwho inwho
foreach chan [internalchannels] {
if {$allowedchans != "" && [lsearch -exact $allowedchans [string tolower $chan]] == -1} {
continue
}
set count 0
foreach nick [internalchanlist $chan] {
set account [bncgettag $chan $nick account]
if {$account == 0 || $account == ""} {
incr count
}
}
if {$count > 100 || ($count > 20 && $count > [llength [internalchanlist $chan]] * 3 / 4)} {
auth:enqueuewho $chan
continue
}
foreach nick [internalchanlist $chan] {
set account [bncgettag $chan $nick account]
if {($reason == 180 && $account == "") || ($account == 0 && $reason == 240)} {
lappend nicks $nick
}
if {[string length [join [sbnc:uniq $nicks] ","]] > 350} {
auth:enqueuewho [join [sbnc:uniq $nicks] ","]
set nicks [list]
}
}
}
if {$nicks != ""} {
auth:enqueuewho [join [sbnc:uniq $nicks] ","]
}
}
}
proc getchanlogin {nick {channel ""}} {
foreach chan [internalchannels] {
set acc [bncgettag $chan $nick account]
if {$acc != ""} {
return $acc
}
}
return ""
}
|