mIRC Home    About    Download    Register    News    Help

Print Thread
#77809 04/04/04 05:20 AM
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
Quite some time ago, I asked for a script that would parse out the channel modes when they changed. The code was as follows:

Code:
; 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-
    }
}
 

I was rather inexperienced in mIRC scripting at the time, but today I realized why this script didn't work. For some reason, when the alias is called, the entire script is sent directly to the network instead of actually being executed. Anyone know why that is?


Kewlio
Insanity is all I have to keep from becoming insane.
#77810 04/04/04 04:34 PM
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
Maybe it'd help if I told you it's supposed to work with this remote code:

Code:
on *:rawmode:#:{
/modes $1-
var %m = 1
while ($modes(%m).chr) {
  ;
  ; ---------- Addition
  ; limit (+l)
  if ($modes(%m).mode == +l) /echo 14 -t # 8MODE: 7User Limit to $modes(%m) <- $nick
  ; key (+k)
  if ($modes(%m).mode == +k) /echo 14 -t # 8MODE: 7Password is $modes(%m) <- $nick
  ; ops set topic (+t)
  if ($modes(%m).mode == +t) /echo 14 -t # 8MODE: 7Topic Lock <- $nick
  ; moderated (+m)
  if ($modes(%m).mode == +m) /echo 14 -t # 8MODE: 7Channel Moderation <- $nick
  ;
  ; ---------- Removal
  ; no limit (-l)
  if ($modes(%m).mode == -l) /echo 14 -t # 8MODE: 7No User Limit <- $nick
  ; no key (-k)
  if ($modes(%m).mode == -k) /echo 14 -t # 8MODE: 7Password removed <- $nick
  ; anyone sets topic (-t)
  if ($modes(%m).mode == -t) /echo 14 -t # 8MODE: 7Topic Unlock <- $nick
  ; no moderation (-m)
  if ($modes(%m).mode == -m) /echo 14 -t # 8MODE: 7Free Chat <- $nick
  ;    /inc %m
}
}


Kewlio
Insanity is all I have to keep from becoming insane.
#77811 04/04/04 04:58 PM
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
...Okay. Well, I fixed it so that it actually tries to work. Problem now is, it does absolutely nothing. Any help?


Kewlio
Insanity is all I have to keep from becoming insane.

Link Copied to Clipboard