egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

a little help

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Ezekiel
Voice


Joined: 16 Dec 2014
Posts: 21

PostPosted: Wed Dec 24, 2014 5:40 am    Post subject: a little help Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Dec 24, 2014 10:52 am    Post subject: Reply with quote

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. Smile
_________________
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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Dec 24, 2014 4:52 pm    Post subject: Reply with quote

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. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Ezekiel
Voice


Joined: 16 Dec 2014
Posts: 21

PostPosted: Thu Dec 25, 2014 3:18 am    Post subject: Reply with quote

Yes, it's $vhost indeed Smile
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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Dec 25, 2014 4:24 am    Post subject: Reply with quote

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

Merry Christmas everyone! Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Ezekiel
Voice


Joined: 16 Dec 2014
Posts: 21

PostPosted: Mon Feb 09, 2015 3:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Feb 10, 2015 1:43 am    Post subject: Reply with quote

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
View user's profile Send private message
Ezekiel
Voice


Joined: 16 Dec 2014
Posts: 21

PostPosted: Tue Feb 10, 2015 3:06 am    Post subject: Reply with quote

Yeah, i think i did it Smile

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber