# 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 # /umode / /cmode aliases. fe (umode \$servernick() cmode *) foo bar {alias.t $foo mode $bar} # Part certain channels. alias.t hop part $C;join $0- alias.t la quote JOIN 0 alias.t lao @:leave=mychannels();fe leave foo {@foo=ischanop($servernick() $foo)?foo:[]};if (leave){part $unsplit(, $leave)} alias.t lac (args) { @ :args = args ? args : mychannels() @ :nuhs = remw($servernick()!$X $mynuhs()) fe args chan { @ chan = match("\\[$nuhs\\]" $nickuserhost($chanusers($chan))) ? chan : [] } if (args) { part $unsplit(, $args) } } alias.t lae (args) { @ :max = isnumber(b10 $args) ? shift(args) : 1 @ :min = isnumber(b10 $args) ? shift(args) : 1 @ :args = args ? args : mychannels() fe args foo { @ :bar = numonchannel($foo) @ :foo = min <= bar && bar <= max ? foo : [] } if (args) { part $unsplit(, $args) } } # 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} 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 } } alias.t kick.all (args) { unless (#args) { echo usage: ${t} [max-at-a-time] [#chan] patterns / 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 = afterw(/ $args) @ :args = beforew(/ $args) @ :sn = encode($servernum() $reason) @ :nicks = chanusers($chan) if (args) { @ :nuhs = userhost($nicks) @ :nuhs = joinstr(! nicks nuhs) fe args pat { if (0 > index(?*!@ $pat)) { @ pat = pattern($pat $nicks) } else { @ pat = pattern($pat $nuhs) } } fe args nick { @ nick = before(! $nick!) } @ cetk[kick][$sn] = uniq($shufflef($args) $cetk[kick][$sn]) } elsif (cetk[kick][$sn]) { @ cetk[kick][$sn] = pattern("\\[$nicks\\]" $cetk[kick][$sn]) @ cetk[kick][$sn] = filter($servernick() $cetk[kick][$sn]) kick $chan $unsplit(, $splice(cetk[kick][$sn] 0 $count)) $reason } if (cetk[kick][$sn]) { q1cmd 0 92 kick.all $chan / $reason } } 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 : [You are banned.] kick.all $count $chan $chanbans(b $chan) / $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 } } } alias join.all (args) { ^join $pattern("\\[$args\\]" $mychannels()) @ :sn = servernum() @ cetk[join][$sn] = uniq($args $cetk[join][$sn]) @ cetk[join][$sn] = filter("\\[$mychannels()\\]" $cetk[join][$sn]) if (cetk[join][$sn] && !args) { join $split(, $shift(cetk[join][$sn])) } if (cetk[join][$sn]) { q1cmd 0 94 join.all } } on #-channel_sync + * qcmd 9 on #-341 + * qcmd 9 # Read on. alias alias.tt (args) { fe (op nochops + o deop chops - o voice 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 = shufflef($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 alias.quoted unless (cexist($0)) {alias.t $0 quote $toupper($0) ${0<[$1]?[\$0-${[$1]-1} ]:[]}${0>[$1]?[\$*]:[:\$${[$1]}-]}\;} fe (chanserv knock memoserv nickserv samode silence watch) 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.t #-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 matchbans (types,chan,nuhs) { fec types type { @ :bans = chanbans($type $chan) fe nuhs nuh { @ nuh = rmatch($nuh $bans) ? nuh : [] } } return $nuhs } alias.t patternbans (type,nuh,chan) { return $rpattern($nuh $chanbans($type $chan)) } # Store modes in an array, then send them off to the server in packed chunks. # Avoid calling this with more than one mode at a time. alias.t qmode (chan default *,args) { @ :sn = servernum() @ :modeq = [modeq,$sn,$chan] @ :cmd = cmd ? cmd : cetk[modecmd][$sn] @ :cmd = cmd ? cmd : cetk[modecmd] @ :cmd = cmd ? cmd : [jmode] @ :mm = cetk[maxmodes][$sn] @ :mm = isnumber(b10 $args) ? shift(args) : mm @ :mm = 0 < mm ? mm : serverctl(get $sn 005 MODES) @ cetk[maxmodes][$sn] = mm @ :mm = 0 < mm ? mm : 3 @ :args = unsplit(" " $args) if (#args) { setuniqitem $modeq $args } elsif (ischanop($servernick() $chan)) { if (numitems($modeq)) { @ :it0 = getmatches($modeq -? %) @ :it1 = getmatches($modeq +? %) @ :it2 = getmatches($modeq %) @ :it = leftw($mm $it0 $it1 $it2) $cmd $chan $getndelitems($modeq $it) } else { qcmd } } else { qcmd 9 } if (numitems($modeq)) { q1cmd 0 91 qmode $chan } elsif (serverctl(get $sn 005 MODES)) { @ cetk[maxmodes][$sn] = 0 } } on #-mode_stripped - * { getandmitems modeq,$servernum(),$1 $2-3 } on #-mode - '$servernick() *' { qcmd 9 } alias.t jmode (chan,modes) { @ :md = modes @ :cm = split(, $serverctl(get $servernum() 005 CHANMODES)) @ :cm = :pm = :nm = cm ? cm : [b k l imnpst] @ :pm = [$pop(pm) $pop(pm)$pop(pm)$pop(pm)ohv] @ :nm = [$pop(nm)$pop(nm) $pop(nm)$pop(nm)ohv] @ :cm = pm fe md md { if (0<:count) {@ --:count;continue} fec md md { switch ($rmatch($md + -)) { (0) {@ :count += indextoword($index($md $cm) $cm)} (1) {@ :cm = pm} (2) {@ :cm = nm} } } @ :ret#= md, :md = [] } if (count) { @ cetk[modecmd][$servernum()] = [mode] echo Failed to parse modes command in /jmode. mode $chan $modes } else { mode $chan $ret $md } } alias chanmodes (pat dwords 1, filt dwords 1,args) { @ :oxd = xdebug(extractw) xdebug extractw @ :chan = pattern("\\[$args\\]" $mychannels()) @ :mode = chanmode($chan) fe mode mode {@ mode = shift(mode)} fec pat foo { @ chan = copattern(*$foo* mode chan) @ mode = copattern(*$foo* mode mode) } fec filt foo { @ chan = cofilter(*$foo* mode chan) @ mode = cofilter(*$foo* mode mode) } xdebug $oxd if (functioncall()) { return $chan } else { echo $chan } } # /wi, wii, ww, wwi, wiq, wwq. Mass whois using various queueing methods. fe (tt ttt) foo {stack push alias alias.$foo} alias alias.tt (args) { alias.t $args @ sar(gr/wi/ww/args) @ sar(gr/whois/whowas/args) @ sar(gr/q1cmd/fq1cmd/args) @ sar(gr/qcmd/fqcmd/args) alias.t $args } fe ("q1cmd 300 93" p "qcmd 93" "") qcmd suff { alias.tt wi$suff $qcmd whois \$unsplit(, $*) alias.tt wii$suff fe (${[$*]?[$*]:servernick()}) foo \{$qcmd whois \$foo \$foo\} } alias.tt wiq (args) { @ :sn = servernum() if (#args) { @ wi[$sn][max] = isnumber(b10 $args) ? shift(args) : wi[$sn][max] @ wi[$sn][max] = 0 < wi[$sn][max] ? wi[$sn][max] : 10 @ wi[$sn] = uniq($wi[$sn] $args) } elsif (wi[$sn]) { whois $unsplit(, $splice(wi[$sn] 0 $wi[$sn][max])) } if (wi[$sn]) { q1cmd 0 93 ${t} } } fe (318 369) foo {on #-$foo - * qcmd 9} fe (tt ttt) foo {stack pop alias alias.$foo} alias.t comchan (chans) { @ :mc = sort($mychannels()) @ :min = isnumber(b10 $chans) ? shift(chans) : #chans ? #chans : #mc @ :mint = isnumber(b10 $chans) ? shift(chans) : 0 @ :chans = chans ? chans : mc fe ($remw($servernick() $chanusersa())) user { @ :userchans = [] @ :userextra = [] fe ($mc) chan { if (onchannel($user $chan)) { if (rmatch($chan $chans)) { push userchans $chan } else { push userextra $chan } } } if (min<=#userchans && mint<=#userextra) { xecho -banner -- $[16]user $attr.bold($userchans) $userextra } } } alias.t comusers (chans) { } stack push alias alias.tt stack push alias alias.ttt alias.t alias.tt (args) { alias.t $args @ sar(gr/chanusers/nochops/args) @ sar(gr/users/usersn/args) alias.t $args @ sar(gr/nochops/chops/args) @ sar(gr/usersn/userso/args) alias.t $args } alias.t alias.ttt (args) { alias.tt $args @ sar(gr/users.r/users/args) @ sar(gr/regpattern/pattern/args) alias.tt $args } alias.ttt users.r (args) { @ :oxd = xdebug(dword) xdebug dword @ :maxtm = isnumber(b10 $args) ? shift(args) : [] @ :users = args fe users users {@ users = ischannel($users) ? users : []} fe args args {@ args = ischannel($args) ? [] : args} @ :users = users ? users : 1<#args ? shift(args) : C @ :users = chanusersa($users) @ :hosts = userhost($users) @ :users = joinstr(! users hosts) @ :chans = mychannels() @ :time = time() @ :twid = time - F @ :twid = 0 - strlen($twid) @ :b = chr(2) fe args foo { @ foo = regpattern($foo $users) } @ :args = sort($uniq($args)) xdebug $oxd if (functioncall() || !args) { return $args } fe ($args) foo { @ :sl = my[nl] = rightw(1 $numsort($my[nl] $strlen($foo))) @ :mc = chans @ :eu = encode($tolower($foo)) fe mc mc { @ :tm = list[chan][$encode($tolower($mc))][nuh][$eu] @ :tm = tm ? time - tm : [] @ :tm = tm < maxtm || !maxtm ? tm : [] @ :mc = tm ? [$b$[$twid]tm$b$mc] : [] } @ :tm = list[nuh][$eu] @ :tm = tm ? time - tm : [] if (mc || !maxtm || maxtm > tm && tm) { xecho -banner -nolog -- $[$sl]foo $[$twid]tm $mc @ :listed++ } } xecho -banner -nolog -- $b$listed$b/$b$#args$b users listed. } stack pop alias alias.ttt stack pop alias alias.tt alias.t find.join (serv,chan,key,...) { fe ($split(, $serv)) serv { if (match($chan $mychannels($serv))) { } elsif (isconnected($serv)) { scmd $serv join $chan $key } } defer $* } on ^421 "% #QCMD# *" qcmd 0. # 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 = servernum() if (#args) { @ cetk[fc][$sn] = uniq($args $cetk[fc][$sn]) @ cetk[fc][$sn] = filter("\\[$mychannels()\\]" $cetk[fc][$sn]) } elsif (cetk[fc][$sn]) { @ :chans = indextoword(500 $cetk[fc][$sn]) @ :chans = 1 < chans ? chans : numwords($cetk[fc][$sn]) @ :chans = splice(cetk[fc][$sn] 0 $chans) part $unsplit(, $chans) quote #QCMD# } if (cetk[fc][$sn]) { q1cmd 0 0.0 ${t} } } on #-442 1 * setuniqitem channels find.join $lastserver() $1 , # Randjoin. alias.t randjoin (mask default $randjoin.mask) { @ :time = isnumber(b10 $mask) ? shift(mask) : randjoin.time @ ::randjoin.time = time @ ::randjoin.mask = mask @ :time += 0 <= time ? 0 : time() @ :maxchan = serverctl(get $servernum() 005 MAXCHANNELS) @ :maxchan = maxchan ? maxchan : 10 if (maxchan > 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 (chans,keys) { @ :oxd = xdebug(dword) xdebug dword @ :sn = servernum() @ :chans = split(, $chans) if (#chans) { fe chans chan { @ :chan = repeat($#keys $chan ) @ :chan = joinstr(, chan keys) } @ cetk[fk][$sn] = uniq($chans $cetk[fk][$sn]) @ cetk[fk][$sn] = filter("\\[$mychannels()\\],*" $cetk[fk][$sn]) } elsif (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) quote #QCMD# } if (cetk[fk][$sn]) { q1cmd 0 0.0 ${t} } 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};quote JOIN ${#?[$0]:C} $unsplit(, $key($split(, ${#?[$0]:C}))) # These aliases attempt to recreate the $userhost() data using various methods. # alias.t uhfix (args) { @ uhfix[num] = isnumber(b10 $args) ? shift(args) : uhfix[num] ? uhfix[num] : 30 @ uhfix[cnt] = isnumber(b10 $args) ? shift(args) : uhfix[cnt] ? uhfix[cnt] : 5 @ :sn = servernum() @ uhfix[$sn] = uniq($args $uhfix[$sn]) @ :uh = userhost($uhfix[$sn]) @ uhfix[$sn] = copattern($userhost(,) uh uhfix[$sn]) ^userhost $splice(uhfix[$sn] 0 $uhfix[num]) -direct -count $uhfix[cnt] -cmd { unless ([$3@$4] == userhost(,)) {pretend :$0!$3@$4 NICK :$0} q1cmd 0 9 uhfix ${uhfix[$servernum()] ? uhfix[cnt] : uhfix[num]} } } alias.t uhfix.xw (args) { @ uhfix[len] = isnumber(b10 $args) ? shift(args) : uhfix[len] ? uhfix[len] : 480 @ :sn = servernum() @ uhfix[$sn] = uniq($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 uhfix.xw} } -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 uhfix.xw} } $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 } } # 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 { break on #^$hook + '% \\\\[\$relay.chans\\\\] *' { unless (numwords($relay.src) == numwords($relay.dst)) {return} @ :chans = copattern(-$servernum()/$1 relay.src relay.dst))) @ :chans = unsplit(, $uniq($chans)) if (chans) {1cmd 10,30 notice $chans <$1:$0> $2-} } }