mIRC Home    About    Download    Register    News    Help

Print Thread
Part if not op #219307 13/03/10 12:39 AM
Joined: Jan 2010
Posts: 26
V
vinyltm Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Jan 2010
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?

Re: Part if not op [Re: vinyltm] #219311 13/03/10 02:01 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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).

Re: Part if not op [Re: Tomao] #219334 13/03/10 09:37 PM
Joined: Jan 2010
Posts: 26
V
vinyltm Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Jan 2010
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?

Last edited by vinyltm; 13/03/10 10:07 PM.
Re: Part if not op [Re: vinyltm] #219335 13/03/10 10:09 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: Part if not op [Re: vinyltm] #219336 13/03/10 10:16 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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!

Re: Part if not op [Re: Tomao] #219337 13/03/10 10:17 PM
Joined: Jan 2010
Posts: 26
V
vinyltm Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Jan 2010
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 :-)

Re: Part if not op [Re: vinyltm] #219338 13/03/10 10:32 PM
Joined: Jan 2010
Posts: 26
V
vinyltm Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Jan 2010
Posts: 26
Anyway i could make him periodically check for his OP status?

Re: Part if not op [Re: vinyltm] #219339 13/03/10 10:40 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
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
}

Last edited by Wims; 13/03/10 10:40 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Part if not op [Re: Wims] #219340 13/03/10 11:02 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
ok Wims example works...but perhaps some events should be added to turn the timer off upon parting, quitting or disconnecting.

Re: Part if not op [Re: vinyltm] #219341 13/03/10 11:12 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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"
Re: Part if not op [Re: Tomao] #219342 13/03/10 11:16 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
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
Re: Part if not op [Re: vinyltm] #219344 13/03/10 11:52 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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 }

Re: Part if not op [Re: Tomao] #219345 14/03/10 01:26 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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) }

Re: Part if not op [Re: Horstl] #219347 14/03/10 06:51 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks Horstl. You're not nit-picking. You're being helpfully informative. This is what makes one's improvement in learning.