aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / script / queue.mrc
queue.mrc — 7.97 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Queues
; *
; **********************************************************************/
alias putserv { _queue.add server & & $$1- }
alias puthelp { _queue.add help & & $$1- }
alias putquick { _queue.add mode & & $$1- }
; /_put???? <target> <flags> <command>
alias _putserv { _queue.add server $$1- }
alias _puthelp { _queue.add help $$1- }
alias _putquick { _queue.add mode $$1- }
alias _queue { _queue.add help $$1- }
raw 401:* No such nick*:{ _queue.removenick $2 }
ON *:QUIT:{ _queue.removenick $nick }
;;;; ON *:NICK:{ do something!! }
alias _queue.add {
if ($_not($_connected)) || ($istok(server help mode,$1,32) == $false) || ($2- == $null) { return }
var %target = $$2,%flags = $$3,%text = $replace($$4-,$cr,<_CR_-_CR_-_CR_>,$lf,<_LF_-_LF_-_LF_>),%file = $_queue.file($$1)
write $"(%file) %target %flags %text
if ($timer(_QUEUE) == $null) { _queue.timer }
}
alias _queue.timer {
if ($_not($_connected)) { return $_clearqueue(all) }
elseif ($_queuesize(mode)) { .timer_QUEUE -mo 1 0 _queue.perform mode }
elseif ($_queuesize(server)) { .timer_QUEUE -mo 1 0 _queue.perform server }
elseif ($_queuesize(help)) { .timer_QUEUE -mo 1 0 _queue.perform help }
}
alias _queue.perform {
var %file = $_queue.file($1),%timer = 1000,%tmp
if ($isfile(%file)) {
tokenize 32 $read -nl1 %file
if ($3- != $null) {
write -dl1 " $+ %file $+ "
$replace($$3-,<_CR_-_CR_-_CR_>,$cr,<_LF_-_LF_-_LF_>,$lf)
}
}
if ($_queuesize(mode)) { %timer = 500 }
elseif ($_queuesize(server)) { %timer = 1000 }
elseif ($_queuesize(help)) { %timer = 2000 }
.timer_QUEUE -mo 1 %timer _queue.timer
}
; $_clearqueue(mode|server|help|all)
alias _clearqueue {
var %l = 0,%file,%t
if ($1 == mode) { %t = m }
elseif ($1 == server) { %t = s }
elseif ($1 == help) { %t = h }
else { %t = msh }
if (m isin %t) {
%file = $_queue.file(mode)
if ($lines(%file)) { inc %l $ifmatch }
_remove %file
}
if (s isin %t) {
%file = $_queue.file(server)
if ($lines(%file)) { inc %l $ifmatch }
_remove %file
}
if (h isin %t) {
%file = $_queue.file(help)
if ($lines(%file)) { inc %l $ifmatch }
_remove %file
}
return %l
}
; $_queuesize(mode|server|help|all)
alias _queuesize {
var %l = 0,%file,%t
if ($1 == mode) { %t = m }
elseif ($1 == server) { %t = s }
elseif ($1 == help) { %t = h }
else { %t = msh }
if (m isin %t) {
%file = $_queue.file(mode)
if ($lines(%file)) { inc %l $ifmatch }
}
if (s isin %t) {
%file = $_queue.file(server)
if ($lines(%file)) { inc %l $ifmatch }
}
if (h isin %t) {
%file = $_queue.file(help)
if ($lines(%file)) { inc %l $ifmatch }
}
return %l
}
; $_queue.file(mode|server|help)
alias _queue.file { return $_tmpdir $+ $1 $+ .queue }
; /_queue.removenick <nick>
alias _queue.removenick {
__queue.removenick $$1 $_queue.file(mode)
__queue.removenick $$1 $_queue.file(server)
__queue.removenick $$1 $_queue.file(help)
}
alias __queue.removenick {
var %nick = $$1,%file = " $+ $$2- $+ ",%win = @___queueremovenick,%tmp
if ($lines(%file)) {
%tmp = $read -ns $+ %nick %file
if ($readn) {
close -@ %win
window -h %win
filter -fwx %file %win %nick *
savebuf %win $2-
close -@ %win
}
}
}
;;
;
; -( channel mode queue )-
;
;;
; /_chanmode <chan> <modes> <parms>
alias _chanmode {
if (%c.chanmodequeue != $null) && (($gettok(%c.chanmodequeue,1,32) != $1) || ($calc($len($gettok(%c.chanmodequeue,2,32)) / 2) >= %.maxmodes)) { .timer_CHANMODE -e }
%c.chanmodequeue = $1 $gettok(%c.chanmodequeue,2,32) $+ $2 $gettok(%c.chanmodequeue,3-,32) $gettok($3-,1- [ $+ [ $calc($len($2) / 2) ] ] ,32)
.timer_CHANMODE -mo 1 1 _chanmode.flush
}
alias _mmode { _chanmode #$1 $str($2,$numtok($3-,32)) $3- }
alias _chanmode.flush {
tokenize 32 %c.chanmodequeue
unset %c.chanmodequeue
var %n = 1,%t = $iif(%.maxmodes,$calc(%.maxmodes - 1),2),%putquick = _putquick #$1 c&
while ($mid($2,$calc((%n * 2) - 1),$calc((%n + %t) * 2)) != $null) {
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
$iif(0,%putquick) .quote mode #$1 $mid($2,$calc((%n * 2) - 1),$calc((%n + %t) * 2)) $gettok($3-, [ %n $+ - $+ [ $calc(%n + %t) ] ] ,32)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
inc %n $calc(%t + 1)
}
}
alias _raw.ban {
if ($_queue.svars.check(ban,$1,$2)) { _chanmode $1 +b $2 }
}
alias _raw.unban {
if ($_queue.svars.check(unban,$1,$2)) { _chanmode $1 -b $2 }
.timerENFORCEBAN $+ , $+ $1 $+ , $+ $2 $+ ,* off
}
alias _raw.voice {
if ($_queue.svars.check(voice,$1,$2)) { _chanmode $1 +v $2 }
}
alias _raw.devoice {
if ($_queue.svars.check(devoice,$1,$2)) { _chanmode $1 -v $2 }
}
alias _raw.op {
if ($_queue.svars.check(op,$1,$2)) { _chanmode $1 +o $2 }
}
alias _raw.deop {
if ($_queue.svars.check(deop,$1,$2)) { _chanmode $1 -o $2 }
}
alias _raw.owner {
if ($_queue.svars.check(owner,$1,$2)) { _chanmode $1 +q $2 }
}
alias _raw.deowner {
if ($_queue.svars.check(deowner,$1,$2)) { _chanmode $1 -q $2 }
}
;;
;
; -( Kick queue )-
;
;;
alias _putkick { kick -i $$1 $$2 $3- }
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
; /_kickqueue <chan> <nick> [reason]
alias _kickqueue {
if ($_queue.svars.check(kick,$1,$2)) {
if (%c.kickqueue != $null) && ( ($gettok(%c.kickqueue,1,32) != $1) || ($gettok(%c.kickqueue,3-,32) != $3-) || ($numtok($gettok(%c.kickqueue,2,32),44) >= %.maxkicks) ) {
.timer_KICKQUEUE off
_kickqueue.flush
}
%c.kickqueue = $1 $addtok($gettok(%c.kickqueue,2,32),$2,44) $3-
.timer_KICKQUEUE -mo 1 1 _kickqueue.flush
}
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
alias _kickqueue.flush {
tokenize 32 %c.kickqueue
unset %c.kickqueue
var %chan = $1,%nicks = $2,%user,%reason = $3-,%i = 0,%n = $numtok(%nicks,44),%maxkicks = $iif($_isint(%.maxkicks),%.maxkicks,1),%toks = $iif(%maxkicks == 1,1,1- [ $+ [ %maxkicks ] ] ),%defmsg
while ($gettok(%nicks,%toks,32) != $null) {
%user = $replace($ifmatch,$chr(32),$chr(44))
%defmsg = $replace($_defmsg(kick,%reason),<CHAN>,%chan,<NICK>,%user)
if (%reason == $null) { %defmsg = $_evaltext(%defmsg) }
$iif(0,_putserv & &) .quote kick %chan %user : $+ $replace(%defmsg,<CHAN>,%chan,<NICK>,%user)
%nicks = $deltok(%nicks,%toks,32)
}
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;
; -( Support )-
;
;;
alias _queue.svars.check {
var %var = ¶__ $+ $1 $+ $chr(44) $+ $2 $+ $chr(44) $+ $3,%tmp = % [ $+ [ %var ] ]
if ($_not(%tmp)) {
inc -u4 % $+ %var
return 1
}
return 0
}
alias _queue.svars.flushall { unset %¶__*,*,* }
alias _queue.svars.flushcn { unset %¶__ $+ $1 $+ , $+ $2 $+ , $+ $3 }
alias _queue.svars.flushchan { unset %¶__ $+ $1 $+ , $+ $2 $+ ,* }
alias _queue.svars.flushnick { unset %¶__ $+ $1 $+ ,*, $+ $2 }
ON *:CONNECT:{ _queue.svars.flushall }
ON *:DISCONNECT:{ _queue.svars.flushall }
ON *:KICK:*:{
if ($knick == $me) { _queue.svars.flushchan * $chan }
else { _queue.svars.flushcn * $chan $knick }
}
ON *:NICK:{ _queue.svars.flushnick * $nick }
ON *:PART:*:{
if ($nick == $me) { _queue.svars.flushchan * $chan }
else { _queue.svars.flushcn * $chan $nick }
}
ON *:JOIN:*:{
if ($nick == $me) { _queue.svars.flushchan * $chan }
else { _queue.svars.flushcn * $chan $nick }
}
ON *:BAN:*:{ _queue.svars.flushcn ban $chan $banmask }
ON *:UNBAN:*:{ _queue.svars.flushcn unban $chan $banmask }
ON *:VOICE:*:{ _queue.svars.flushcn voice $chan $opnick }
ON *:DEVOICE:*:{ _queue.svars.flushcn devoice $chan $opnick }
ON *:OP:*:{ _queue.svars.flushcn op $chan $opnick }
ON *:DEOP:*:{
if ($opnick == $me) && ($me !isop $chan) { _queue.svars.flushchan * $chan }
_queue.svars.flushcn deop $chan $opnick
}
ON *:OWNER:*:{ _queue.svars.flushnick owner $opnick }
ON *:DEOWNER:*:{
if ($opnick == $me) && ($me !isop $chan) { _queue.svars.flushchan * $chan }
_queue.svars.flushcn deowner $chan $opnick
}