mIRC Home    About    Download    Register    News    Help

Print Thread
multiple networks #224791 18/08/10 07:10 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
Code:
        var %net = network, %chan = chan
        var %nr = 1
        ; loop all connections (the network names of-)
        var %max_loops 10
        while ($scon(%nr).network) {

          ; if (%nr > %max_loops) { halt }

          ; if it's the net you specified...
          if ($v1 == %net) {
            ; make this network the active connection
            scon %nr
            ; ...and if you're on the channel specified: forward the text to that chan
            if ($me ison %chan && $nick !isop %chan) { /msg $v2 something }

            ; and return
            return
          } 
          inc %nr
        }
      }
I got the above code snippet from here a few years ago but can't find that topic now

it is used to msg something from a channel on one network to a channel on another network

what I want to know is how to message from one channel on a network to channels on 2 other networks

Re: multiple networks [Re: firefox] #224793 18/08/10 08:31 PM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
Code:
 var %n network network1 networkN ,%c #chan,%a 1
 while ($scon(%a).network != $null) {
 if ($istok(%n,$v1,32)) {
   scon %a
   msg %c something
  }
 inc %a
}

works for more than one or two networks, just seperate them with a space in %n.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: multiple networks [Re: Wims] #224795 18/08/10 09:04 PM
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
Code:
  var %n = network network1 networkN ,%c = #chan1 #chan2 #chanN,%a = 1,%b = 1
  while ($scon(%a).network != $null) {
    if ($istok(%n,$v1,32)) {
      while %b <= $gettok(%c,0,32) {
      {
        scon %a msg $gettok(%c,%b,32) Text To Send Here
        inc %b
      }
    }
    inc %a
  }


A little improvement.
I noted there were no '='s for the vars, something usually leading to 'set' type variables being created instead of 'var' ones...afair, any way.

This snippet will send the text to any channels you tell it to, on any network you tell it to.
You add a network/channel by replacing those Network1 and the like, in the first line.
Obviously, you can add more of both, you're not limited to the number of words we've left there to be replaced.

Good luck,
ziv.

Re: multiple networks [Re: ziv] #224798 18/08/10 09:45 PM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
Quote:
I noted there were no '='s for the vars, something usually leading to 'set' type variables being created instead of 'var' ones...afair, any way.
Yeah, the equal sign isn't required since mIRC 6.21 (could cause error before) so I don't use it, sure it's a good habit to use it...
And the /scon command plus the /msg command was on differents lines on purpose, now the code can be exploited since scon is "double evaluating" the channel parameter and the message.
There's also a 'typo' with the {} bracket for the while loop, and as a side note this loop could be written in a much faster way :
Code:
scon %a
var %n 1
while ($gettok(%c,%n,32)) {
msg $v1 Text To Send Here
inc %n
}


edit : put the scon before the loop in my example.

Last edited by Wims; 18/08/10 09:55 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: multiple networks [Re: Wims] #224801 18/08/10 10:10 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
ok thank you both
what about different chans on each network?

i.e. if I want network1 to be using #help
and network2 to use #mirc

edit: can you show one example in which I want to send same message to both chans and one where a different message (i.e. different colour or something)

Last edited by firefox; 18/08/10 10:13 PM.
Re: multiple networks [Re: firefox] #224803 19/08/10 12:05 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Code:
alias -l findNetworkCid {
  var %a 1
  var %connections $scon(0)
  while (%a <= %connections) {
    if ($scon(%a).network == $1) { scon %a | return $cid }
    inc %a
  }
}

on 1:text:*:#: {
  var %networkList network1 network1 network2 network3 network3 network3
  var %channelList #chan1 #chan2 #chan3 #chan4 #chan5 #chan6
  var %a 1
  var %channels $numtok(%channelList,32)
  var %channel $chan
  var %network $network
  while (%a <= %channels) {
    if (($gettok(%channelList,%a,32) == %channel) && ($gettok(%networkList,%a,32) == %network) {
      var %isOnList $true
      break
    }
    inc %a
  }
  if (%isOnList != $true) { halt }
  var %a 1
  while (%a <= %channels) {
    if (($gettok(%channelList,%a,32) != %channel) || ($gettok(%networkList,%a,32) != %network) {
      scid $findNetworkCid($gettok(%networkList,%a,32))
      msg $gettok(%channelList,%a,32) %network $+(%chan,: <,$nick,> $1-)
    }
    inc %a
  }
}


I haven't tested this yet, but I use a similar method for remembering which channel goes with which network on another script. Keep in mind that with this method, you need to make sure that the channels stay in order with the networks. That is, the 3rd channel needs to correspond with the 3rd listed network, and you may want to list the same network more than once if you have more than one channel on the same network you want this working in.

Edit: I decided to clarify a bit. In this particular example, network1 is listed twice, then network 2 is listed once, then network3 is listed 3 times. Since network1 is the first and second item in the network list, the first 2 channels will pair with that network. The third channel pairs with the third network (network2), and the 4th through 6th channels will pair with the 4th through 6th network items (all of them are network3).

Last edited by KageNoOni; 19/08/10 01:21 AM.
Re: multiple networks [Re: KageNoOni] #224804 19/08/10 12:51 AM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
Read my previous post, again this code can be exploited, use scid N | cmd instead of scid N cmd otherwise the cmd parameter is double evaluated.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: multiple networks [Re: Wims] #224805 19/08/10 01:20 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
I was unaware of the fact that /scon evaluates the text, so I didn't understand what you meant. I just tested to see if that was the case, so now that I know it does, I'll go ahead and fix it.

Re: multiple networks [Re: KageNoOni] #224809 19/08/10 04:48 AM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
thank you KageNoOni

a few questions:
1. can I change that on text event to an alias?
2. I assume it would work fine if I was adding removing networks and channels and at some point there was only 1 network and 1 channel listed?
3. What if I want to send to #channel1 in blue colour and #channel2 in red?

Re: multiple networks [Re: firefox] #224811 19/08/10 06:56 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Originally Posted By: firefox
1. can I change that on text event to an alias?
2. I assume it would work fine if I was adding removing networks and channels and at some point there was only 1 network and 1 channel listed?
3. What if I want to send to #channel1 in blue colour and #channel2 in red?


1) Yes, I suppose so. Just create the alias definition, copy and paste, then update anything you might need to change so that it's compatible as a command rather than a triggered event.
2) Yes, that would work fine, though it wouldn't do anything at that point, since it only sends to channels other than the one it triggers in, and if you only have 1 listed, then there isn't any "other" channels for it to send to.
3) Create a third variable, probably call it %colorList, and format it $+($chr(3),2) repeatedly but seperated by spaces (if doing it in mIRC's own editor, you can just use Ctrl + K, followed by the number). In the part where the message is sent, use $+(%chan,: <,$nick,> $gettok(%colorList,%a,32),$1-) instead of what's currently there.

Formatting it for an alias might take some extra work compared to the other 2. For example, $chan will almost likely not be available unless triggered from an event like on Text. You'd need some way of telling it what channel to check for, so possibly use $active if it runs by typing the command (assuming that is a channel, you'll want to add a check for the possibility that the active window isn't a channel, and possibly display an error message and halt the script if it isn't).

Re: multiple networks [Re: KageNoOni] #224812 19/08/10 07:55 AM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
Originally Posted By: KageNoOni

2) Yes, that would work fine, though it wouldn't do anything at that point, since it only sends to channels other than the one it triggers in, and if you only have 1 listed, then there isn't any "other" channels for it to send to.
3) Create a third variable, probably call it %colorList, and format it $+($chr(3),2) repeatedly but seperated by spaces (if doing it in mIRC's own editor, you can just use Ctrl + K, followed by the number). In the part where the message is sent, use $+(%chan,: <,$nick,> $gettok(%colorList,%a,32),$1-) instead of what's currently there.

Formatting it for an alias might take some extra work compared to the other 2. For example, $chan will almost likely not be available unless triggered from an event like on Text. You'd need some way of telling it what channel to check for, so possibly use $active if it runs by typing the command (assuming that is a channel, you'll want to add a check for the possibility that the active window isn't a channel, and possibly display an error message and halt the script if it isn't).


2. What I meant was like:

Code:
on 1:text:*:#originalchannel: {
  var %networkList newnetwork
  var %channelList #newchan1


3. yes about colorlist what if I want

blue colour --> channel1
and
red colour --> channel2

if another on text event is calling the alias is $chan available then ?

Re: multiple networks [Re: firefox] #224836 19/08/10 08:39 PM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Originally Posted By: firefox
2. What I meant was like:

Code:
on 1:text:*:#originalchannel: {
  var %networkList newnetwork
  var %channelList #newchan1

Not sure why you'd want to do it that way, but it would work. The problem with this method is that now only what's said in #originalchannel will be relayed, and nothing said in #newchan1 would be relayed. If that's what you want, then this would do the trick.

Originally Posted By: firefox
3. yes about colorlist what if I want

blue colour --> channel1
and
red colour --> channel2

if another on text event is calling the alias is $chan available then ?


Yes, that's what my alteration using %colorList would have done. Assuming you have 2 channels in the list, you'd use this line

var %colorList $+($chr(3),12 $chr(3),4)

When you use $gettok, and it's for the first channel, it returns $chr(3) $+ 12, which is the blue color. When it's for the second channel, it will return $chr(3) $+ 4, which is the red color.

Yes, $chan becomes the channel the on text event triggered from. $chan in such an event is automatically passed, as is $nick, but $1- you'll have to pass on your own. Remember that in your alias you'll need to check and see if things like $chan exist, if not, check and see if $active is a channel, if it's not, handle how ever you would for no channel being listed (in this case, halting the script and displaying the error seems most appropriate). I'd check for $nick, because if it's an alias, it could end up being used as a command when no $nick is available, and handle the lack of a $nick appropriately.

Re: multiple networks [Re: KageNoOni] #224837 19/08/10 08:48 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
ok thank you very much again you have been very helpful

in regards to why I would want just 1 channel if I was dynamically adding/removing channels sometimes it might go down to one but mostly be more

Re: multiple networks [Re: firefox] #224858 20/08/10 01:02 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Originally Posted By: firefox
in regards to why I would want just 1 channel if I was dynamically adding/removing channels sometimes it might go down to one but mostly be more


I suppose I can understand that, but the code example you gave, effectively created an eavesdropping bot. Some one sits in #newchan, and can see everything being said in #originalchannel, but no one in #originalchannel will even realize the chat is connected because nothing from #newchan is being relayed back. My method ensures all channels you add to the lists in this grouping see each other. If what you want is effectively a means to monitor a channel with out it being known you're present, than the code you gave as an example works perfectly well. Otherwise, it fails to do what the intended purpose was, effectively linking 2 or more channels together.