mIRC Homepage
Posted By: Tzar469 Modes help - 18/12/08 06:13 AM
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.
Posted By: 5618 Re: Modes help - 18/12/08 06:25 AM
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 }
}

Posted By: Wims Re: Modes help - 18/12/08 09:13 AM
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
Posted By: DJ_Sol Re: Modes help - 18/12/08 01:37 PM
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 }
}
Posted By: 5618 Re: Modes help - 18/12/08 02:02 PM
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*
© mIRC Discussion Forums