This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED] isvoice / isop help

Help for those learning Tcl or writing their own scripts.
Post Reply
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

[SOLVED] isvoice / isop help

Post by MIODude »

I just want a simple procedure to only be invoked if the user isn't an op or doesn't have voice...

Code: Select all

proc procname {nick uhost hand chan args} {
     if {{![isvoice $nick $chan]} || {![isop $nick $chan]}} {
     putchan $chan "$nick, blah blah blah"
     return 1
  } 
return 1
}
i've tried multiple variations - i get
expected boolean value but got "![isvoice $nick $chan]"

What am I doing wrong?
Last edited by MIODude on Sat Oct 03, 2009 6:37 pm, edited 1 time in total.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Logically you need && instead of || because you want to trigger if user is not op AND is not voice.

You are also using braces to seperate the two commands determining the logical result instead of parenthesis. Braces generally hinder variable, command and backslash substitution.

I'm not entirely sure what putchan means. Perhaps you mean one of the Eggdrop Tcl output commands putserv or putquick.

The argument 'args' has special meaning, do not use it in this context.

Generally I would use return 0 or even simply return at the conclusion of a proc, though there are special circumstances where you may want to deliberately return 1. Refer to 'return values' in tcl-commands.doc. In any case you don't need two such statements as per your code.

Code: Select all

proc procname {nick uhost hand chan text} { 
    if {(![isvoice $nick $chan]) && (![isop $nick $chan])} {
        putserv "PRIVMSG $chan :$nick, blah blah blah"
    } 
    return 0
}
Last edited by arfer on Sat Oct 03, 2009 6:37 pm, edited 1 time in total.
I must have had nothing to do
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

SOLVED

Post by MIODude »

Thanks! that did it..

I'm not sure about the putchan myself - it came with the original script that i was modifying
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The putchan command is provided by the alltools.tcl script provided with eggdrops.

As for the logics, you don't need those parenthesis, as the not-operator (!) has higher priority than either and-operator (&&) or or-operator (||). No harm in including them though.
NML_375
Post Reply