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.

Need Help with Userlist

Help for those learning Tcl or writing their own scripts.
t
theice
Voice
Posts: 36
Joined: Thu Mar 13, 2008 4:20 pm

Need Help with Userlist

Post by theice »

okay.

Code: Select all

bind join - * rockband:greeting
proc rockband:greeting {n u h c } {
	global channel
	if {$c == "$channel"} {
		if {[matchattr $h |f $channel]} {
			 puthelp "PRIVMSG $c :\002$n:\002 \037\002Console\037\002: [getuser $n XTRA console] \002\037Username\037\002: [getuser $n XTRA username] \002\037Instruments\037\002: [getuser $n XTRA instruments]"
		} else {
			putserv "NOTICE $n :\002Hello $n\002 you aren't registered with RockBand, to register msg |ICE| , Apples"
			
		}
	}
}
I am trying to make it so, if I add a user with the nick Test , if they later change their nick to Test2 it will still greet them by checking their host matches any of the handles, or something like that..

my script works great if no one changes their nick, but what perfect world does that happen?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Well, for starters...

Code: Select all

[getuser $n XTRA username]
...
[getuser $n XTRA instruments]
Firstly, $n contains the current nickname of the user...
$h is the handle they were added to the bot with... I think you want $h...

Secondly, why use [getuser ... username] at all? Why not just use $h?
t
theice
Voice
Posts: 36
Joined: Thu Mar 13, 2008 4:20 pm

Post by theice »

strikelight wrote:Well, for starters...

Code: Select all

[getuser $n XTRA username]
...
[getuser $n XTRA instruments]
Firstly, $n contains the current nickname of the user...
$h is the handle they were added to the bot with... I think you want $h...

Secondly, why use [getuser ... username] at all? Why not just use $h?
the getuser username is for a username for the game, not their handle.

even if I switch it to $h it wasn't working.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

If they are seeing the notice from the bot that they are not registered, then their hostmask has changed from what they were added with.

To comment on anything other than that would be purely speculative as you have not provided the code you use for registration. (Unless you are manually adding them, we need to see an example of how you are setting their hostmask and XTRA settings).
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Look at nick2hand and finduser in the "Eggdrop TCL Commands" that can be found in the eggdrop documentation..
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

S/He's already got the handle passed from the binding in $h
t
theice
Voice
Posts: 36
Joined: Thu Mar 13, 2008 4:20 pm

Post by theice »

That was fixed, the handle problem on the greeting. But now I am changing my .whois [nick] command.

how can I take whatever they type for [lindex $text 0] and get the handle of that nick.

Code: Select all

bind pub - ${pubtrig}whois whois:pub
proc whois:pub {n u h c t} {
	global channel
	set usern [lindex $t 0]
	if {[matchattr $usern |f $channel]} {
		puthelp "PRIVMSG $c :\002[lindex $t 0] is\002 \037\002Console\037\002: [getuser [lindex $t 0] XTRA console] \002\037Username\037\002: [getuser [lindex $t 0] XTRA username] \002\037Instruments\037\002: [getuser [lindex $t 0] XTRA instruments]"
	}			
}

im sorry if you hate shortened vars, I will learn to get out of that someday.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Firstly, (Dragon's gunna love this)...
You should not be using list operations on strings....

Code: Select all

set usern [lindex [split $t] 0]
Is what you want....

secondly... I'm assuming that the specified nick is a user on the channel?
In which case you would use...

Code: Select all

set hand [nick2hand $usern $c]
the $c is optional, but it can't hurt... (Note: if the user with the specified nick isn't added, hand will be set to "*")
t
theice
Voice
Posts: 36
Joined: Thu Mar 13, 2008 4:20 pm

Post by theice »

awesome thanks for your guys help,

figured it all out =]

its my first week with tcl sooooo sorry im nooby :-D


one more question

how can I do like

Code: Select all

if {[lindex $t 2] doestnotequal "this" or "this2"} {
			putserv "NOTICE $n :\002Syntax error:\002 please use (.search console XBox/PS3 )"
			return 0
		}

ONE MORE THING: if someone does .whois handle that won't work anymore since we did the nick2han how can I make so if [lindex $t 1 == handle and not a nick] do this
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I've never recommended using lindex on any string. :P

Funny though that you said nick2hand and finduser weren't much help, then you give an example using nick2hand. I needed a good smile. :)
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

(again, do not treat strings as lists, convert strings to lists using [split] first)..

Several ways you can do what you are asking...
Here are some examples:

eg1.

Code: Select all

if {([lindex [split $t] 0] == "moo") || ([lindex [split $t] 0] == "foobar")} {
  # do what you want
  # Notes: || is OR, while && is AND
  # Notes: This example is not case insensitive
}
eg2.

Code: Select all

if {[regexp ^(moo|foobar)$ [lindex [split $t] 0]]} {
  # do what you want
  # Notes: For regular expressions | is equivelent to OR
  # Notes: ^ must match at beginning of string
  # Notes: $ must match at ending of string
  # Notes: See Tcl manpages for regex syntax
}
You can also use a -nocase switch with regexp to make it case insensitive.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

DragnLord wrote:I've never recommended using lindex on any string. :P

Funny though that you said nick2hand and finduser weren't much help, then you give an example using nick2hand. I needed a good smile. :)
nick2hand was for a follow up question, a question he asked AFTER you replied to the initial question. the nick2hand was for a different trigger altogether.

/me laughs last

;x
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

theice wrote: ONE MORE THING: if someone does .whois handle that won't work anymore since we did the nick2han how can I make so if [lindex $t 1 == handle and not a nick] do this
You shouldn't edit your posts after people have already replied.. Instead make a reply post...

Code: Select all

if {[validuser "bunny"]} { # bunny is a valid user }
See Tcl-commands.doc that comes with your eggdrop please.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Might want to read the postings better.
/me gets to laugh louder
:D
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

DragnLord wrote:Might want to read the postings better.
/me gets to laugh louder
:D
Think you might want to...
First post by the user was a join binding (the one which you replied to).. which did NOT require nick2hand....

The post after your reply was a pub binding... which COULD have used nick2hand under given assumptions...
I'm pretty sure you don't posses the gift of seeing into the future..

/me laughs loudest
:twisted:


In any event, this has gotten long past silly....
Post Reply