aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / script / ignores.mrc
ignores.mrc — 8.94 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Ignores
; *
; **********************************************************************/
alias _start.ignores {
var %file = $_igninifile,%win = @__start.ignores,%i = 1,%n
_openwins %win
loadbuf %win " $+ %file $+ "
%i = $ignore(0)
while (%i) {
if ($ignore(%i).type != exclude) { .ignore -r $ignore(%i) }
dec %i
}
%i = 1
%n = $line(%win,0)
while (%i <= %n) {
tokenize 32 $line(%win,%i)
if ($4) {
if ($calc($3 + $4) <= $ctime) {
.ignore -r $1
dline %win %i
dec %n
dec %i
}
else { .ignore $5 $+ u $+ $calc($3 + $4 - $ctime) $1 }
}
else { .ignore $5 $1 }
inc %i
}
savebuf %win " $+ %file $+ "
close -@ %win
}
alias ignorelist {
var %d = _ignorelist
_dialog -m %d %d
_ignorelist.load
_ignorelist.timer
}
alias _ignorelist.load {
var %file = $_igninifile,%win = @__loadignorelist,%i = 1,%n,%d = _ignorelist
did -r %d 100,101
_start.ignores
_openwins %win
loadbuf %win $"(%file)
%n = $line(%win,0)
while (%i <= %n) {
tokenize 32 $line(%win,%i)
did -a %d 100 $1
did -a %d 101 $1-
inc %i
}
close -@ %win
_ignorelist.ad
}
alias _ignorelist.timer {
var %file = $_igninifile,%d = _ignorelist
if ($dialog(%d) == $null) { return }
if ($lines(%file) != $ignore(0)) { _start.ignores }
if ($ignore(0) != $did(%d,100).lines) { _ignorelist.load }
.timer -o 1 0 _ignorelist.timer
}
alias _ignorelist.ad {
var %d = _ignorelist,%l,%t,%dida = _dida %d 110
did -r %d 110
%l = $did(%d,100).sel
if (%l == $null) { return }
tokenize 32 $did(%d,101,%l)
%t = $1
%t = %t $+ $crlf $+ set by $2
%t = %t $+ $crlf $+ on $_date($3)
if ($4) {
%t = %t $+ $crlf $+ duration: $_duratio($4)
%t = %t $+ $crlf $+ expires: $_date($calc($3 + $4))
}
%t = %t $+ $crlf $+ Ignoring:
if (p isincs $5) { %t = %t $+ $crlf - (p) private }
if (c isincs $5) { %t = %t $+ $crlf - (c) channel }
if (n isincs $5) { %t = %t $+ $crlf - (n) notice }
if (t isincs $5) { %t = %t $+ $crlf - (t) ctcp }
if (i isincs $5) { %t = %t $+ $crlf - (i) invite }
if (k isincs $5) { %t = %t $+ $crlf - (k) control codes }
%t = %t $+ $crlf $+ comment: $6-
%dida %t
}
alias _ignorelist.clear {
if ($_yesno(1,Ignore List [/ignorelist],0,Clear ignore list?)) {
_ignore.rem *
_ignorelist.load
}
}
dialog _ignorelist {
title "Ignore List [/ignorelist]"
size -1 -1 185 125
option dbu
list 100,5 5 90 100
list 101,5 5 90 100,hide
text "",110,100 5 80 94,multi
button "&Add",400,10 105 30 15
button "&Del",401,55 105 30 15
button "C&lear",402,100 105 30 15
button "&Close",403,145 105 30 15,cancel
}
ON *:DIALOG:_ignorelist:init:0:{
_mdx.init $_icofile(ignorelist.ico)
_dummy $_lang.loaddialog($dname,$dname,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:_ignorelist:sclick:100:{ _ignorelist.ad }
ON *:DIALOG:_ignorelist:sclick:400:{ .timer -o 1 0 _ignore.dialog }
ON *:DIALOG:_ignorelist:sclick:401:{
var %d = $dname,%l = $did(%d,100).sel
-ignore $did(%d,100,%l)
_ignorelist.load
if (%l <= $did(%d,100).lines) { did -c %d 100 %l }
_ignorelist.ad
}
ON *:DIALOG:_ignorelist:sclick:402:{ .timer -o 1 0 _ignorelist.clear }
alias _ignore {
var %i = 1,%n
while ($gettok($1,%i,44)) {
%n = $ifmatch
if ($2) { .ignore -u $+ $2 %n }
else { .ignore %n }
_closequery %n
inc %i
}
}
alias _ignore.addtemp {
var %duration = $round($_getsetup(script,ignore-time),0),%switches = -pcntik
if ($_not($_isint(%duration))) { %duration = 15 }
%duration = %duration * 60
if (-* iswm $1) {
%switches = $remove($1,u,1,2,3,4,5,6,7,8,9,0)
tokenize 32 $2-
}
%switches = %switches $+ u $+ %duration
tokenize 32 $_parameter($1,1,Ignore User [/ignore],replace 32 44,$_activequery,Temp ignore <nicks|masks>:<CRLF>[separated by commas]) $2-
_ignore.add %switches $1 $2-
}
alias _ignore.addperm {
var %switches = -pcntik
if (-* iswm $1) {
%switches = $remove($1,u,1,2,3,4,5,6,7,8,9,0)
if (%switches == -) { %switches = -pcntik }
tokenize 32 $2-
}
tokenize 32 $_parameter($1,1,Ignore User [/ignore],replace 32 44,$_activequery,Temp ignore <nicks|masks>:<CRLF>[separated by commas]) $2-
_ignore.add %switches $1 $2-
}
alias _ignore.add {
if (-* !iswm $1) { tokenize 32 -pcntik $1- }
var %i = 1,%n = $numtok($2,44),%t
while (%i <= %n) {
%t = $gettok($2,%i,44)
if ($_ismask(%t)) { +ignore $1 $_fixmask(%t) $3- }
elseif ($_getaddress(%t,%_masknorm)) { +ignore $1 $ifmatch $3- }
else { _nickhost %t %_masknorm _donothing $iif($_not($show),.) $+ +ignore $1 <MASK> $3- }
inc %i
}
}
alias _ignore.rem {
var %i = 1,%n = $numtok($1,44),%t
while (%i <= %n) {
%t = $gettok($1,%i,44)
if ($_ismask(%t)) { __ignore.rem $_fixmask(%t) }
elseif ($_getaddress(%t)) { __ignore.rem $ifmatch }
else { _nickhost %t 5 _donothing $iif($_not($show),.) $+ __ignore.rem <ADDR> }
inc %i
}
}
;;
;
; /__ignore.rem <mask|wildcard>
;
alias __ignore.rem {
var %i = $ignore(0),%n,%total = 0
_start.ignores
while (%i) {
%n = $ignore(%i)
if (%n iswm $1) || ($1 iswm %n) {
inc %total
-ignore %n
if ($ignore(%i) == %n) { ignore -r %n }
}
dec %i
}
if (%total == 0) && ($show) { info.a No ignores matching $^'($1) }
return %total
}
alias _ignore.dialog {
if (-* !iswm $1) { tokenize 32 -pcntik $1- }
tokenize 32 $1 $_parameter($2,1,Ignore user [/ignore],replace 32 44,$_activequery,Ignore <nicks|masks>:<CRLF>[separated by commas]) $3-
if ($_ismask($2)) { __ignore.dialog $_fixmask($2) $1- }
elseif ($_getaddress($2)) { __ignore.dialog $ifmatch $1- }
else { _nickhost $2 5 _donothing $iif($_not($show),.) $+ __ignore.dialog <ADDR> $1- }
}
alias __ignore.dialog {
var %d = ignoreuser,%toks,%i = 0,%m,%duration
_dialog -m %d %d
did -r %d 100,131,141,150
did -u %d 110,111,112,113,114,115,120,130,140
did -c %d 120
did -o %d 131,141 1 15
if ($_isfullmask($1)) {
while (%i <= 19) {
%m = $_mask($1,%i)
if ($istok(%toks,%m,32) == $false) {
if (%m == $_mask($1,%_masknorm)) { did -ac %d 100 %m }
else { did -a %d 100 %m }
}
%toks = $addtok(%toks,%m,32)
inc %i
}
}
else {
did -ac %d 100 $1
%toks = $1
}
if (* !isin $gettok($1,1,33)) && (? !isin $gettok($1,1,33)) {
%m = $gettok($1,1,33) $+ !*@*
if ($istok(%toks,%m,32) == $false) { did -a %d 100 %m }
%toks = $addtok(%toks,%m,32)
}
if ($did(%d,100).sel == $null) { did -c %d 100 1 }
%i = 1
while (%i <= 6) {
if ($mid(pcntik,%i,1) isincs $2) { did -c %d $calc(109 + %i) }
inc %i
}
if (u isincs $2) {
%duration = $remove($2,-,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
if ($_isint(%duration)) {
did -u %d 120
if ($calc(%duration / 60) == $int($calc(%duration / 60))) {
did -o %d 131 1 $ifmatch
did -c %d 130
}
else {
did -o %d 141 1 %duration
did -c %d 140
}
}
}
did -o %d 150 1 $4-
did $iif($did(%d,130).state,-e,-b) %d 131
did $iif($did(%d,140).state,-e,-b) %d 141
}
dialog ignoreuser {
title "Ignore User"
size -1 -1 130 184
option dbu
combo 100,10 15 110 900,edit drop
check "Private",110,15 48 50 8
check "Channel",111,70 48 50 8
check "Notice",112,15 58 50 8
check "CTCP",113,70 58 50 8
check "Invite",114,15 68 50 8
check "Control Codes",115,70 68 50 8
radio "Permanent",120,10 97 35 8
radio "Minutes:",130,10 107 35 8
edit "",131,48 106 20 10,autohs
radio "Seconds:",140,10 117 35 8
edit "",141,48 116 20 10,autohs
edit "",150,10 145 110 10,autohs
box "Address",350,5 5 120 28
box "Switches",351,5 38 120 45
box "Duration",352,5 87 120 45
box "Comment",353,5 135 120 25
button "&Ignore",400,5 165 30 15,ok
button "&Cancel",401,50 165 30 15,cancel
button "&Help",402,95 165 30 15
}
ON *:DIALOG:ignoreuser:init:0:{
_mdx.init $_icofile(ignorelist.ico)
_dummy $_lang.loaddialog($dname,_ignoreuser,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:ignoreuser:sclick:120:{ did -b $dname 131,141 }
ON *:DIALOG:ignoreuser:sclick:130:{
did -e $dname 131
did -b $dname 141
}
ON *:DIALOG:ignoreuser:sclick:140:{
did -b $dname 131
did -e $dname 141
}
ON *:DIALOG:ignoreuser:sclick:400:{
var %switches,%duration,%mask = $_fixmask($did(100)),%i = 1
while (%i <= 6) {
if ($did($calc(%i + 109)).state) { %switches = %switches $+ $mid(pcntik,%i,1) }
inc %i
}
if (%switches == $null) || ($_not($_ismask(%mask))) { halt }
if ($did(130).state) && ($_isint($did(131))) { %duration = u $+ $calc($ifmatch * 60) }
if ($did(140).state) && ($_isint($did(141))) { %duration = u $+ $ifmatch }
%switches = - $+ %switches $+ %duration
+ignore %switches %mask $did(150)
}