| View previous topic :: View next topic |
| Author |
Message |
Ezekiel Voice

Joined: 16 Dec 2014 Posts: 21
|
Posted: Wed Dec 24, 2014 5:40 am Post subject: a little help |
|
|
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: |
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"
}
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Dec 24, 2014 10:52 am Post subject: |
|
|
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: |
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: |
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: |
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.  _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Thu Dec 25, 2014 4:25 am; edited 1 time in total |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Dec 24, 2014 4:52 pm Post subject: |
|
|
| caesar wrote: | | Code: | | 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.  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Ezekiel Voice

Joined: 16 Dec 2014 Posts: 21
|
Posted: Thu Dec 25, 2014 3:18 am Post subject: |
|
|
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! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Dec 25, 2014 4:24 am Post subject: |
|
|
@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. |
|
| Back to top |
|
 |
Ezekiel Voice

Joined: 16 Dec 2014 Posts: 21
|
Posted: Mon Feb 09, 2015 3:42 pm Post subject: |
|
|
and for private message?
| Code: |
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"
}
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 10, 2015 1:43 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Ezekiel Voice

Joined: 16 Dec 2014 Posts: 21
|
Posted: Tue Feb 10, 2015 3:06 am Post subject: |
|
|
Yeah, i think i did it
Thank you.
| Code: | 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!"
}
} |
|
|
| Back to top |
|
 |
|