mIRC Homepage
Posted By: BlackAcidDevil How could be done? - 24/06/09 05:24 AM
Basically what I want to do when joining a certain server change my nick for that server, identify myself, join a channel, and set channel modes

something like

on *:connect:irc.testserver.net /nick testnick /msg NickServ IDENTIFY password /join #testchannel /mode +abc

I looked through mirc's help file but I am not able to put these commands together in a script and have them work properly. Any help is appreciated.
Posted By: westor Re: How could be done? - 24/06/09 11:08 AM
Yes you can try using this:

Code:
ON *:CONNECT: {
  if ($server == irc.testserver.net) {
    nick testnick
    .msg NickServ IDENTIFY 12345
    timer 1 3 join #mychan1,#mychan2
    mode $me +abc
  }
}


more information help about it try : /help on connect
Posted By: argv0 Re: How could be done? - 24/06/09 06:01 PM
That won't work.

He wants to set channel modes, not user modes. You can't do this from one event

See here for the reason why: http://kthx.net/ftb/#54
Posted By: westor Re: How could be done? - 24/06/09 09:59 PM
I didn't read the hole post, So then try this:

Code:
ON *:CONNECT: {
  if ($server == irc.testserver.net) {
    nick testnick
    .msg NickServ IDENTIFY 12345
    timer 1 3 join #mychan1,#mychan2
    timer 1 4 mode #channel +abc
  }
}


Edit: There are more way's to do that you want, Just i gave you the more simple way that i know until now.
Posted By: RusselB Re: How could be done? - 24/06/09 11:26 PM
I'd recommend something like
Code:
on *:connect:{
  if (<network_name> isin $network) {
    if $me != $mnick {      .nick $v2    }
  }
}
on *:notice:*is registered and protected*:{
  if ($nick == nickserv) {    .msg $v2 identify <password>  }
}
on *:notice:Password accepted*:*{
  if $nick == nickserv {    .join #chan1,#chan2,#chan3  }
}
on *:op:#:{
  if $opnick == $me {    .mode $chan <modes>  }
}

As noted, the timing is the biggest hassle, and rather than guess at a fixed time delay, my code waits for specific information to be received before going onto the next step.
Thus, even if services are extremely lagged (and I've seen lags of up to 10 seconds for services), or extremely fast (in the millisecond range), there is minimum delay between when an operation has been completed and when the next one will take place.
The main problem that I have with this code (although I use something similar myself), is the fact that if services go completely down, then come back, you will end up with a repeat of the join to the channels, which could make you end up sending a message to the wrong channel, due to the fact that each channel takes focus when you join it.
There are ways of avoiding most of that, but they require even more code than has already been done here.
Posted By: Tomao Re: How could be done? - 25/06/09 12:24 AM
What if the mode +abc has already been set? Maybe a check for $chan(#).mode is needed so that it won't set the mode again once you enter the channel?
Posted By: RusselB Re: How could be done? - 25/06/09 01:07 AM
Good point. That check is easily added, as I'm quite sure you know.
Posted By: BlackAcidDevil Re: How could be done? - 25/06/09 03:02 AM
Thanks to everyone for replying!

Here's what I have:
Code:
on *:connect:{
  if (slashnet isin $network) {
    if $me != $mnick {      .nick $v2    }
  }
}
on *:notice:*is registered and protected*:{
  if ($nick == nickserv) {    .msg $v2 identify abc123  }
}
on *:notice:Password accepted*:*{
  if $nick == nickserv {    .join #testchannel  }
}
on *:op:#:{
  if $opnick == $me {    .mode $chan +k 123xyz  }
}
I don't understand where the nick gets changed from my normal nick to the nick I want to use on this server. I am using slashnet.org only for an online game clan and want to use my clan name only with this server. I messed around with the code for a couple hours just to try to even get identify to work when I set my nick to the correct one before joining the server. I just can't seem to get any of this do anything.

Even just trying this after identifying isn't doing anything.
Code:
on *:notice:Password accepted*:*{
  if $nick == nickserv {    .join #testchannel  }
}


What am I missing?

Thanks!
Posted By: RusselB Re: How could be done? - 25/06/09 03:57 AM
In
Code:
 if $me != $mnick {      .nick $v2    }
change $mnick to the nick you want to use for that network.
Posted By: BlackAcidDevil Re: How could be done? - 25/06/09 05:22 AM
The nick changing part is working great. After some reading in the mirc's help file and looking at the code I am understanding whats happening a lot better.

Code:
if $me != MyNick {      .nick $v2    }

if i'm not equal to MyNick /nick MyNick. Where $v2 is the second part of $me != MyNick

Code:
on *:notice:*is registered and protected*:{
  if ($nick == nickserv) {    .msg $v2 identify abc123  }

on notice from nickserv with the statement *is registered and protected* /msg nickserv identify password. Where * are wild cards for the beginning and ending of the message

This part of the code is not working nor is the rest for obvious reasons; this part is broke. When I change my nick I get 2 notices:
-NickServ- This nickname is registered and protected. If it is your nickname, type /msg NickServ IDENTIFY password. Otherwise, please choose a different nickname.
-NickServ- If you do not change your nickname within one minute, it will be changed automatically.

The way the script is written I don't see why 2 notices should really matter as the script is just waiting for the first notice to proceed to the next command of identifying.

Hopefully I don't sound like an idiot. Any ideas? Thanks!



Posted By: RusselB Re: How could be done? - 25/06/09 06:51 AM
You're missing the location parameter for the ON NOTICE event.
Code:
on *:notice:*is registered and protected*:*:{ 


The two notices are used for different reasons.
The first one (as mentioned in this post) is the notice from nickserv telling you that the nick is registered and protected.
If you want to use the nick, you have to identify yourself as tnee owner of the nick, otherwise nickserv may (and probably will) change your nick after 20-60 seconds.

The second notice is nickserv's message confirming that the identification sent for the first notice was accepted.
Posted By: westor Re: How could be done? - 25/06/09 10:23 AM
And what about if the server netsplit and the services came back or when restarting network services and the user is on the currently channels that have joined on the CONNECT ?

e.g:
Code:
on *:notice:Password accepted*:*{
  if ($nick == nickserv) { .join #chan1,#chan2,#chan3 }
}


this must be like this corrected:

Code:
on *:notice:Password accepted*:*{
  if (($nick == nickserv) && ($me !ison #chan1,#chan2,#chan3)) { .join #chan1,#chan2,#chan3 }
}

Posted By: RusselB Re: How could be done? - 25/06/09 12:05 PM
It can be modified like you have shown, but saying that it must be changed is ridiculous. If you do a /join #channel when you are already on that channel, you simply force that channel to become the active channel.

Additionally, the op was enquiring as to why the ON NOTICE event was not triggering, which is what I answered.

Out of curiosity, did you try your modification?
I tried the following
Code:
//var %chans = #DragonsDen,#Help,#X-Staff,#mirc_scripting | echo -a $iif($me ison %chans,$v2,$v1)
on a network where I was on all of the channels specified, and it returns the $v1 whether I'm on all of the channels or not, thus your modification that must be made, by my testing, does not work, which, imo, is worse than having channels re-joined while already on the channel.
Posted By: Horstl Re: How could be done? - 25/06/09 12:07 PM
You cannot check for "ison <multiple channels>". You'd have to check each channel separately... the suggested condition will always fail and the code will always issue the join command (and the "correction" will have zero effect).
But if you're already on some a channel, another /join command won't hurt at all smile
Posted By: CtrlAltDel Re: How could be done? - 25/06/09 01:49 PM
Originally Posted By: RusselB

The main problem that I have with this code (although I use something similar myself), is the fact that if services go completely down, then come back, you will end up with a repeat of the join to the channels, which could make you end up sending a message to the wrong channel, due to the fact that each channel takes focus when you join it.
There are ways of avoiding most of that, but they require even more code than has already been done here.


Not you particularly, but to everyone ...

Does the /join -n #1,#2,#3 not eliminate the "taking focus" problem mentioned here?

Originally Posted By: Tomato
What if the mode +abc has already been set?


If the channel mode is already set and you try to reset it, nothing happens. At least not on any of the networks I'm on.
Posted By: westor Re: How could be done? - 25/06/09 02:35 PM
Originally Posted By: Tomato
If the channel mode is already set and you try to reset it, nothing happens. At least not on any of the networks I'm on.


This is depended from the network services, The newest network services like (Unreal 3.2.7) if you try to set a channel mode and exists then the network use HALT into your mode!
Posted By: RusselB Re: How could be done? - 25/06/09 03:33 PM
Quote:
Does the /join -n #1,#2,#3 not eliminate the "taking focus" problem mentioned here?
Yes it will, but I didn't know if the OP wanted the channels opened in minimized format, as that means they will have to go through and un-minimize any channel(s) that they want to see.
Posted By: BlackAcidDevil Re: How could be done? - 25/06/09 06:48 PM
RusselB thanks for all your help and writing that code for me! Also thanks to all the other people that replied with suggestions! This is what I have and it is working great.
Code:
on *:connect:{
  if (slashnet isin $network) {
    if $me != MyNick {      .nick $v2    }
  }
}
on *:notice:*is registered and protected*:*:{
  if ($nick == NickServ) {    .msg $v2 identify password  }
}
on *:notice:Password accepted*:*:{
  if ($nick == NickServ) {    .join #testchannel  }
}
on *:op:#:{
  if ($opnick == $me) {    .mode $chan +k 123xyz  }
}
Posted By: BlackAcidDevil Re: How could be done? - 25/06/09 07:11 PM
I guess not, thought channel modes were being set but they are not. I'm gonna figure this out myself. Thanks again!
Posted By: RusselB Re: How could be done? - 25/06/09 10:35 PM
If the mode(s) that you are applying are not being kept, try checking with chanserv to see what (if any) modes are locked using mlock.
If the mode(s) that you are trying to set are being countered by chanserv's mlock, then you need to find out who has access to change the mlock options on chanserv for the channel in question.

That's the only thing I can think of that would keep the code you posted from working.
Posted By: s00p Re: How could be done? - 26/06/09 08:25 AM
it can be far simpler than that, even.
You only need to do these once for your nickname:
1. /ns access add *@*
2. /alias slashnet server irc.slashnet.org 6667 your_ns_password -i your_nickname[/code]

3. Insert the following code into your remotes:
Code:
on 1:connect: {
  if ($network == [b]SlashNet[/b]) {
    join #channel1,#channel2
    mode #channel1 +abc123
  }
}


4. Type /slashnet smile

Keep in mind this may not work on some networks, but it does work on slashnet and freenode as well as most other networks that have nickserv.
Posted By: s00p Re: How could be done? - 26/06/09 08:29 AM
Quote:
If the mode(s) that you are applying are not being kept, try checking with chanserv to see what (if any) modes are locked using mlock.
If the mode(s) that you are trying to set are being countered by chanserv's mlock, then you need to find out who has access to change the mlock options on chanserv for the channel in question.

That's the only thing I can think of that would keep the code you posted from working.


Most servers are running separate from services, so any command you type to services needs to be forwarded on by the server. This leads to an increased latency for messages bound to the services. If you consider this, then no, that code wouldn't work. Unless you define a working solution as one that works only when the conditions are in your favour (which certainly isn't my case).
Posted By: DJ_Sol Re: How could be done? - 26/06/09 01:15 PM
Your mode change works in the connect event? You aren't in the room yet. You may want to put the mode command in a join event.

on me:*:join:#:mode # +abc123
Posted By: BlackAcidDevil Re: How could be done? - 27/06/09 01:40 AM
After some digging around in the help file I came up with this for setting the channel modes. It's working fine. Same thing you have DJ Sol just coded slightly different.

Code:
on *:join:#testchannel:/mode #testchannel +slk 50 xyz123
Posted By: RusselB Re: How could be done? - 27/06/09 02:07 AM
Using your code, the modes would be set every time someone entered the room, rather than when you entered.
Posted By: BlackAcidDevil Re: How could be done? - 27/06/09 02:15 AM
So it should be "on me", like DJ Sol pointed out?
Posted By: Wims Re: How could be done? - 27/06/09 02:32 AM
Yes smile
Posted By: BlackAcidDevil Re: How could be done? - 27/06/09 04:44 AM
Ok, Thanks.
Posted By: DJ_Sol Re: How could be done? - 27/06/09 08:17 AM
The thing about the join even though is that it is before you are given op status so you can't really check if you are op or not. When I join a room I have a 2 or 3 second timer that triggers an alias "op_check" which is where I store different commands I may want to implement if I am joining a channel as op.

Also, there is no need to double check a mode before making a mode change. There will be no error.
Posted By: RusselB Re: How could be done? - 27/06/09 11:07 AM
This is the reason I used the ON OP event in my original coded response to this topic.
Posted By: DJ_Sol Re: How could be done? - 28/06/09 02:58 AM
Quite right. In my connection, Owner and Op events point to the same alias.
Posted By: RusselB Re: How could be done? - 28/06/09 03:15 AM
Knew I had to be right about something, eventually... laugh
© mIRC Discussion Forums