; new mode identifier
; by kingtomato
; -
; usage:
; after using $mode for so ling, and trying to match up the letter
; with the appropriate $mode(N), I got tired of it. So I write a
; lil snipplet that does just that. The way it works is just like
; $mode when no proerties are attached. When they are attached, it
; can return the character of mode N, or its associated parameter.
; i.e. a ban will return b for its character, and the nick/mask
; thats being banned for its parameter. Here's the break down:
;
; syntax:
; $modes(N)
; Gets the Nth mode
; Properties:
; .chr - Gets the mode character associated with the mode
;
; syntax 2:
; /modes <modes>
; modes - the current mode string being set. Because this is a
; custom identifier, I have no means of having it be
; 'auto called' with the mode change. What you have to do
; is call this before using the variable. Much like a dialog
; dll such as mdx, you have to 'set' the modes we're going
; to be parsing before you can use them.
;
; So for example, something like a mode change of:
; +ovp KingTomato KingTomato
; would return:
;
; $modes(1) = KingTomato (Like Normal)
; $modes(1).chr = o
;
; $modes(2) = KingTomato (Again, normal)
; $modes(2).chr = v
;
; $modes(3) = $null
; $modes(3).chr = p
modes {
; if it if being used as an identifier ($modes)
if ($isid) {
; set a variable that's easy to work with
var %modes = %unique_modes_var | ; variable we are parsing
var %mode = $gettok(%modes, 1, 32) | ; just the +this-that part
; here we loop through each letter of the mode change. When we find
; one that has params that should be associated to it, we put both
; the letter, and the parameter together seperated by a colon. If
; a colon should conflict, then please change the variable below to
; another char.
var %param = 2 | ; Starting gettok value for associations
var %letter = 1 | ; letter number we're lookin at in %mode
var %modeNum = 1 | ; numeric count of the current mode (compared to $1)
var %delim = : | ; this is what will seperate the letter from the param
; begin to loop through the %mode value
while ($mid(%modes, %letter, 1)) {
; easier to deal with
var %chr = $ifmatch
; check for a mode sign (+/-)
if (%chr isin +-) var %sign = %chr
; not a sign, its a letter
else {
; check for a letter that has a paramter with it
if ((%chr isincs $gettok($chanmodes, 1-3, 44)) || (%chr isincs qaohv)) {
; this has a mode, now we get the parameter that corrisponds to it
var %curMode = $+(%sign,%chr,$chr(%delim),$gettok(%modes, %param, 32))
; add it to the list of modes
var %modeList = %modeList %curMode
; we used a param, increase the coutner
/inc %param
}
; its jsut a letter mode (like +s, +p, etc)
else var %modeList = %modeList $+(%sign,%chr)
; check if this is a mode the user is requesting
if ($1 == %modeNum) {
; do they want the chr, or its mode
if ($prop == chr) return %chr
else return $mid(%curMode, 3)
}
; moving onto next mode, increase count
/inc %modeNum
}
; goto next letter
/inc %letter
}
; 0 as a mode, for total count
if ($1 == 0) return %curMode
; default
return $null
}
; being used as a command
else {
; I'd use some var like %modes, but i don't want it to interfere
; with other's scripts. I'm also using /set because we're not parsing
; what's being passed, just setting it into somethign we can deal with
; when the time comes
/set -u0 %unique_modes_var $1-
}
}