/*_____________________________________________________________________________ |/ / IML add-on by David "Saturn" van Moolenbroek | Version 0.1, released 03-11-2003 -- support on #help.script/Quakenet | Use/modify however you want, but please keep my name in it. Thank you! | | Keywords: internal mode list, +e/+I, hashtables, multi-server | | This add-on provides a generic way of keeping track of list modes, of | which the ban (+b) is best known. The main purpose of this add-on is to | save all other similar modes (for example, +e and +I on some networks) | into hashtables, so they can be retrieved later in a way very similar to | $ibl. The script does this for all parameter-taking modes from what's | in $chanmodes, and also has built-in support for the raws of the modes +e | and +I. Manipulation of the modes lists can be done with /iml, and the | lists can be retrieved using $iml. $iml also provides a standard way of | the information $chan().ibl provides about $ibl, see below for details. | Modes are always one case-sensitive letter, like "e" or "I"; note that if | "b" is used as mode, /iml will do nothing, and $iml will get its | information from $ibl, in order to not save the same information twice. | | The script defines the following commands/identifiers: | | /iml add [ []] | | This command adds entry for mode letter on on the | current connection, eventually including information on who set the | entry, and when the entry was set. | | /iml del | | Deletes entry for mode letter on on the current | connection. | | /iml clear [ []] | | This command deletes all entries for mode letter on channel | , or all entries for all modes on if is omitted, or | all data for the current connection if is also omitted. It also | resets the mode status for any affected modes/channels. | | /iml mode [start|end] | | This sets the mode status of the given mode on the given channel on the | current connection; "start" means a /who is in progress, "end" means the | /who is done. If the mode status has been set to "end" already, this | command will have no further effect. | | $iml(#chan,mode) | | Returns the mode status of the given mode on the given channel on the | current connection: $true if the script has seen a /who for this mode, | $inmode if a /who is still in progress, and $false otherwise. This is | similar to what $chan().ibl returns for mIRC's internal ban list. | | $iml(#chan,mode,N) | | Properties: by, date, ctime | | Returns the Nth entry for the given mode on the given channel on the | current connection. The properties return information about who set the | mode entry and when, just like $ibl, and they may return $null. | | $iel(#chan,N) and $iil(#chan,N) | | Shortcuts for respectively $iml(#chan,e,N) and $iml(#chan,I,N), provided | for convenience. As with $iml, the N parameter may be omitted, or any of | the properties of $iml may be used. | | Simple example | |\ ; list all ban exceptions for the current channel | \ var %i = 1 * | while (%i <= $iel(#,0)) { | echo -a Ban exception: $iel(#,%i) | inc %i * | } | * echo -a End of ban exceptions list \ _\_____________________________________________________________________________ */ alias iil return $iml($1,I,$2) [ $+ [ $iif($prop,. $+ $prop) ] ] alias iel return $iml($1,e,$2) [ $+ [ $iif($prop,. $+ $prop) ] ] raw 346:*:.iml mode $2 I start | .iml add $2 I $3- raw 347:*:.iml mode $2 I end raw 348:*:.iml mode $2 e start | .iml add $2 e $3- raw 349:*:.iml mode $2 e end on me:*:JOIN:#:.iml clear $chan on me:*:PART:#:.iml clear $chan on *:KICK:#:if ($knick == $me) .iml clear $chan on *:LOGON:*:iml clear on *:DISCONNECT:iml clear on *:RAWMODE:#:{ var %c, %d = +, %i = 0, %p = 1, %m = $1 tokenize 44 $chanmodes if ($0 < 4) tokenize 32 $1-3 imnpst while (%i < $len(%m)) { inc %i var %c = $mid(%m,%i,1) if (%c isin +-) { %d = %c | continue } if (%c isletter $4) continue if (%c isletter $1) .iml $iif(%d == +,add,del) $chan %c $mode(%p) $fulladdress $ctime if ((%d == +) || (%c !isletter $3)) inc %p } } alias -l table return $+(iml.,$cid,.,$iif($1 != $null,$encode($lower($1),m),*),.,$iif($2 != $null,$asc($2),*)) alias iml { tokenize 32 $1- if ($isid) { ; too few parameters if ($0 < 2) return ; invalid parameters if (($1 !ischan) || ($2 !isletter)) return $iif($0 < 3,$false,$iif(!$3,0)) ; if it's about bans, then redirect to $ibl or $chan().ibl if ($2 === b) { if ($0 < 3) return $chan($1).ibl return $ibl($1,$3) [ $+ [ $iif($prop,. $+ $prop) ] ] } ; check the mode list status if ($0 < 3) return $iif($hget(iml.mode,$table($1,$2)),$ifmatch,$false) ; return the number of entries if (!$3) return $hget($table($1,$2),0).item ; return the entry, or a property of this entry if ($prop == by) return $gettok($hget($table($1,$2),$3).data,2,32) elseif ($prop == date) return $asctime($gettok($hget($table($1,$2),$3).data,3,32),mmm doo h:nntt) elseif ($prop == ctime) return $gettok($hget($table($1,$2),$3).data,3,32) else return $hget($table($1,$2),$3).item } ; check whether we have been given enough parameters if (($0 < 1) || ((($1 == add) || ($1 == del)) && ($0 < 4)) || (($1 == mode) && ($0 < 3))) { echo $color(info) -aeqt * /iml: insufficient parameters return } ; check whether the given parameters are valid if ((($0 > 2) && ($2 !ischan)) || (($0 > 3) && ($3 !isletter))) { echo $color(info) -aeqt * /iml: invalid parameters return } ; ignore bans, mIRC can handle them if ($3 === b) return ; add element if ($1 == add) hadd -m $table($2,$3) $4 $true $5- ; delete element elseif ($1 == del) { if ($hget($table($2,$3))) hdel $table($2,$3) $4 } ; delete all elements or even all data elseif ($1 == clear) { if ($hget(iml.mode)) hdel -w iml.mode $table($2,$3) hfree -w $table($2,$3) } ; set mode status elseif (($1 == mode) && (($4 == start) || ($4 == end))) { if ($hget(iml.mode,$table($2,$3)) == $true) return hadd -m iml.mode $table($2,$3) $iif($4 == start,$!inmode,$true) } ; something else, display an error else echo $color(info) -aeqt * /iml: invalid parameters }