mIRC Home    About    Download    Register    News    Help

Print Thread
#179498 23/06/07 07:10 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Hi All,

I want to have a new alias that can check for the following.
My bot joins several channels when it connects.
When it joins those channels, it will set appropriate channel modes.

Whenever the bot doesn't join any of these channels, I want it to inform me.
Additionally, when it fails to set these channel modes, it needs to inform me as well.

Does anyone have idea's for this?

My current code is:
Code:
set %channels #channel1,#channel2,#channel3,#channel4,#channel5,#channel6

alias join-channels {
  var %cnt = 1
  var %ttl = $numtok(%channels,44)
  while (%cnt <= %ttl) {
    var %chan = $gettok(%channels,%cnt,44)
    .timer 1 3 join %chan
    .timer 1 4 mode %chan +is
    inc %cnt
  }
}

OrionsBelt #179515 23/06/07 10:54 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try this:

Code:
set %channels #channel1,#channel2,#channel3,#channel4,#channel5,#channel6

alias join-channels {
  var %cnt = 1
  var %ttl = $numtok(%channels,44)
  while (%cnt <= %ttl) {
    var %chan = $gettok(%channels,%cnt,44)
    .timer 1 3 join %chan
    .timer 1 4 mode %chan +is
    .timer 1 8 checkchan %chan 1
    inc %cnt
  }
}

alias checkchan {
;$1 = channel, $2 = attempt#

  if ($2 == $null) return

  .timer 1 5 checkchan $1 $calc($2 + 1)

  if ($me !ison $1) {
    if ($2 <= 1) join $1
    else checknotify $me is not on $1
    return 
  }

  var %cmode = $chan($1).mode

  if (i !isincs %cmode) {
    if ($2 <= 2) mode $1 +i
    else checknotify $1 is not set to +i 
  }

  if (s !isincs %cmode) {
    if ($2 <= 2) mode $1 +s
    else checknotify $1 is not set to +s 
  }
}

alias checknotify echo 4 -a $1-


(untested)

-genius_at_work

Joined: Apr 2006
Posts: 464
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Thanks for your reply Genius.
I tried it, and it does work. Just a little spammy though grin

Anyway, I should have tried some more myself, before asking.
Came up with the below alias, and that does the trick for me.
Again, thank you for looking into it.

Code:
alias check-channels {
  var %cnt = 1
  var %ttl = $chan(0)
  var %mode-errors = 0
  var %names = %channels
  while (%cnt <= %ttl) {
    if ($findtok(%channels,$chan(%cnt),44)) {
      if ($chan($chan(%cnt)).mode == +is) {
        var %names = $remtok(%names,$chan(%cnt),1,44)
      }
      else {
        inc %mode-errors
        var %mode-problems = $iif((!%mode-problems),$chan(%cnt) $+ : $chan($chan(%cnt)).mode,%mode-problems $chr(32) $+ - $chr(32) $chan(%cnt) $+ : $chan($chan(%cnt)).mode)
        var %names = $remtok(%names,$chan(%cnt),1,44)
      }
    }
    inc %cnt
  }
  var %chan-errors = $numtok(%names,44)
  if (!%chan-errors) && (%mode-errors == 0) { echo 04 -a Check completed, no problems found! }
  elseif (%chan-errors) && (%mode-errors == 0) { echo 04 -a Check completed, no mode errors detected, but the bot is NOT present on: %names }
  elseif (%chan-errors) && (%mode-errors != 0) { echo 04 -a Check completed, %mode-errors mode error(s) detected: %mode-problems and the bot is NOT present on: %names }
  elseif (!%chan-errors) && (%mode-errors != 0) { echo 04 -a Check completed, %mode-errors mode error(s) detected: %mode-problems but at least the bot is present on all channels. }
}


Link Copied to Clipboard