mIRC Home    About    Download    Register    News    Help

Print Thread
Returning the $active $network? #181675 28/07/07 08:25 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
How do you do that? How do you return the $network of $active?

2.) $!scon($activecid).network won't return after disconnected servers. For example.

Connected network
Connected network
Disconnected network.
Connected network.

$!scon($activecid).network will only work for the 1st 2 networks I'm connected to, it won't work after the 3rd.

Also, could anyone think they could make a $comnet() identifier for me? $comnet(), as opposed to $comchan().

I was also for hoping for a $comchanmask(), where you can $comchanmask(*!*@host,N) and return comchans by the host, not by nick.

Thanks..

-Neal.

Re: Returning the $active $network? [Re: LostShadow] #181677 28/07/07 09:13 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
First of all I wouldn't think you would have trouble returning $network of $active.

I would use scon and a loop.
Code:
alias get_net {
var %scon = $scon(0), %ch | while (%scon) {
scon %scon
%ch = $chan(0) | while (%ch) {
if ($chan(%ch) == $1) return $network
dec %ch
}
dec %scon
}
}


echo -a Network for $active is $get_net($active) $+ !

Now this is a round about way to do it, but without testing on your networks and your mirc/computer this is the best way I could think of.

Re: Returning the $active $network? [Re: LostShadow] #181678 28/07/07 09:44 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The problem is you're passing a connection ID ($activecid) to $scon(), which accepts a connection number (ie. the N'th connection).

$scid($activecid).network should work fine


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Returning the $active $network? [Re: starbucks_mafia] #181679 28/07/07 10:03 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Okay thanks, that works.

Now I'm trying to echo to that network.

I could have.

/echo -s Blah for an on text event.

But if I'm on a lot of servers, then I have a status window for every server. And an on text event, I may have several status windows to check in. So I'm trying to get it to /echo -s my my $active status window.

I tried..

/scon -a if ($network == $scid($activecid).network) /echo -s Blah

* If invalid format..

Thanks.

Re: Returning the $active $network? [Re: LostShadow] #181680 28/07/07 10:03 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Here's a simple $comchanmask I slapped together. It relies on the Internal Address List (IAL), so if you want it to always work 100% accurately you'll need to fill your IAL upon joining channels by issuing a command like /who #channelname. Note that I only just wrote this so you should probably test it a bit to make sure it works correctly before doing anything important with it.

Code:
alias comchanmask {
  ; Usage: $comchanmask(hostmask, N)
  var %i = 1, %chans, %parm2 = $int($2), %c
  while $chan(%i) {
    %c = $v1
    if ($ialchan($1, %c, 0)) {
      %chans = $addtok(%chans, %c, 32)
      if ($numtok(%chans, 32) == %parm2) return %c
    }
    inc %i
  }
  if (%parm2 == 0) return $numtok(%chans, 32)
}


As for the $comnet, I'm not sure exactly what you're looking for. Do you want it to take a nickname and return common networks based on nicks which you can see (ie. that you share at least one channels with on a network) or do you want it to actually check if that nick exists anywhere on that network (if so, it won't be possible to write an identifier that does that).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Returning the $active $network? [Re: LostShadow] #181681 28/07/07 10:21 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
To echo to the status window of a specific connection (and knowing the connection ID of that connection) just prefix the echo command with "/scid N" where N is the connection ID, e.g.
Code:
//var %cid = $activecid | /scid %cid echo -s this window is the status window of $scid($activecid).network

Last edited by Horstl; 28/07/07 10:22 PM.
Re: Returning the $active $network? [Re: starbucks_mafia] #181682 28/07/07 10:29 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Okay it works.

Originally Posted By: starbucks_mafia
As for the $comnet, I'm not sure exactly what you're looking for. Do you want it to take a nickname and return common networks based on nicks which you can see (ie. that you share at least one channels with on a network) or do you want it to actually check if that nick exists anywhere on that network (if so, it won't be possible to write an identifier that does that).


The 1st one. And thanks for the code. laugh

Re: Returning the $active $network? [Re: LostShadow] #181683 28/07/07 10:31 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well you're going to more trouble than you need to with that code. You can echo to the active connection's status window with this:

Code:
/scid $activecid echo -s Blah


The reason your code wasn't working is because of the way mIRC treats the /scon and /scid commands. The thing to remember is that /scon and /scid behave like /timer, so all of their parameters are evaluated twice: Once for the script's default connection and then again for the connection you set it to. For your original code to work you'd have to prevent the identifiers from being evaluated on the first "pass" by either using $eval(code, 0) or the ! prefix on each identifier. eg.

Code:
/scon -a if ( $!network == $!scid($activecid).network ) /echo -s Blah


Note that there's still a potential bug there if you happen to connect to the same network twice, so you're better off using the "/scid $activecid echo -s Blah" method

It's important to consider this double evaluation behaviour when echo'ing text sent by other people. For example if you planned to change your code to:
Code:
on *:text:*:*:scid $activecid echo -s $1-


then there's a big security risk there because if they type "hi $identifier", $identifier will be evaluated.

There are ways around that though. Here's a simple(ish) way:
Code:
on *:text:*:*:{
  var %tmpvarname = $+(%,temp.ontext.,$chan,.,$ticks)
  set -u0 % $+ %tmpvarname $1-
  scid $activecid echo -s $+(%,%tmpvarname)
}


Using the previous example that would correctly echo "hi $identifier" to the active connection's Status Window without evaluating $identifier.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Returning the $active $network? [Re: starbucks_mafia] #181684 28/07/07 10:45 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Btw, I changed your $comchanmask a bit to include the host.

Previously, you could:

//echo -a $comchanmask( $address($me,1) , 0)

Would work.

But you couldnt.

//echo -a $comchanmask($host,0)

Here's what I arranged.

Code:
alias comchanmask {
  var %i = 1, %chans, %parm2 = $int($2), %c
  while $comchan($me,%i) {
    %c = $v1
    if ($ial(*, %i)) {
      %chans = $addtok(%chans, %c, 32)
      if ($numtok(%chans, 32) == %parm2) return %c
    }
    inc %i
  }
  if (%parm2 == 0) return $numtok(%chans, 32)
}


Now I can /echo -a $comchanmask($address($me,4),1) and //echo -a $comchanmask($host,1)

And for live 5, I've tested it wih %c and %i...both work. Weird, as %i is a number and %c is a channel. Should work for numbers only..

Last edited by LostShadow; 28/07/07 10:54 PM.
Re: Returning the $active $network? [Re: starbucks_mafia] #181685 28/07/07 10:48 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Originally Posted By: starbucks_mafia
then there's a big security risk there because if they type "hi $identifier", $identifier will be evaluated.

There are ways around that though. Here's a simple(ish) way:
Code:
on *:text:*:*:{
  var %tmpvarname = $+(%,temp.ontext.,$chan,.,$ticks)
  set -u0 % $+ %tmpvarname $1-
  scid $activecid echo -s $+(%,%tmpvarname)
}


Using the previous example that would correctly echo "hi $identifier" to the active connection's Status Window without evaluating $identifier.


Okay thank you for the security alert, I've removed $1- from my on text, as it isn't necessary.

Re: Returning the $active $network? [Re: starbucks_mafia] #181686 28/07/07 10:48 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Local variables set in the first pass are recognised in the second, so
Code:
var %a = $1-
scid $activecid echo -s % $+ a
will work.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Returning the $active $network? [Re: LostShadow] #181687 28/07/07 11:28 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Here's a quick stab at $comnet. I tested it briefly but again I'd suggest trying it out a bit more thoroughly before relying on it.

Code:
alias comnet {
  ; Usage: $comnet(nick, N) returns the connection ID of the Nth connection you share with nick
  ; Usage: $comnet(nick, N).network returns the network name of the Nth connection you share with nick
  var %networks
  scon -a $eval(%networks = %networks,0) $!iif($comchan( $1 , 0) ,$iif($prop == network,$network,$cid) ,$null )
  return $iif($int($2) == 0, $numtok(%networks, 32), $gettok(%networks, $v1, 32))
}


Important to note you should use the .network property if you just want the network name.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Returning the $active $network? [Re: qwerty] #181688 28/07/07 11:29 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Hmm.. I tried with a local var and it didn't work. I guess I must've typo'd somewhere.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Returning the $active $network? [Re: starbucks_mafia] #181697 29/07/07 12:30 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Hey, this $comnet() works perfect.

I used it in alias to list global common nicks.

Listing the most global common channels by nick (all networks).
Neal - 62 global common channels - 10 common networks.
atomiku - 9 global common channels - 4 common networks.
TheChedder - 9 global common channels - 3 common networks.
TaGg - 8 global common channels - 3 common networks.
Kara - 7 global common channels - 3 common networks.
|star| - 7 global common channels - 2 common networks.
D3ADLiN3 - 7 global common channels - 2 common networks.
burakrules69 - 6 global common channels - 2 common networks.
gdi - 6 global common channels - 1 common networks.

Awesome <3.

Re: Returning the $active $network? [Re: LostShadow] #181701 29/07/07 03:22 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Ok.. I haven't read all the replies in detail, so I may be missing some clarification made beyond the initial post.

Correct me if I'm wrong, but in order to get the network of the active connection, you should use:

$network

There is absolutely NO reason to use $scid($activecid).network. It ALWAYS gives you the same reply as $network. EVERY $identifier is the equivalient of $scid($activecid).identifier.

Sorry for pointing out the obvious, but some of the helpers need to actually think through what the original poster's code is doing, rather than just assuming that they are using the correct command/identifier for that situation.

-genius_at_work

Re: Returning the $active $network? [Re: genius_at_work] #181703 29/07/07 04:38 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Originally Posted By: genius_at_work
Ok.. I haven't read all the replies in detail, so I may be missing some clarification made beyond the initial post.

Correct me if I'm wrong, but in order to get the network of the active connection, you should use:

$network

There is absolutely NO reason to use $scid($activecid).network. It ALWAYS gives you the same reply as $network. EVERY $identifier is the equivalient of $scid($activecid).identifier.

Sorry for pointing out the obvious, but some of the helpers need to actually think through what the original poster's code is doing, rather than just assuming that they are using the correct command/identifier for that situation.

-genius_at_work


All that is true for those that are on 1 network.

/echo -s Blah
/scid $activecid /echo -s Blah

Re: Returning the $active $network? [Re: genius_at_work] #181705 29/07/07 04:49 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$scid($activecid).ident is not the same as $ident everywhere. An obvious situation where they're different is $network used in an on TEXT that fires on an inactive connection. Since the OP didn't clarify where this would be used, starbucks_mafia's suggestion was exactly the correct answer.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com