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.

a little help

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Ezekiel
Voice
Posts: 21
Joined: Tue Dec 16, 2014 8:05 am

a little help

Post by Ezekiel »

I am new and I need a little help to understand something.
I have an eggdrop who is logged as iRcop and I want to use this public command to let users set their own vhosts.

Tcl error [vhost]: wrong # args: should be "vhost nick uhost handle channel arg pass"

Code: Select all

bind pub - !vhost vhost

proc vhost { nick uhost handle channel arg pass } {

if {[llength $pass]==0} {
   putserv "PRIVMSG $channel :$nick: To change your host type: !vhost <your.vhost> <pass>"  
   } else {
   putquick "PRIVMSG H :add $nick $uhost $arg $pass"
   putserv "PRIVMSG $channel :$nick: Your Vhost has been changed to: $arg"
   }
 }
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The pub bind accepts only 5 arguments: nick, user@host, handle, channel, and text.

You need to check the text for a vhost and password. You could do this by either splitting the $text variable with split then lindex to or by using scan. I prefer the second option.

Anyway, the two methods are:

Code: Select all

set text [split $text]
if {[llength $text] != 2} {
	putserv "PRIVMSG $channel :$nick: To change your host type: !vhost <your.vhost> <pass>"
} else {
	set vhost [lindex $text 0]
	set password [lindex $text 1]
	# use $vhost and $password to do whatever
}
and the one I prefer that's a little less messy:

Code: Select all

if {[scan $text {%s%s} vhost password] != 2} {
	putserv "PRIVMSG $channel :$nick: To change your host type: !vhost <your.vhost> <pass>"
}
# use $vhost and $password to do whatever
Now, with the above in mind your proc is changed like this:

Code: Select all

bind pub - !vhost vhost

proc vhost { nick uhost handle channel text} {
	if {[scan $text {%s%s} vhost password] != 2} {
		puthelp "PRIVMSG $channel :$nick: To change your host type: !vhost <your.vhost> <pass>"
	} else {
		puthelp "PRIVMSG H :add $nick $uhost $vhost $password"
		puthelp "PRIVMSG $channel :$nick: Your Vhost has been changed to: $vhost"
	}
}
Edit: Typo fix. :)
Last edited by caesar on Thu Dec 25, 2014 4:25 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

caesar wrote:

Code: Select all

puthelp "PRIVMSG H :add $nick $uhost $text $password"
Shouldn't $text be $vhost ?

caesar, I admire the time you take with new people. Even the time you took on this post too. The explanations and such are something not enough people are doing. This helps spread the joy of eggdrop to all. I am not knocking you at all. Please don't see it that way. Merry Christmas and hopefully Santa brings you good tidings. Even if he doesn't, your good cheer is well noticed. ;)
User avatar
Ezekiel
Voice
Posts: 21
Joined: Tue Dec 16, 2014 8:05 am

Post by Ezekiel »

Yes, it's $vhost indeed :)
I just tested it and it's working great with that change, thanks a lot caesar and speechles too.
Merry XMas and a Happy New Year full of achievements and opportunities!
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

@speechles : Awww.. yeah, missed that. :) Thanks buddy. No grudge at all. :)

Merry Christmas everyone! :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Ezekiel
Voice
Posts: 21
Joined: Tue Dec 16, 2014 8:05 am

Post by Ezekiel »

and for private message?

Code: Select all

bind msg - !vhost vhost 

proc:msg vhost { nick uhost handle channel text} { 
   if {[scan $text {%s%s} vhost password] != 2} { 
      puthelp "PRIVMSG $channel :$nick: To change your host type: !vhost <your.vhost> <pass>" 
   } else { 
      puthelp "PRIVMSG H :add $nick $uhost $vhost $password" 
      puthelp "PRIVMSG $channel :$nick: Your Vhost has been changed to: $vhost" 
   } 
}
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Easy, replace $channel with $nick on the lines you wish to have the message be sent to the person triggering the command, not to the channel.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Ezekiel
Voice
Posts: 21
Joined: Tue Dec 16, 2014 8:05 am

Post by Ezekiel »

Yeah, i think i did it :)

Thank you.

Code: Select all

bind msg - request vhost

proc vhost { nick uhost handle text} {
	global botnick
	if {[scan $text {%s%s} vhost password] != 2} {
		puthelp "PRIVMSG $nick :Syntax: request <your.vhost.here> <pass>"
	} else {
		puthelp "PRIVMSG Florian :add $nick *!*@$uhost *!*@$vhost $password"
		puthelp "PRIVMSG $nick :Your Vhost has been changed to: $vhost. Have fun!"
	}
}
Post Reply