mIRC Home    About    Download    Register    News    Help

Topic Options
#219307 - 13/03/10 12:39 AM Part if not op
vinyltm Offline
Ameglian cow

Registered: 08/01/10
Posts: 26
I have a chatbot running on a website. A lot of the scripts dont work right unless the bot is an op in the channel so i want to add a script to my join command that will make it automatically part from the channel if its not an op. any way to do so?

Top
#219311 - 13/03/10 02:01 AM Re: Part if not op [Re: vinyltm]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Code:
on me:*:join:#:.timeroc 1 5 oc
alias -l oc {
  var %x = $chan(0)
  while (%x) {
    if ($me !isop $chan(%x)) { 
      part $chan(%x) 
    }
    dec %x
  }
}
This goes into your bot remote. Upon its joining, a delay timer of 5 secs will set out to check if the bot is opped or not. If not, part the channel(s).

Top
#219334 - 13/03/10 09:37 PM Re: Part if not op [Re: Tomao]
vinyltm Offline
Ameglian cow

Registered: 08/01/10
Posts: 26
Where would i put a message in this and can i use double digit numbers on the timer? so extend it to 20 seconds and put a warning that the bot must be OP'ed to keep it in the channel?


Edited by vinyltm (13/03/10 10:07 PM)

Top
#219335 - 13/03/10 10:09 PM Re: Part if not op [Re: vinyltm]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Code:
on me:*:join:#:.timeroc 1 5 oc
alias -l oc {
  var %x = $chan(0)
  while (%x) {
    if ($me !isop $chan(%x)) {
      msg $chan(%x) message here
      part $chan(%x)
    }
    dec %x
  }
}
This code is working for me upon testing.

Top
#219336 - 13/03/10 10:16 PM Re: Part if not op [Re: vinyltm]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Quote:
can i use double digit numbers on the timer and put a warning that the bot must be OP'ed to keep it in the channel?
Yes, you can like so:
Code:
.timeroc 1 20 oc
Code:
msg $chan(%x) The bot must be OP'ed to keep it in the channel!

Top
#219337 - 13/03/10 10:17 PM Re: Part if not op [Re: Tomao]
vinyltm Offline
Ameglian cow

Registered: 08/01/10
Posts: 26
yea my first problem was the bot is on a remote accessed computer and accidently pasted it in the popup area and didnt notice at all haha but yea i didnt even think about the %x part. thanks :-)

Top
#219338 - 13/03/10 10:32 PM Re: Part if not op [Re: vinyltm]
vinyltm Offline
Ameglian cow

Registered: 08/01/10
Posts: 26
Anyway i could make him periodically check for his OP status?

Top
#219339 - 13/03/10 10:40 PM Re: Part if not op [Re: vinyltm]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
Code:
on me:*:join:#:.timeroc $+ $chan 0 15 oc $chan 
alias -l oc {
if ($me !isop $1) msg $1 I need to be opped
else .timeroc $+ $1 off
}


Edited by Wims (13/03/10 10:40 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#219340 - 13/03/10 11:02 PM Re: Part if not op [Re: Wims]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
ok Wims example works...but perhaps some events should be added to turn the timer off upon parting, quitting or disconnecting.

Top
#219341 - 13/03/10 11:12 PM Re: Part if not op [Re: vinyltm]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
There's no reason to poll (periodically check) for op status. When your bot gets deopped you can part the channel

Code:
ON me:*:JOIN:#:.timerNOOP $+ # 1 5 part #
ON *:DEOP:#:if ($opnick == $me) .timerNOOP $+ # 1 5 part #
ON *:OP:#:if ($opnick == $me) .timerNOOP $+ # off
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#219342 - 13/03/10 11:16 PM Re: Part if not op [Re: Tomao]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
I've used 0 15 on purpose, he can easy change 0 to a number that represent how many time he wants to "check".
It's also up to him to add such events
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#219344 - 13/03/10 11:52 PM Re: Part if not op [Re: vinyltm]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Based on argv0:
Code:
on me:*:quit:ocoff
on me:*:part:#:ocoff
on *:disconnect:ocoff
on *:op:#:if ($opnick == $me) ocoff
on *:kick:#:if ($knick == $me) ocoff
alias -l ocoff { .timeroc $+ $($+(%,c,$chan),2) off }
alias -l oc { $iif($me !isop $1,msg $1 I need to be opped,.timeroc $+ $1 off) }
on me:*:join:#: { set -e $+(%,c,$chan) $chan | .timeroc $+ $($+(%,c,$chan),2) 0 20 oc $chan }

Top
#219345 - 14/03/10 01:26 AM Re: Part if not op [Re: Tomao]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
Sorry for nit-picking, but
- the on disconnect / on quit event won't kill the timers (ocoff alias), as they don't know a $chan value. But then, you don't need those events at all - you don't start any offline timer smile
- what's the use of the variable if you evaluate it instantly to the $chan?
- all the scripts (not only yours) do evaluate the channel name in a timer command frown


My two cents:
Code:
; ----- SETUP START -----
; duration (in s) to wait for op after join and between requests
alias oc.delay { return 15 }
; numer of times to ask for ops before part
alias oc.request { return 3 }
; ----- SETUP END -----

on me:*:join:#: oc.beg
on me:*:part:#: oc.off 
on *:deop:#: if ($opnick == $me) oc.beg
on *:kick:#: if ($knick == $me) oc.off
on *:op:#: if ($opnick == $me) oc.off

alias -l oc.beg {
  .timeroc $+ # $$oc.request $$oc.delay oc
  oc.ask # $calc($oc.request * $oc.delay)
}
alias -l oc {
  var %c = $mid($ctimer,3-)
  if ($me isop %c) { .timeroc $+ %c off }
  elseif ($timer($ctimer).reps == 0) { part %c }
  else { oc.ask %c $calc($timer($ctimer).reps * $timer($ctimer).delay) }
}
alias -l oc.off { .timeroc $+ $chan off }
alias -l oc.ask { msg $1 I need to be opped. If I don't get ops, I'll auto-part in $duration($2) }

Top
#219347 - 14/03/10 06:51 AM Re: Part if not op [Re: Horstl]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Thanks Horstl. You're not nit-picking. You're being helpfully informative. This is what makes one's improvement in learning.

Top