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.

kick cmd not working

Old posts that have not been replied to for several years.
Locked
User avatar
kazoo
Halfop
Posts: 48
Joined: Wed Jun 18, 2003 7:26 pm
Location: Nashville, TN
Contact:

kick cmd not working

Post by kazoo »

Why doesn't this work?

Code: Select all

bind pub o|f .kick cmd:kick
proc cmd:kick {nick host hand chan text} {
putkick "$chan :$text"
puthelp "Privmsg $nick :Kicked $text from $chan"
}
I'm using eggdrop1.6.8 btw
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

You need the correcy syntax for putkick

Code: Select all

 putkick $chan $target $reason 
and if you replace

Code: Select all

proc cmd:kick {nick host hand chan text} {
with

Code: Select all

 proc cmd:kick {nick host hand chan args} { 
and add

Code: Select all

set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
Im sure you can figure the rest out :)
Dave
User avatar
kazoo
Halfop
Posts: 48
Joined: Wed Jun 18, 2003 7:26 pm
Location: Nashville, TN
Contact:

Post by kazoo »

Thanks :]
User avatar
kazoo
Halfop
Posts: 48
Joined: Wed Jun 18, 2003 7:26 pm
Location: Nashville, TN
Contact:

Post by kazoo »

Is this what I should have?

Code: Select all

bind pub o|f .kick cmd:kick
proc cmd:kick {nick host hand chan args} {
set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
putkick "$chan [lindex $arg 1] [lrange $arg 2 end] ($nick)"
puthelp "Privmsg $nick :Kicked [lindex $arg 1] from $chan"
}
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dw2k wrote:

Code: Select all

set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
Do you have the slightest idea what you're doing? :o First you use a special argument name (args - read about it here: http://tcl.tk/man/tcl8.4/TclCmd/proc.htm) that's not needed for this kind of task (a predefined number of arguments), then you join the list created by it, so you're left with the string that was passed to the proc, and THEN you start using list commands on that string. (not a good idea)
How about NOT doing all that? :P
kazoo wrote:Is this what I should have?

Code: Select all

...
No..you didn't listen to what Dw2k said about putkick (the only thing he got right) Try something like this (lots of extra bloat added, sorry):

Code: Select all

bind pub o|f .kick cmd:kick
proc cmd:kick {nick uhost hand chan arg} {
  # extract the first word and the remaining ones (if any)
  # into separate vars and store the return value from 'scan'
  set i [scan $arg "%s %\[^\n\]" victim reason]
  # if scan returned something > 0 we know there's a victim...
  if {$i>0} {
    # checking to see if there's someone by that nick present...
    if {[onchan $victim $chan]} {
      # did the scan find a reason or do we have to provide a default value?
      if {$i!=2} {
        set reason "$nick doesn't seem to like you."
      }
      putkick $chan $victim $reason
    } else {
      puthelp "NOTICE $nick :$victim is not on $chan"
    }
  } else {
    # no arguments were provided, so we tell the stupid user
    # how it should be done ;)
    puthelp "NOTICE $nick :Syntax: $::lastbind nick ?reason?"
  }
}
This code is not tested, but should at least give you some new ideas :)
You're still left with an authentication problem, though. How do you make sure the people triggering the proc really are who they seem to be?
Have you ever read "The Manual"?
User avatar
kazoo
Halfop
Posts: 48
Joined: Wed Jun 18, 2003 7:26 pm
Location: Nashville, TN
Contact:

Post by kazoo »

the users have specific host masks.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

user wrote:
Dw2k wrote:

Code: Select all

set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
Do you have the slightest idea what you're doing? :o First you use a special argument name (args - read about it here: http://tcl.tk/man/tcl8.4/TclCmd/proc.htm) that's not needed for this kind of task (a predefined number of arguments), then you join the list created by it, so you're left with the string that was passed to the proc, and THEN you start using list commands on that string. (not a good idea)
How about NOT doing all that? :P
As noted in my previous post to arcane in another thread, if we were speaking of plain old vanilla TCL, you would be right about him using args improperly... However because of the way bind calls procedures, it produces a list of lists in this scenario... so join'ing the list of lists produces a single list..... But Again, I don't agree with using this method any more than you do....
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

strikelight, I'm not sure what you mean. Are you saying bind passes a list as the last argument, not a string? I'm pretty sure that's wrong!
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

I think you're wrong.

Post by user »

strikelight wrote:As noted in my previous post to arcane in another thread, if we were speaking of plain old vanilla TCL, you would be right about him using args improperly... However because of the way bind calls procedures, it produces a list of lists in this scenario... so join'ing the list of lists produces a single list.....
Since when does eggdrop do that? And what exactly do you mean? It's passed to the proc as a string in my 1.6.13 test bot.
[13:20] (@user) % bind pub n !doit doit; proc doit {n u h c args} {putserv "PRIVMSG $c :[join $args]"}
[13:21] (@user) !doit { [
[13:21] (@sh) { [
Have you ever read "The Manual"?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

After a night's sleep, I have thought about it more clearly.... Peterre's page confused me into wrongly accusing eggdrop's bind command... Of course it would be a string passed to the last parameter, and 'args' by its very nature converts to a list.... Thus by join'ing it, you would get a string still needing to be split....

What else can I say.... My bad... :oops:
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

Hah! :P
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
Locked