# CETK epic Channel Management script 1.0 # unload cetk.chanmgmt package cetk.chanmgmt # # Recommended. load cetk.functions load cetk.userlist load functions # stack push alias alias.tt stack push alias alias.ttt # Supporting functions. alias.t mynuhs (args) @:args=#args?args:myservers(.);fe args arg {xeval -s $arg {@arg=[$servernick()!$X]}};return $args # /umode / /cmode aliases. fe (umode \$servernick() cmode *) foo bar {alias.t $foo mode $bar} # Part certain channels. alias.t hop leave.pattern $remwws(/ $* / $mychannels());join.all $remwws(/ $mychannels() / $*) alias.t la quote JOIN 0 # # Leave All Opped alias.t lao { @ :leave = mychannels() fe leave foo {@ foo = rmatch($foo $*) ? foo : []} fe leave foo {@ foo = ischanop($servernick() $foo) ? foo : []} if (leave) {part $unsplit(, $shufflef($leave))} } # # Leave All Cloned. alias.t lad (args) { @ :part = isnumber(b10 $args) ? shift(args) : 0 @ :maxc = isnumber(b10 $args) ? shift(args) : 0 @ :args = args ? args : shuffled($mychannels()) @ :part = 0 >= part ? part + #args : part @ :nicks = remw($servernick() $mynicks($common($serverctl(gmatch $servergroup()) / $myservers(,)))) fe args chan {@ chan = (maxc <#common($nicks / $chanusers($chan))) ? chan : []} @ :args = leftw($part $args) if (args) {part $unsplit(, $shufflef($args))} } # # Leave All Empty. alias.t lae (args) { @ :maxu = isnumber(b10 $args) ? shift(args) : 0 @ :maxc = isnumber(b10 $args) ? shift(args) : 0 @ :mink = isnumber(b10 $args) ? shift(args) : 0 @ :maxk = isnumber(b10 $args) ? shift(args) : 0 @ :args = args ? args : mychannels() @ :mynicks = mynicks($common($myservers(,) / $serverctl(gmatch $servergroup()))) fe args foo { @ :nicks = chanusers($foo) @ :foo = #nicks ? foo : [] fe ($mynicks) nick {@nicks = remw($nick $nicks)} @ :nicks = #nicks @ :foo = (nicks <= maxu) ? foo : [] } @ :maxc = 0=numb)*#chan lae $max($leftw($numb $numsort($chan))) $numa $chans } # # Leave All (this) Window. alias.t law (args default 0) { fe ($args) win { xeval -w $win { @ :chan = mychannels(#$win) fe chan chan { @ chan = !win || chanwin($chan) == win ? chan : [] } if (chan) { part $unsplit(, $shufflef($chan))} } } } # # Leave All Looped channels. Channels with common users, for networking purposes. alias.t lal (args) { @ :chan = :chans = args ? args : mychannels() @ :chans = shuffled($uniq($chans)) fe chans chan {@ chan = ischanop($servernick() $chan) ? [] : chan} @ :nicks = chans fe nicks nick {@ nick = chanusers($nick)} @ nicks = remw($servernick() $uniq($uniqd(1 $sort($nicks)))) fe ($chans) chan { fe ($nicks) nick { if (onchannel($nick $chan)) { push :part $chan } } } shift part push join $part if (:part) {leave $unsplit(, $uniq($part))} } # Read on. alias alias.tt (args) { fe (ban b 1 exempt e 0 iexempt I 0) foo bar bat { fe (un$foo -$bar $foo +$bar) foo bar { @ :argz = args @ :baz = bat && bar=~[+*] ? [deop \$num \$chan \$args\;] : [] #@ :baz#= bar=~[+*] ? [un$foo \$chan \$serverctl( @ msar(gr/\$foo/$foo/\$bar/$bar/\$baz/$baz/argz) if (aliasctl(alias exists $word(0 $argz))) {continue} #@ :baz#= bar=~[+*] ? [un$foo \$chan \$serverctl( @ msar(gr/\$foo/$foo/\$bar/$bar/\$baz/$baz/argz) if (aliasctl(alias exists $word(0 $argz))) {continue} if (argz =~ [*.mask *] && foo !~ [un*]) {continue} alias.t $argz } } } # Ban, Exempt, Iexempt. UnBan, UnExempt, UnIexempt. # Call deop on matching users for bans only. alias.tt $foo (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] [patterns] } @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C $baz fe ($args) arg { qmode $chan $num $bar $arg } } # Ban, etc, nicks based on the $mask() of n!u@h of all [nicks]. # Nicks don't have to be on channel. alias.tt $foo.nick (args) { unless (#args) { echo usage: ${t} mask [max-at-a-time] [#chan] [nicks] } @ :mask = isnumber(b10 $args) ? shift(args) : 2 @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C @ :nuhs = nickuserhost($args) @ :masks = maskm($mask $nuhs) @ :chanb = chanbans($strip(+- $bar) $chan) fe chanb cb {@ cb = match($cb $nuhs) ? chanb : []} $foo $num $chan $uniq($masks $chanb) } # Read on. alias alias.ttt fe (reg "") bar {alias.tt $sar(g/\$bar/$bar/$*)} # Ban, etc, based on $mask() of all n!u@h on channel matching [patterns]. # [pattern] may be a wildcard for ban.mask and a regex for ban.regmask. alias.ttt $foo.$barpat (args) { unless (#args) { echo usage: ${t} mask [max-at-a-time] [#chan] [patterns] } @ :mask = isnumber(b10 $args) ? shift(args) : 2 @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C @ :nuhs = chanusers($chan) @ :nuh1 = userhost($nuhs) @ :nuhs = joinstr(! nuhs nuh1) fe args arg { @ arg = maskm($mask $$barpattern($arg $nuhs)) } $foo $num $chan $uniq($args) } # Unban all matching bans currently set. alias.tt $foo.mask (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] [patterns] } @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C @ :bans = chanbans($strip(+- $bar) $chan) fe bans ban { @ :ban = match($ban $args) || rmatch($ban $args) ? ban : [] } $foo $num $chan $bans } # Site ban all nicks currently on the network that are shitlisted at a # particular level. alias.t pban (args) { unless (#args) { echo usage: ${t} [level] [mask] [max-at-a-time] [#chan] [nicks] } @ :level = isnumber(b10 $args) ? shift(args) : 8 @ :mask = isnumber(b10 $args) ? shift(args) : 2 @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C @ :args = #args ? args : notify(on) @ :args = nickuserhost($args) @ :args = checkshits($level $chan $args) @ :args = maskm($mask $args) ban $num $chan $args } # Read on. alias alias.tt { fe (kill \$1 kline \$1 zline \$nametoip($4)) cmd arg { @ :args = [$*] @ sar(gr/CMDA/$cmd $arg/args) @ sar(gr/CMD/$cmd/args) alias.t $args } } # /pkill, /pakill, pkline. Perform a who request, kill everyone matching the # masks, but perform some sanity checks. alias.tt pCMD { @ :ar = beforew(/ $*) @ :rn = afterw(/ $*) @ :cnt = isnumber(b10 $ar) ? shift(ar) : 10 @ :mask = shift(ar) if (rmatch($servernick()!$X $mask) && rmatch($servernick()!$X $ar)) { echo Refusing to kill self. } elsif (#mask && #ar && #rn) { widle $mask wait for who $mask -line { bless if ([$1] == servernick()) { echo This might have been a bad idea. } elsif (rmatch($1!$3@$4 $ar) && -1 < --cnt) { CMDA $rn } } } else { echo usage: ${t} [max-kills] whomask nuhmasks / reason } } # kick.all isn't well CPU optimised, which is probably a good thing. alias.t kick.all (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] patterns / reason } @ :oxd = xdebug(dword) xdebug dword @ :count = isnumber(b10 $args) ? shift(args) : cetk[maxkick][$servernum()] @ :count = cetk[maxkick][$servernum()] = 0 < count ? count : 1 @ :chan = ischannel($args) ? shift(args) : C @ :reason = afterw(/ $args) @ :args = beforew(/ $args) @ :sn = encode($servernum() $reason) if (args) { @ cetk[kick][$sn] = uniq($args $cetk[kick][$sn]) } elsif (cetk[kick][$sn][nick]) { @ cetk[kick][$sn][nick] = pattern("\\[$chanusers($chan)\\]" $cetk[kick][$sn][nick]) kick $chan $unsplit(, $splice(cetk[kick][$sn][nick] 0 $count)) $reason } elsif (cetk[kick][$sn]) { @ :nick = chanusers($chan) @ :nuhs = userhost($nick) @ :nuhs = joinstr(! nick nuhs) @ :nick = pattern("\\[$cetk[kick][$sn]\\]" $nuhs) fe nick nick {@ nick = before(! $nick!)} @ :nick = shufflef($nick) @ :nick = filter($servernick() $nick) @ :nick = splice(nick 0 $count) kick $chan $unsplit(, $nick) $reason fe cetk[kick][$sn] pat {@ :pat = match($pat $nuhs) ? pat : []} @ cetk[kick][$sn][nick] = nick } if (cetk[kick][$sn] || cetk[kick][$sn][nick]) { q1cmd 0 92 kick.all $chan / $reason } xdebug $oxd } #on #-kick + '% $servernick() *' qcmd 9 alias.t kick.banned (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] reason } @ :count = isnumber(b10 $args) ? shift(args) : cetk[maxkick][$servernum()] @ :count = cetk[maxkick][$servernum()] = 0 < count ? count : 1 @ :chan = ischannel($args) ? shift(args) : C @ :reason = args ? args : [] kick.all $count $chan $filterbans(b $chan $mynuhs()) / $reason } alias.t invite.all (args) { @ :nicks = :chans = args @ :nuhs = chanusersa() @ :nuh1 = userhost($nuhs) @ :nuhs = joinstr(! nuhs nuh1) @ :sn = servernick() fe chans chan {@ chan = ischannel($chan) ? chan : []} fe nicks nick {@ nick = ischannel($nick) ? [] : nick} fe nicks nick {@ nick = 0 > index(*? $nick) ? nick : pattern($nick $nuhs)} fe nicks nick {@ nick = before(! $nick!)} @ :nicks = uniq($nicks) fe ($chans) chan { unless (onchannel($sn $chan)) {continue} fe ($nicks) nick { if (onchannel($nick $chan)) {continue} qcmd 93 invite $nick $chan } } } # Don't use. Use "join.all -jf" instead. alias join.flash (args) { @ args = remwws(/ $replacex(\$mychannels(x) x $serverctl(gmatch $servergroup())) / $args) while (#args && ++:chans) { fe ($shuffled($common($myservers(,) / $serverctl(gmatch $servergroup())))) serv { if (!#args) { break } elsif (chans>#mychannels($serv)) { scmd $serv join $shift(args) } } } } alias join.all (args) { $getopts(:args :opt. "djsfouqc:m:n:r:v:" $args) @ :cmd = opt.q ? [quote : JOIN] : [join] @ :opt.v = 0 < opt.v ? opt.v : time() + opt.v @ :maxc = serverctl(get $servernum() 005 MAXCHANNELS) @ :maxc = 0 < maxc ? maxc : serverctl(get $servernum() 005 CHANLIMIT) @ :maxc = 0 < maxc ? maxc : cut(1 : $cut(0 , $serverctl(get $servernum() 005 CHANLIMIT))) @ :maxc = 0 < maxc ? maxc : #mychannels() @ :maxc = 10 < maxc ? maxc : 10 @ :opt.c = pop(:opt.c) @ :opt.n = pop(:opt.n) @ :opt.c = (0 < opt.c) ? opt.c : opt.c + maxc @ :opt.n = (0 < opt.n) ? opt.n : opt.n + maxc fe args arg {@ arg = opt.v > list[chan][$encodel($beforr(, $arg))][creation] ? arg : []} if (opt.r) { @ :rmax = shift(opt.r) @ :rmin = shift(opt.r) @ :rmin = rmin ? rmin - 1 : 0 @ :rmin = 0 <= rmin ? rmin : rmax + rmin fe args args {@ :args = rmin < rand($rmax) ? [] : args} } @ :cmd = opt.d ? [echo $cmd] : cmd fe (${ opt.j ? serverctl(gmatch $servergroup()) : opt.f ? -1 : servernum()}) serv { @ args = remwws(, $tolower($mychannels($serv) , $args)) } if (opt.s) @ :args = shufflef($args) if (0= ++:chans) { fe ($shuffled($common($myservers(,) / ${opt.f ? serverctl(gmatch $servergroup()) : server}))) serv { @ :mc = mychannels($serv), nmc = #mc if (opt.n && opt.n <= #join[$serv]) { } elsif (0 >= serverwin($serv)) { } elsif (opt.c < #:join[$serv] + nmc) { } elsif (isconnected($serv) && (chans>nmc)) { while (match(${:chan=shift(args)} $mc) && nmc--) {push args $chan} push :join[$serv] $chan push :join $serv } } } fe ($shufflef($uniq($:join))) serv { unless (numwords($:join[$serv])) {continue} @ :chns = :keys = [] fe ($:join[$serv]) arg { @ :arg = split(, $arg) @ :chns = [$:chns,]##shift(arg) @ :keys = [$:keys,]##shift(arg) } @ :chns = after(, $:chns) @ :keys = after(, $:keys) if (chns || keys) {scmd $serv if.windows 1 $cmd $chns $keys} } } alias leave.pattern (args) { @ :args = split(, $args) fe args arg {@ arg = pattern($arg $mychannels())} @ :args = unsplit(, $uniq($args)) if (args) {part $shufflef($args)} } #on #-channel_sync + * qcmd 9 #on #-341 + * qcmd 9 # Read on. alias alias.tt (args) { fe (op nochops + o enop nochops + o deop chops - o enhop nochhops + h dehop chhops - h envoice chnovoices + v devoice chvoices - v) cmd ufn sign mode { #if (aliasctl(alias exists $cmd)) {continue} @ :argz = args alias.t $msar(gr/\$cmd/$cmd/\$ufn/$ufn/\$sign/$sign/\$mode/$mode/argz) } } # Op, Deop, Voice, Devoice. alias.tt $cmd (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] [patterns] } @ :num = isnumber(b10 $args) ? shift(args) : [] @ :chan = ischannel($args) ? shift(args) : C @ :nicks = filter($servernick() $$ufn($chan)) @ :nuhs = nickuserhost($nicks) fe args pat { if (0 > index(?* $pat)) { @ pat = pattern($pat $nicks) } else { @ pat = pattern($pat $nuhs) } } @ :args = shuffles($args) @ :args = uniq($args) fe args nick { qmode $chan $num $sign$mode $before(! $nick!) } } # msg.ov #channel message fe (o @ vo @+) foo bar { fe (msg PRIVMSG notice NOTICE) food bard { alias.t ${food}.$foo quote $bard $bar\$* } } alias.t cnmode (chan,mode,mask) { fe mask mask {@ mask = shuffles($pattern($mask $chanusers($chan)))} @ mask = remw($servernick() $uniq($mask)) fec ($mode) char { switch ($char) { (+) (-) {@ :pm = char} (*) {fe ($mask) nick {qmode $chan $pm$char $nick}} } } } alias.t cuhmode (chan,mode,mask) { @ :nicks = chanusers($chan) @ :nuhs = userhost($nicks) @ :nuhs = joinstr(! nicks nuhs) fe mask mask {@ mask = pattern($mask $nuhs)} @ :nuhs = uniq($mask) fe mask mask {@ mask = before(! $mask)} cnmode $chan $mode $mask } alias alias.quoted unless (cexist($0)) {alias.t $0 quote $toupper($0) ${0<[$1]?[\$0-${[$1]-1} ]:[]}${0>[$1]?[\$*]:[:\$${[$1]}-]}\;} fe (botserv chanfix chanserv groupserv hostserv infoserv memoserv nickserv operserv saslserv statserv) foo {alias.quoted $foo -1} fe (knock sajoin samode silence watch monitor) foo {alias.quoted $foo -1} fe (chatops globops locops) foo {alias.quoted $foo 0} fe (kline unkline zline unzline sqline unsqline) foo {alias.quoted $foo 1} fe (gline ungline) foo {alias.quoted $foo 2} stack pop alias alias.tt stack pop alias alias.ttt # CHANMODE type 1 functions stack push alias on.t alias on.t (argx) { fe (367 368 b 348 349 e 346 347 I) foo bar baz { @ :args = argx @ sar(gr/\$foo/$foo/args) @ sar(gr/\$bar/$bar/args) @ sar(gr/\$baz/$encode($baz)/args) on $args } } on.t #-$foo - * { @ :var = [list] @ :var#= [.chan.$encode($tolower($1))] @ :var#= [.srv.$servernum()] @ :var#= [.modes.$baz.] ^assign $var $uniq($2 $remw($3 $($var))) } on.t #-$bar - * { @ :var = [list] @ :var#= [.chan.$encode($tolower($2))] @ :var#= [.srv.$servernum()] @ :var#= [.modes.$baz] ^assign $var $uniq($(${var}.) 0) ^assign -${var}. } on #-mode_stripped - "% % ?? %" { if (0<=index($2 b$cut(0 , $serverctl(get $servernum() 005 CHANMODES)))) { @ :var = [list] @ :var#= [.chan.$encode($tolower($1))] @ :var#= [.srv.$servernum()] @ :var#= [.modes.$encode($rest(1 $2))] ^assign $var $uniq($remw($3 $($var)) ${left(1 $2)==[+]?[$3]:[]}) } } stack pop alias on.t alias.t chanbans (type,chans) { @ :bold = chr(2) @ :etype = encode($type) @ :chans = chans ? chans : mychannels() fe chans chan { @ :bans = encode($tolower($chan)) @ :bans = list[chan][$bans][srv][$servernum()][modes][$etype] unless (functioncall()) { @ :nick = chanusers($chan) @ :nuhs = userhost($nick) @ :nuhs = joinstr(! nick nuhs) fe ($bans) ban { echo $chan +$type $ban $bold$pattern($ban $nuhs)$bold } } @ chan = bans } return $chans } alias.t matchban (types,nuh,chan) { fec types type { @ :type = rmatch($nuh $chanbans($type $chan)) ? type : [] } return $types } alias.t patternbans (types,chan,nuhs) { fec types type { @ :bans = chanbans($type $chan) fe nuhs nuh { @ nuh = rmatch($nuh $bans) ? nuh : [] } } return $nuhs } alias.t filterbans (types,chan,nuhs) { @ :banned = patternbans($types $chan $nuhs) fe nuhs nuh {if (-1 tm && tm) { #xecho -banner -nolog -- $[$sl]foo $[$twid]tm $mc $sort($uniq($ul)) xecho -banner -nolog -- $foo $tm $mc $sort($uniq($ul)) @ :listed++ } } xecho -banner -nolog -- $b$listed$b/$b$#args$b users listed. xdebug $oxd } stack pop alias alias.ttt stack pop alias alias.tt # Test for the existance of a list of channels using a fairly efficient method. # The results are placed in the CHANNELS array as a command that will join the # channel. alias.t find.chans (args) { @ :sn = isnumber(b10 $args) ? shift(args) : servernum() @ :mw = isnumber(b10 $args) ? shift(args) : 500 @ :mc = isnumber(b10 $args) ? shift(args) : 500 @ :oxd = xdebug(dword) xdebug -dword if (#args && 0 numwords($mychannels())) { } elsif (randjoin.part) { part $unsplit(, $splice(randjoin.part 0 9999)) } foreach list.chan foo { @ :dc = decode($foo) if (!time && list[chan][$foo][creation]) { } elsif (time <= list[chan][$foo]) { } elsif (rmatch($dc $mychannels() $randjoin.filt)) { } elsif (!rmatch($dc $randjoin.mask)) { } elsif (!rand(${++:rand})) { @ :chan = foo } } if (:chan) { echo $rand channels remaining. @ chan = decode($chan) @ randjoin.visit = uniq($chan $randjoin.visit) join $unsplit(, $randjoin.visit) } elsif (!randjoin.mask) { echo You must specify a mask. } elsif (randjoin.part) { part $unsplit(, $splice(randjoin.part 0 9999)) defer randjoin } else { echo Finshed randomly joining all channels! beep } } on #-channel_sync + '\\[$randjoin.visit\\] *' { @ list[chan][$encodel($0)] = time() @ randjoin.visit = remw($0 $randjoin.visit) @ randjoin.part = uniq($0 $randjoin.part) defer randjoin } alias.t visit (args) { @ :num = isnumber(b10 $args) ? shift(args) : 10 @ :args = uniq($args) stack push assign randjoin.visit while (args) { @ :args = remwws(// $mychannels() // $args) @ :chans = randjoin.visit = splice(args 0 $num) @ :chans = unsplit(, $chans) wait for quote : JOIN $chans$chr(13 10)PART $chans } stack pop assign randjoin.visit } on ^send_to '% % MODE \\[$randjoin.visit\\]**' defer pretend :$S 324 $servernick() $3 + on ^send_to '% % WHO \\[$randjoin.visit\\]**' defer pretend :$S 315 $servernick() $3 : on #-439 + "% #% *" if (randjoin.part) {part $unsplit(, $randjoin.part)} # Attempt to join a comma separated list of channels (first arg) using a list # of keys (remaining args). This one won't actually tell you the key yet. alias.t find.keys (keys) { @ :oxd = xdebug(dword) xdebug dword @ :sn = isnumber(b10 $keys) ? shift(keys) : servernum() @ :chans = split(, $shift(keys)) if (#chans) { fe chans chan { @ :chan = repeat($#keys $chan ) @ :chan = joinstr(, chan keys) } @ cetk[fk][$sn] = decodew($uniq($encodew($chans $cetk[fk][$sn]))) } elsif (cetk[fk][$sn]) { @ cetk[fk][$sn] = filter("\\[$mychannels()\\],*" $cetk[fk][$sn]) @ :args = indextoword(500 $cetk[fk][$sn]) @ :args = 1 < args ? args : numwords($cetk[fk][$sn]) @ :args = splice(cetk[fk][$sn] 0 $args) @ :args = split(, $args) fe args chan key { push :chans $chan push :keys $key } quote : JOIN $unsplit(, $chans) $unsplit(, $keys) q1cmd 0 9 ${t} $sn } xdebug $oxd } alias.t emptycycle (args) { if (args) {$getopts(:args cetk.emptycycle. "hi:x:" $args)} if (cetk.emptycycle.h) { @ cetk.emptycycle.h = [] echo /emptycycle [min-chan-age] [switches] [serv,chan] echo -i mask Automatically include channels matching serv,chan mask. echo -x mask Automatically exclude channels matching serv,chan mask. } @ :mint = isnumber(b10 $args) ? shift(args) : 300 @ :servg = servergroup() @ :servg = servergroup(,) == servg ? servernum() : servg @ :servg = serversgroup($servg) @ :chans = mychannels() @ :nick = servernick() fe chans chan { if (1 != numonchannel($chan)) { } elsif (ischanop($nick $chan)) { } elsif (mint > time() - list[chan][$encodel($chan)][creation]) { } elsif (rmatch($servg,$chan $cetk.emptycycle.x)) { } elsif (rmatch($servg,$chan $cetk.emptycycle.i $args)) { continue } @ :chan = [] } if (#chans) { xecho -banner -- Cycling $chans cycle $unsplit(, $chans) } } alias.t cycle quote PART ${#?[$0]:C} $2-$chr(13 10)JOIN ${#?[$(0-1)]:C} # These aliases attempt to recreate the $userhost() data using various methods. # alias.t uhfix.me () { userhost $servernick() -cmd { unless (X == [$3@$4]) { @ serverctl(set $servernum() userhost $3@$4) } fe ($mychannels()) chan { if (1==#uniq($userhost($chan $0))) { pretend :$0!$3@$4 NICK :$0 break } } } } alias.t uhfix (args) { @ uhfix[count] = isnumber(b10 $args) ? shift(args) : uhfix[count] ? uhfix[count] : 5 @ uhfix[lines] = isnumber(b10 $args) ? shift(args) : uhfix[lines] ? uhfix[lines] : 2 @ :sn = pass($jotc(AZaz)_ $servergroup()); # Formerly servernum(). @ :count = uhfix[count] * (#uhfix[$sn] ? 1 : uhfix[lines]) @ :cua = chanusersa() fe args arg {@arg = pattern($arg $cua)} @ :uh = userhost($args) @ :args = copattern($userhost(,) uh args) @ :args = shuffles($args) @ uhfix[$sn] = uniq($args $uhfix[$sn]) @ :uh = userhost($uhfix[$sn]) @ uhfix[$sn] = copattern($userhost(,) uh uhfix[$sn]) if (x==userhost(,)) {unshift uhfix[$sn] $servernick()} if (#uhfix[$sn]) { @ :servs = common($myservers(.) / $serverctl(gmatch $servergroup())) ^userhost $splice(uhfix[$sn] 0 $count) -direct -count $uhfix[count] -extra servs -cmd { if ([$3@$4] == userhost(,)) { push uhfix[$pass($jotc(AZaz)_ $servergroup())] $0 } else { fe ($5-) serv { if (-1 <= findw($0 $chanusersa())) { xeval -serv $serv -window $serverwin($serv) {pretend :$0!$3@$4 NICK :$0} } } } if ([$0] == servernick()) {@ serverctl(set $servernum() userhost $3@$4)} q1cmd 0 9 qcmd.after 9 uhfix } } } alias.t uhfix.xw (args) { @ uhfix[len] = isnumber(b10 $args) ? shift(args) : uhfix[len] ? uhfix[len] : 480 @ :sn = servernum() @ uhfix[$sn] = uniq($shuffles($args) $uhfix[$sn]) @ :uh = userhost($uhfix[$sn]) @ uhfix[$sn] = copattern($userhost(,) uh uhfix[$sn]) @ :i2w = indextoword($uhfix[len] $uhfix[$sn]) @ :i2w = i2w ? i2w : numwords($uhfix[$sn]) if (serverctl(get $sn 005 whox)) { ^who -line { unless ([$0] || rmatch($1@$2 $userhost(, $3))) { pretend :$3!$1@$2 NICK :$3 } } -end { if (uhfix[$servernum()]) {q1cmd 0 9 qcmd.after 9 uhfix.xw} uhfix.groupush 1 * } -ux $servernick() nuhsir%tnuh $unsplit(, $splice(uhfix[$sn] 0 $i2w)) } else { ^who -line { if (ischannel($0) && !rmatch($3@$4 $userhost(, $1))) { pretend :$1!$3@$4 NICK :$1 } } -end { if (uhfix[$servernum()]) {q1cmd 0 9 qcmd.after 9 uhfix.xw} uhfix.groupush 1 * } $unsplit(, $splice(uhfix[$sn] 0 $i2w)) } } alias.t uhfix.cache { @ :unk = userhost(,) @ :users = mychannels() fe users users { push users $chanusers($users) @ :hosts = userhost($users) @ :users = copattern($unk hosts users) shift users } @ :users = uniq($users) @ :users = sort($users) @ :hosts = userhost($users) @ :users = cofilter($unk hosts users) fe ($users) user { pretend :$user!$userhost($user) NICK :$user } } alias.t uhfix.groupull (args) { fe args arg {@ arg = pattern($arg $chanusersa())} @ :nicks = uniq($args) @ :uhs = userhost($nicks) fe ($serverctl(gmatch $servergroup())) serv { @ :nicks = copattern($userhost(,) uhs nicks) @ :uhs = userhost($nicks) unless (#nicks) {break} xeval -serv $serv -window $serverwin($serv) { @ :uhd = userhost($nicks) } fe ($cofilter($userhost(,) uhd nicks)) nick { pretend :$nick!$copattern($nick nicks uhd) NICK $nick } } } alias.t uhfix.groupush (args) { @ :tim = isnumber(b10 $args) ? shift(args) : 0 @ :svs = isnumber(b10 $args) ? shift(args) : #serverctl(gmatch $servergroup()) @ :num = isnumber(b10 $args) ? shift(args) : 0 @ :nicks = chanusersa() @ :uhs = userhost($nicks) @ :nuhs = joinstr(! nicks uhs) fe args arg {@ arg = copattern($arg nuhs nicks)} @ :nicks = args @ :uhs = userhost($nicks) @ :nicks = cofilter($userhost(,) uhs nicks) @ :uhs = userhost($nicks) @ :ut = utime() fe ($shuffles($serverctl(gmatch $servergroup()))) serv { xeval -serv $serv -window $serverwin($serv) { @ :nickd = mychannels() fe nickd nickd {@ :nickd = common($nicks / $chanusers($nickd))} unless (#nickd) {continue} @ :nickd = uniq($nickd) @ :uhd = userhost($nickd) @ :nickd = copattern($userhost(,) uhd nickd) unless (#nickd) {continue} @ :nickd = num ? leftw($num shufflef($nickd)) : nickd fe ($nickd) nick { pretend :$nick!$copattern($nick nicks uhs) NICK $nick } if (0>--svs) {break} if (tim && tim < tdiffu($ut)) {break} } } } alias.t uhfix.list (args) { @ :time = isnumber(b10 $args) ? shift(args) : 0 @ :time = 0 > time ? time() + time : time @ :args = args ? args : [*] @ :args = pattern("\\[$args\\]" $mychannels()) fe ($tolower($args)) chan { @ :echan = encode($chan) foreach list[chan][$echan][nuh] enuh { @ :nuh = decode($enuh) @ :nick = before(! $nuh) if (time > list[chan][$echan][nuh][$enuh]) { } elsif (!onchannel($nick $chan)) { } elsif (match($userhost($chan $nick))) { pretend :$nuh NICK :$nick } } } } alias.t uhfix.list (nicks) { @ :cua = chanusersa() fe nicks nicks {@nicks = pattern($nicks $cua)} @ :nicks = uniq($nicks) @ :nicks = tolower($nicks) @ :uhs = userhost($nicks) @ :nicks = copattern($userhost(,) uhs nicks) @ :time = 0 fe ($nicks) nick { fe ($aliasctl(assign match list.nuh.$encode($nick!))) nuh { if (time > $nuh) {continue} {@ time = $nuh} @ :nuh = cut(2 . $nuh) @ :nuh = decode($nuh) pretend :$nuh NICK :$before(! $nuh) } } } alias.t uhfix.wason (chan,args) { @ :nuhs = userhost(, $args), :unk = shift(nuhs), :chan = encode($chan) userhost $cofilter($unk nuhs args) -cmd \{pretend :\$0!\$3@\$4 notice \$decode\($chan\) :\} userhost $copattern($unk nuhs args) -cmd \{pretend :\$0!\$3@\$4 notice \$decode\($chan\) :\} } # Relay public messages between channels. # alias.t relaychan (chan,chans) { unless (chans) { echo Usage: ${t} sourcechan destination ... return } @ chan = chan =~ [-*/*] ? chan : [-$servernum()/$chan] @ relay.chans = uniq($relay.chans $after(/ $chan)) unless (numwords($relay.src) == numwords($relay.dst)) { echo Warning: Relay variables are inconsistent. Purging. purge relay } echo Relaying $chan to $chans fe ($chans) chans { @ chans = chans =~ [-*/*] ? chans : [-$servernum()/$chans] push relay.src $chan push relay.dst $chans } } # alias.t relayall (masks) { @ :svs = myservers(,) if (masks == [*]) { echo Warning: It is dangerous to use "/${t} *". echo Warning: If you need this, try "/${t} **" instead. return } fe svs sv { @ :chans = mychannels($sv) fe chans chan { @ :chan = [-$sv/$chan] } @ :sv = pattern("\\[$masks\\]" $chans) } fe ($svs) chan { relaychan $uniq($chan $svs) } } # alias.t relaylist (masks default *) { fe ($pattern("\\[$masks\\]" $uniq($relay.src))) src { echo $src -> $pattern("\\[$masks\\]" $uniq($copattern($src relay.src relay.dst))) } } # fe (public public_msg public_other) hook { @ :chans = copattern(-$servernum()/$1 relay.src relay.dst))) @ :chans = unsplit(, $uniq($chans)) if (chans) {1cmd 10,30 notice $chans <$1:$0> $2-} } on #?flood 0 * { if (ischanop($0 $2)) {return 1} if (ischanvoice($0 $2)) {return 1} if (rmatch($1 wallop*)) {return 1} @ :at = chr(2) @ :sg = servergroup() @ :sg = sg ? sg : serversgroup($servernum()) @ :sn = servernick() @ :uh = filter($userhost(, $0) $userhost()) @ :ct = isnumber(b10 $3) ? [$3] : flood_after @ :nicks = chanusers($2) @ :users = userhost($nicks) @ :nicks = copattern(*@$after(@ $uh) users nicks) echo ${at}flood${at}: ${at}\(${at}$ct $1-2 ${at}@${at} $sg $servernum()${at}\)${at} $uh ${at}$#nicks${at} $nicks if (!ischannel($2)) { } elsif (onchannel($0 $2) && userhost($2 ,) == userhost($2 $0)) { pretend :$0!$uh NICK :$0 } elsif (2 < cloak) { } elsif (29<#nicks) { q1cmd 0 90 clonecheck 25 fab $2 } elsif (9 < ct) { q1cmd 0 90 clonecheck 0 Fab $2 } writeto FLOODHOSTS $uh $2 $1 $sg 1cmd 300,300 proxycheck $uh 1cmd 300,300 proxytest -d $rightw(1 $serv[$servernum()][proxy]) -s :::$servergroup() $uh }