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.

matchattr problem

Old posts that have not been replied to for several years.
Locked
t
the_crow
Halfop
Posts: 42
Joined: Fri Feb 28, 2003 7:37 am
Location: Lisboa, Portugal

matchattr problem

Post by the_crow »

Hi there.... i made one tcl, but i can't find the problem, can you help me?!
theres the code

Code: Select all

set text1 "text number 1"
set text2 "text number 2"
set reason "you are out" 

bind pub - !power pub:power


proc pub:power {nick uhost handle chan text} {
global botnick
global text1
global text2
global reason
if {([matchattr $nick o|o $chan])}  {
 		 puthelp "PRIVMSG $nick: $text1"
		 puthelp "PRIVMSG $nick: $text2" 
	} else putkick $chan $nick $reason
}
why when someone that have the flag +o when put the trigger he doesn't give the text!!? The ideia of this tcl is that, someone that have the flag, when trig the !power it will be sent to him a text, if this person don't have the falag should be kick.
Thanks guys :)
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Re: matchattr problem

Post by strikelight »

the_crow wrote:Hi there.... i made one tcl, but i can't find the problem, can you help me?!
theres the code

Code: Select all

set text1 "text number 1"
set text2 "text number 2"
set reason "you are out" 

bind pub - !power pub:power


proc pub:power {nick uhost handle chan text} {
global botnick
global text1
global text2
global reason
if {([matchattr $nick o|o $chan])}  {
 		 puthelp "PRIVMSG $nick: $text1"
		 puthelp "PRIVMSG $nick: $text2" 
	} else putkick $chan $nick $reason
}
why when someone that have the flag +o when put the trigger he doesn't give the text!!? The ideia of this tcl is that, someone that have the flag, when trig the !power it will be sent to him a text, if this person don't have the falag should be kick.
Thanks guys :)
"matchattr" matches flags against a 'handle' not a 'nick'...
Thus, you should be using $handle not $nick.
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Code: Select all

set text1 "text number 1" 
set text2 "text number 2" 
set reason "you are out" 

bind pub - !power pub:power 


proc pub:power {nick uhost handle chan text} { 
global botnick text1 text2 reason
if {[matchattr $nick o|o $chan]}  { 
        puthelp "PRIVMSG $nick: $text1" 
        puthelp "PRIVMSG $nick: $text2"
        return 0
     } else { 
       putkick $chan $nick $reason 
       return 0
       }
   }
} 
This looks about right, you can check matchattr against a nickname. Generally, 'nick' is usually the person who triggered command. This is untested, but looks about right.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

'Generally' and 'usually' don't occur often enough..

In any event, I also just noticed this:

Code: Select all

        puthelp "PRIVMSG $nick: $text1" 
        puthelp "PRIVMSG $nick: $text2" 
IRC expects a PRIVMSG to be of the format:
PRIVMSG <target> :<message>

Notice that the colon comes right before the message, not right after the target.... thus it should be:

Code: Select all

        puthelp "PRIVMSG $nick :$text1" 
        puthelp "PRIVMSG $nick :$text2" 
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Use the nick2hand to get the hand from a nick and then use matchattr, but in your case use matchattr on handle, if it's known by the bot will be his user if is not will be * as in everyone aka. no access :)
Once the game is over, the king and the pawn go back in the same box.
Locked