mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2022
Posts: 2
M
Mark Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Sep 2022
Posts: 2
Hi, i need to autojoin channels on reconnect, the channel entry requires this to be sent "/msg [bot] enter #channel [multiple channels can be here] password"
how do I do this with mIRC? do I need a script, and what would that look like?
Also, I'm connected to two servers, each has different channels requiring the same command, and I'd like to have a separate command for this for each server. The favorites function doesn't seem to work with this, or I don't understand how to do that. I used to have this set up to do that, but my settings got lost and I'm at a loss now.

Joined: Jan 2004
Posts: 1,835
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,835
mIRC doesn't really have a straightforward way during ON CONNECT to tell whether it's connecting there freshly or whether it's a reconnect, unless you do something like hooking the ON DISCONNECT event to set a variable that lets you know during ON CONNECT that you recently disconnected.

But instead, I'll do something based on the assumption that you have checked the box for options/irc/"keep channels open on connect". This won't close the channel window unless that status window reconnects to something using a different $network value. The channel will be counted as being open, but it won't show you or anyone in the nicklist. The lines beginning with ;semi-colon are comments and can be deleted.

You didn't give all the details for a full solution. Once you send the password to the bot, what happens? Does the bot change a network setting which allows /JOIN to work? Or are you actually already able to enter the channel but don't have some kind of privileges until the bot receives your password? Is there a confirmation reply message received from the bot which can be used to make the join attempt? If so, does the message contain the name of channels that can be joined, or does it expect you to already know which ones you want to join?

I'm making this script based on the assumption that you're blocked from entering the channel until you send the password, at which point the /join command works. So I'll have a 2-stage process. The 1st one sends the message to the bot-nick at the specific networks, and then after a 2 seconds delay it attempts to join those channels. This is very basic, so it's not checking to compare against that network's setting for how many channels can be joined in the same JOIN command, and servers will have various limits.

As a 'backstop', it calls an alias that will attempt to join open channel windows if your nick isn't in the nicklist. It will do this at intervals of 5 seconds for a duration of 30 seconds after connecting. The 2nd alias is purposely made to be all-purpose, where it isn't restricted to a specific list of channel names, and doesn't try to join them all at the same time.

The one fault with the backstop alias is that if someone has set you to be kicked from some other channel each time you join it, they may be irritated to see you JOIN/KICKED 6 times in a row.

This can be added as a new script in the Alt+R editor, or can be inserted into any other script which does not already contain the ON CONNECT event handler. I'm just giving a random example, and you'll need to change to whatever networks you are using, and substitute your own channel names and passwords. If not sure which strings to use instead, you can paste this next command into any editbox that's connected to that network:

//echo -a $network

This same kind of logic can be done to have different commands at different networks. I could've had you put all this into the 'perform on connect', but it's a little easier to edit things in the scripts editor. If you want the /RejoinChannels to be something to execute at all networks, you can move it outside the "if (network = name)" section

Code
on *:CONNECT:{

  ; copy next { section } as many times as needed, editing NetworkName Channels Password as needed

  if ($network == Dalnet) {
    ; this list of channels must be separated by spaces. is used in message to bot, and the join attempt
    var %chanlist #channel1 #channel2 #channel3
    msg [bot] enter $$+(%chanlist) password
    ; next tries to join the channels after 2 seconds delay
    timer 1 2 join $unsafe( $replace(%chanlist,$chr(32),$chr(44)) )
    ; next tries at 5 sec intervals to join open channels where your nick isn't there
    ; the '4' is the limit to try to rejoin each interval, overrides the default 3
    timer 6 5 RejoinChannels 4
  }

  ; when copying additional network sections, paste them ABOVE this line
}

; when calling this alias, can override the default to 4 like: /RejoinChannels 4
alias RejoinChannels {
  var %i $chan(0)
  ; next line controls how many open channel windows to join each time this alias runs
  ; joining too many channels at the same time can cause flooding. Defaults to 3 at a time
  var %limit $1 | if (%limit !isnum 1-11) var %limit 3

  while (%i <= $chan(0)) {
    if (%limit !isnum 1-) var %limit 3
    ; if the window is open but $me is not in nicklist then try to join it
    if ( !$nick( $chan(%i) , $me) { join $chan(%i) | dec %limit }
    inc %i
  }

}

Joined: Sep 2022
Posts: 2
M
Mark Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Sep 2022
Posts: 2
maroon, on issuing the command as I said, that joins the channels. No need for a separate /join as the bot takes care of adding you to the channel. The key is getting that command issued on reconnects as I disconnect from this server a couple times a day, and it's frustrating if I am AFK and don't notice for a couple hours.

Joined: Jan 2004
Posts: 1,835
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,835
Unless the bot has server admin privileges to issue a SAJOIN at you, I'm not sure exactly how a bot can 'add you to a channel'.

But, if all you need is the command, the code i listed would do it, except you can delete the timer lines


Link Copied to Clipboard