; RPL_iSupport 005 CNOTICE / CPRIVMSG to avoid 439 Target change too frequently message
raw 005:*: { iSupport.Raw005 $1- }
on *:disconnect: { iSupport.Disconnect }
alias -l iSupport.Raw005 {
; Remove trailing ":are supported by this server"
var %new $replace($2-, are supported by this server,$null)
var %is $iSupport.Name
var %old [ [ %is ] ]
var %n = $numtok(%new,$asc($space)), %i 1
while (%i <= %n) {
var %n = $gettok(%new,%i,$asc($space)), %d $left(%n,1)
if (%d == -) %n = $right(%n,-1)
var %m %n $+ *
var %j $wildtok(%old,%m,0,$asc($space))
while (%j) {
var %o $wildtok(%old,%m,%j,$asc($space))
if ((%n == %o) || ($+(%n,=*) iswm %o)) %old = $remtok(%old,%o,0,$asc($space))
dec %j
}
if (%d != -) %old = %old $iSupport.Decode(%n)
inc %i
}
set -e [ [ %is ] ] $sorttok(%old,$asc($space),a)
}
alias -l iSupport.Decode {
return $regsubex(iSupport.Decode,$1,/(\\x[0-9A-Fa-f]{2})/Fg,$chr($base($right(\t,2),16,10)))
}
alias -l iSupport.Disconnect {
unset [ $iSupport.Name ]
}
alias -l iSupport.Name { return $+(%,ISUPPORT.,$network) }
alias -l iSupport.Supports {
var %p [ [ $iSupport.Name ] ]
var %m $1 $+ *
var %i $wildtok(%p,%m,0,$asc($space))
while (%i) {
var %q $wildtok(%p,%m,%i,$asc($space))
if ($1 == %q) return $true
if ($+($1,=*) iswm %q) return $deltok(%q,1,$asc(=))
dec %i
}
return
}
; The following provide iSupport equivalents for /msg, /describe, /notice, /ctcp and /ctcpreply
; So that if you are an op you can send frequent messages to other users withourt triggering
alias -l msg {
var %c $iSupport.ComChanOp($1)
if (($iSupport.Supports(CPRIVMSG)) && (%c) && ($left($1,1) !isin $chantypes)) .raw CPRIVMSG $1 %c : $+ $2-
else .msg $1-
if ($show) echo -ac Normal -> $+(*,$1,*) $2-
}
alias -l describe {
.ctcp $1 Action $2-
if ($show) echo -ac Action -> $+(*,$1,*) $2-
}
alias -l notice {
var %c $iSupport.ComChanOp($1)
if (($iSupport.Supports(CNOTICE)) && (%c) && ($left($1,1) !isin $chantypes)) .raw CNOTICE $1 %c : $+ $2-
else .notice $1-
if ($show) echo -ac Normal -> $+(-,$1,-) $2-
}
alias -l ctcp {
var %c $iSupport.ComChanOp($1)
var %msg $upper($2) $3-
if (($iSupport.Supports(CPRIVMSG)) && (%c) && ($left($1,1) !isin $chantypes)) .raw CPRIVMSG $1 %c : $+ $iSupport.ctcpEncode(%msg)
else .ctcp $1-
if ($show) echo -ac Ctcp -> $+([,$1,]) $upper($2) $3-
}
alias -l ctcpreply {
var %c $iSupport.ComChanOp($1)
if (($iSupport.Supports(CNOTICE)) && (%c) && ($left($1,1) !isin $chantypes)) .raw CNOTICE $1 %c : $+ $iSupport.ctcpEncode($2-)
else .ctcpreply $1-
if ($show) echo -ac Ctcp -> $+([,$1,]) $2-
}
alias -l iSupport.ctcpEncode {
var %s $replacex($1-,$chr(16),$+($chr(16),$chr(16)),$chr(0),$+($chr(16),$chr(48)),$chr(10),$+($chr(16),$chr(110)),$chr(13),$+($chr(16),$chr(114)))
return $+($chr(1),%s,$chr(1))
}
alias -l iSupport.ComChanOp {
if ($left($1,1) isin $chantypes) return $false
var %i $comchan($1,0)
while (%i) {
if ($comchan($1,%i).op) return $comchan($1,%i)
dec %i
}
return $false
}