mIRC Homepage
Posted By: colt45 Checking Channel Status... - 05/10/11 11:35 AM
What I do wrong here? - I'm unable to get anything to work - I'm not expert on this scripting but doing the best I could wink

Trying to check if I'm in channel on or not (base on several networks) and if I'm not in channel (due to netsplit or such) - it'll auto join/run commands.

I've tried 2 different ways but no luck.

Code:
/scid $scon(%network1) {
    if ($chan(#chan1).status == joined) { echo @Chan.Status You are in #chan1 }
    else { echo @Chan.Status You are NOT in #chan1 | /join #chan1 }
}

or even this one doesn't work for me

Code:
/scid $scon(%network1) {
    if ($me(#chan1,$me,a)) { echo @Chan.Status You are in #chan1 }
    else { echo @Chan.Status You are NOT in #chan1 | /join #chan1 }
}


Once I got the working code, I plan to run this script on timer every 15-30 mins or so to ensure that i'm in channel all the times.

Thanks
Posted By: Wims Re: Checking Channel Status... - 05/10/11 12:26 PM
/scid or /scon are not statement that use { }, they just change the active connection used during the script, remove these {} from /scid in the first code and try
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 12:41 PM
Still doesn't work when I remove { and }
Posted By: Wims Re: Checking Channel Status... - 05/10/11 02:24 PM
How are you using these lines? In an alias?
What is the value of %network1? $scon take a number N in parameter, representing the Nth connection.
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 03:08 PM
code is written in remote not alias
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 05:26 PM
Ok, if i do this as an example (using ALIAS not REMOTE - Yea, i've changed it over from REMOTE over to ALIAS)

Code:
/CheckChan {
  /scid $scon(%Network1) {
    if ($me ison #chan1) { //echo -a You are in #chan1 }
    else { //echo -a You are not in #chan1 }
    if ($me ison #chan2) { //echo -a You are in #chan2 }
    else { //echo -a You are not in #chan2 }
    if ($me ison #chan3) { //echo -a You are in #chan3 }
    else { //echo -a You are not in #chan3 }
  }
  /scid $scon(%Network2) {
    if ($me ison #chan4) { //echo -a You are in #chan4 }
    else { //echo -a You are not in #chan4 }
    if ($me ison #chan5) { //echo -a You are in #chan5 }
    else { //echo -a You are not in #chan5 }
    if ($me ison #chan6) { //echo -a You are in #chan6 }
    else { //echo -a You are not in #chan6 }
  }
}

%network1 and %network2 has been set in variables using ON LOAD script i've wrote.

Anyway, when I type /CheckChan on Network1, It shows that I'm in #chan1, #chan2, #chan3 but saying that i'm not in #chan4, #chan5 and #chan6 frown

Now, when I do /CheckChan on Network2, it shows that i'm not in #chan1, #chan2, #chan3 but showing that i'm #chan4, #chan5 and #chan6! frown

Seems that /scid $scon(%Network1) doesn't help at all? - Removing that does not help too.

Any solution please? - My scripting isn't great and never will be :p - it's the only language I kinda understand a little.

I've tested on both mIRC 7.19 and 6.34 but no luck frown

(My english ain't great so hopefully someone can come up with a solution?)
Posted By: Wims Re: Checking Channel Status... - 05/10/11 06:19 PM
Quote:
%network1 and %network2 has been set in variables using ON LOAD script i've wrote.
Ok, but I need to know what are the values of these variables, I explained that in order for the code to work, they need to be numbers
For example (/ are optional):
Code:
CheckChan {
 scid $scon(1)
 if ($me ison #chan1) { echo -a You are in #chan1 }
 else { echo -a You are not in #chan1 }
 if ($me ison #chan2) { echo -a You are in #chan2 }
 else { echo -a You are not in #chan2 }
 if ($me ison #chan3) { echo -a You are in #chan3 }
 else { echo -a You are not in #chan3 }
 
 scid $scon(2)
 if ($me ison #chan4) { echo -a You are in #chan4 }
 else { echo -a You are not in #chan4 }
 if ($me ison #chan5) { echo -a You are in #chan5 }
 else { echo -a You are not in #chan5 }
 if ($me ison #chan6) { echo -a You are in #chan6 }
 else { echo -a You are not in #chan6 }
}
will work for the first and the second connection (the first and second status window)
Posted By: Tomao Re: Checking Channel Status... - 05/10/11 06:31 PM
There has to be a better way, but this is all I can think of at the moment:
Code:
alias checkchan {
  var %n = $scon(0)
  while (%n) {
    if ($scon(%n).network == %network1) {
      var %i = 1, %c = #chan1 #chan2 #chan3
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2) 
        inc %i
      }
    }
    elseif ($scon(%n).network == %network2) {
      var %i = 1, %c = #chan4 #chan5 #chan6
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2) 
        inc %i
      }
    }
    dec %n
  }
}
And basically you do the same thing by adding another elseif statement for another network with their own channels...so on and forth.
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 08:12 PM
Still doesn't work :s
I'm guessing I'm doing something wrong somewhere! frown

Will keep trying and will post what I've done wrong!

Thanks
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 08:16 PM
%network1 1
%network2 27
%network3 30

Originally Posted By: Wims
Quote:
%network1 and %network2 has been set in variables using ON LOAD script i've wrote.
Ok, but I need to know what are the values of these variables, I explained that in order for the code to work, they need to be numbers
For example (/ are optional):
Code:
CheckChan {
 scid $scon(1)
 if ($me ison #chan1) { echo -a You are in #chan1 }
 else { echo -a You are not in #chan1 }
 if ($me ison #chan2) { echo -a You are in #chan2 }
 else { echo -a You are not in #chan2 }
 if ($me ison #chan3) { echo -a You are in #chan3 }
 else { echo -a You are not in #chan3 }
 
 scid $scon(2)
 if ($me ison #chan4) { echo -a You are in #chan4 }
 else { echo -a You are not in #chan4 }
 if ($me ison #chan5) { echo -a You are in #chan5 }
 else { echo -a You are not in #chan5 }
 if ($me ison #chan6) { echo -a You are in #chan6 }
 else { echo -a You are not in #chan6 }
}
will work for the first and the second connection (the first and second status window)
Posted By: Tomao Re: Checking Channel Status... - 05/10/11 08:42 PM
Originally Posted By: colt45
Still doesn't work :s
I'm guessing I'm doing something wrong somewhere! frown
change
Code:
$scon(%n).network
to
Code:
$scon(%n).cid
I thought those variables were network names.
Posted By: Wims Re: Checking Channel Status... - 05/10/11 08:55 PM
These look like connection id rather than connection number.
If they are connection id, you don't have to use $scon(), use the variable directly
Posted By: Tomao Re: Checking Channel Status... - 05/10/11 09:28 PM
Yeah like Wims said, you can use something like:
Code:
if ($cid == %network1) {
to make a comparison.
Posted By: colt45 Re: Checking Channel Status... - 05/10/11 09:30 PM
Ahhh, i'm getting something! laugh

When I type this /checkchan on Network1, it shows that I'm in these channels but saying i'm not in channel for Network2 and Network3.
Quote:
{On Network1}
/checkchan
I'm NOT on #Chan4 <-- Network3
I'm NOT on #Chan3 <-- Network2
I'm ON #Chan2 <-- Network1
I'm ON #Chan1 <-- Network1

BUT when I type /checkchan on Network2, it shows that I'm in that channel on Network2 but not in channel on Network1 AND Network3?!? :s

Quote:
{On Network2}
/checkchan
I'm NOT on #Chan4 <-- Network3
I'm ON #Chan3 <-- Network2
I'm NOT on #Chan2 <-- Network1
I'm NOT on #Chan1 <-- Network1

I've changed all to $scon(%n).cid tho

Something's missing, but will keep trying ...

Thanks
Posted By: colt45 Re: Checking Channel Status... - 07/10/11 02:58 PM
Anyone know how to fix this?
Posted By: colt45 Re: Checking Channel Status... - 12/10/11 01:57 AM
I'm sorry, I couldn't get this to work.

Only works on 1 or other server where I type the command.

This is the exact code I'm using right now (except the channel name).

Code:
alias checkchan {
  var %n = $scon(0)
  while (%n) {
    if ($scon(%n).network == Kwik-Chat) {
      var %i = 1, %c = #channel1 #channel2
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
        inc %i
      }
    }
    elseif ($scon(%n).network == EFNet) {
      var %i = 1, %c = #channel3
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
        inc %i
      }
    }
    dec %n
  }
}


On Kwik-Chat, when I type /checkchan I see this as result
Quote:
I'm ON #channel1
I'm ON #channel2
I'm NOT on #channel3


But, on EFNet, when I type /checkchan I see this as result
Quote:
I'm NOT on #channel1
I'm NOT on #channel2
I'm ON #channel3


Please help,
Thanks
Posted By: Tomao Re: Checking Channel Status... - 12/10/11 04:17 AM
Use this one and see if it makes any difference:
Code:
alias checkchan {
  var %x = 1
  while ($scon(%x).network) {
    if ($regex($v1,/(Kwit-Chat|EFNet)/i)) {
      if ($regml(1) == EFNET) {
        var %i = 1, %c = #channel3
        while ($gettok(%c,%i,32)) { 
          var %v1 = $v1
          echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
          inc %i
        }
      }
      else {
        var %ii = 1, %cc = #channel1 #channel2
        while ($gettok(%cc,%ii,32)) { 
          var %v1 = $v1
          echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
          inc %ii
        }
      }
    }
    inc %x
  }
}
Posted By: colt45 Re: Checking Channel Status... - 12/10/11 01:49 PM
Seems to be worse frown

Quote:
I'm NOT on #channel3

Showing only 1 line .. that done on Network1.

Quote:
I'm ON #channel3

Showing only 1 line .. that done on Network2.

I don't want to run that command on every network i'm on.

What I need is to show all channel's result from several network. When I'm not in any of the channel, it'll perform by identify myself before joining channel(s).

I'm guessing it's more advance than I thought? - As I don't want to identify myself and join channel every 5 mins or so? - Hence why i need a better script especially when u have quite a lot of channels/network.

(Sorry if my english isnt clear but I will get a friend to help translate for me if you prefer?)

Thanks
Posted By: Tomao Re: Checking Channel Status... - 12/10/11 07:09 PM
I think I've hit the wall at my end. I'm afraid I cannot be of help to you. I hope somebody else, who has a better approach or idea, can assist you further with the issue at hand. eek
Posted By: Riamus2 Re: Checking Channel Status... - 12/10/11 09:32 PM
Try this:

Code:
alias checkchan {
  var %c = 1, %t = $scon(0)
  while (%c <= %t) {
    scon %c
    if ($network == network1) {
      echo -a NETWORK: $network
      echo -a I'm $iif($me !ison #chan1,NOT) on $v2
      echo -a I'm $iif($me !ison #chan2,NOT) on $v2
    }
    elseif ($network == network2) {
      echo -a NETWORK: $network
      echo -a I'm $iif($me !ison #chan3,NOT) on $v2
      echo -a I'm $iif($me !ison #chan4,NOT) on $v2
    }
    inc %c
  }
}


This will not display "not on" messages for networks that you are not connected to.

* Note that I know there is some security issue with using scon/scid, but I'm not real clear on what it is. Hopefully someone who understands it can decide if this is safe. smile

EDIT:
Here's another option that would work if you have many networks and channels:
Code:
alias checkchan {
  var %network1 = #chan1 #chan2
  var %network2 = #chan3 #chan4
  var %c = 1, %t = $scon(0)
  while (%c <= %t) {
    scon %c
    if ($($+(%,$network),2)) {
      echo -a NETWORK: $network
      var %cc = 1, %ct = $numtok($($+(%,$network),2),32)
      while (%cc <= %ct) {
        var %chan = $gettok($($+(%,$network),2),%cc,32)
        echo -a I'm $iif($me !ison %chan,NOT) on $v2        
        inc %cc
      }
    }
    inc %c
  }
}


For this one, be sure to change the network variable names to be exactly the same as what $network returns. For example:
var %undernet = #chan1 #chan2
var %efnet = #chan3 #chan4
Posted By: colt45 Re: Checking Channel Status... - 12/10/11 11:04 PM
Tomao : Many appreciated for your help .. at least you've tried.

Riamus2 : your code works best but not 100% (currently using your 2nd code - both seems to work but I prefer 2nd code ;p) .. for some reason it would not should result on the first network which is cid=1 ? - It only reads from Network2, Network3, etc.. but not Network1 if u know what i mean?

One small thing? - If i'm not in channel, how do I get it to run a command by joining channel?

Thanks
Posted By: Wims Re: Checking Channel Status... - 12/10/11 11:12 PM
The problem of security with scid and scon is the same as the one with timer: the parameter of the command is a command itself, which cause the double evaluation; however, scid and scon can be used without a command as a parameter (and you used it that way), in this case there's no problem of double evaluation
Posted By: Riamus2 Re: Checking Channel Status... - 13/10/11 12:13 AM
Thanks for the clarification, Wims.

@colt: Check what $network equals on whatever network isn't displaying and make absolutely certain it's the same in the script. I've tested this with multiple networks and they are all showing. That doesn't mean there isn't an error, but I don't currently see one. (You can type //echo -a $network on that network to verify what it is). You might also try changing which network is first and then run this again. If it's always the same network (instead of always the first network), then you'll know it's due to a difference in $network and what you have in the script as the variable name.

As far as running commands, you're already doing that with the /echo commands. Just use an IF to check connection (instead of the $iif in the middle of the echo)...

Example:
Code:
if ($me !ison %chan) { join %chan }
Posted By: colt45 Re: Checking Channel Status... - 13/10/11 01:12 AM
I made a mistake with network name (blush typo blush) .. forgot to add the "dash" in network name i.e. EFNET instead of EF-NET

Yea, it's looking good (so far) .. i will start adding channels, networks now and see how it is goes and hopefully it's just how I wanted wink

Many thanks for your help!

For the commands to perform the script if I'm not in channel, I've tried and it works too .. thanks again laugh
Posted By: Tomao Re: Checking Channel Status... - 13/10/11 02:23 AM
Wow gee thanks Riamus2. I never thought it could be that easy. I overcomplicated myself. Thanks for your rescue.

Yeah I tried but sort of failed, colt45. I'm glad you have a working code now. wink
© mIRC Discussion Forums