mIRC Home    About    Download    Register    News    Help

Print Thread
#207464 18/12/08 06:13 AM
Joined: Dec 2007
Posts: 24
T
Tzar469 Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2007
Posts: 24
Hi. I'm trying to make a join script for a bot but I can't figure out one thing. I want the bot to automatically leave the channel if it is moderated (+m) and the bot has no voice (or greater) after 5 seconds. I've tried using timers but the bot still leaves.

Any help is appreciated.

Last edited by Tzar469; 18/12/08 06:14 AM.
Tzar469 #207465 18/12/08 06:25 AM
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Maybe something like...
Code:
on *:JOIN:#channel:{
  if ($nick == me) && (m isincs $chan(#).mode) {
    .timer 1 5 voicecheck
  }
}
alias -l voicecheck {
  if ($me isreg $chan) { part $chan }
}


Actually, I did some testing and I had problems because the channel modes cannot be read that quickly. Furthermore I believe $chan cannot be carried over to an alias called later on. So you may be better off with...

Code:
on *:JOIN:#channel:{
  if ($nick == $me) {
    set -u7 %joinchan $chan
    .timer 1 5 voicecheck
  }
} 
alias -l voicecheck { 
  if ($me isreg %joinchan) && (m isincs $chan(%joinchan).mode) { part %joinchan }
}


Last edited by 5618; 18/12/08 06:55 AM.
5618 #207473 18/12/08 09:13 AM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Code:
on me:*:join:#:timer 1 5 if ( $me isreg $chan ) && (m isincs $!gettok($chan( $chan ).mode,1,32)) part $chan

It's better to check the m mode in the first word in the channel mode, because the channel could be +k something


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
5618 #207478 18/12/08 01:37 PM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I want you to know this 5618 because this little bit of knowledge opened up my scripting a lot when I learned it.

You can send data to an alias.

Code:
on *:join:#:{
/test_alias $nick $chan
}

alias test_alias {
;$1 == $nick
;$2 == $chan
  if (m isincs $chan($2).mode) && ($2 !isvoice $1) { mode $2 +v $1 }
}



Also, an alias called in an event carries over things like $chan I guess. I never use this as I don't understand it's limits and I like to make sure my code is 100% accurate always. (It would just take some time to test, Im lazy)

Anyways, this is good to know. smile


As for the request ...

Code:
on me:*:join:#:{ .timerjoinm 1 5 /join_m $chan }
alias join_m {
  if ($me !ison $1) { return }
  elseif (m isincs $chan($1).mode) && ($me !isvoice $1) { part $1 }
}

DJ_Sol #207480 18/12/08 02:02 PM
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Yeah, thanks. I actually know that but I never thought of it. D'oh!

Oh, and if you read his post you'll see you need isreg instead of !isvoice.
*always feels a bit strange when trying to pass an if-statement to the start of a timed command*


Link Copied to Clipboard