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 little help.

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
crux
Voice
Posts: 35
Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:

need little help.

Post by crux »

Code: Select all

#Make the bot KICK someone...

bind msg n|n .kick kick
proc kick {nick host handle channel testes} {
set who [lindex $testes 0]
set why [lrange $testes 1 end]
if {$who == ""} {
putserv "NOTICE $nick :Usage: .KICK <nick> <reason>"
return 1
}
putserv "KICK $who :$why"
putserv "NOTICE $nick :Done: KICKED $who with: $why"
return 1
}
#end of kick
this code doesn't work. I think I need sth.. please help me if you know..

thanks you.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Try:

Code: Select all

#Make the bot KICK someone...

bind msg n|n .kick kick
proc kick {nick host handle channel testes} {
set who [lindex $testes 0]
set why [lrange $testes 1 end]
if {$who == ""} {
  putserv "NOTICE $nick :Usage: .KICK <nick> <reason>"
} elseif {![onchan $who $channel]} {
  putserv "NOTICE $nick :$who not on $channel."
} else {
  if {$why == ""} {
    putserv "KICK $channel $who :Requested by $nick"
  } else {
    putserv "KICK $channel $who :$why"
  }
}
#end of kick
Not Tested
r0t3n @ #r0t3n @ Quakenet
User avatar
crux
Voice
Posts: 35
Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:

Post by crux »

Thanks you much, I'll test..
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You might wanna keep in mind there's no "channel" argument on a msg-binding...
Also, please considder "splitting" strings into lists before using list-operations such as lindex, lrange, etc. Especially when it comes from an untrusted source (in this case, untrusted means anything that might generate an improper list-structure)
NML_375
User avatar
crux
Voice
Posts: 35
Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:

Post by crux »

Tosser^^ wrote:Try:

Code: Select all

#Make the bot KICK someone...

bind msg n|n .kick kick
proc kick {nick host handle channel testes} {
set who [lindex $testes 0]
set why [lrange $testes 1 end]
if {$who == ""} {
  putserv "NOTICE $nick :Usage: .KICK <nick> <reason>"
} elseif {![onchan $who $channel]} {
  putserv "NOTICE $nick :$who not on $channel."
} else {
  if {$why == ""} {
    putserv "KICK $channel $who :Requested by $nick"
  } else {
    putserv "KICK $channel $who :$why"
  }
}
#end of kick
Not Tested


donesn't work :(

i got this error:

Code: Select all

[20:55] Tcl error [kick]: wrong # args: should be "kick nick host handle channel testes"
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

nml375 wrote:You might wanna keep in mind there's no "channel" argument on a msg-binding...
Also, please considder "splitting" strings into lists before using list-operations such as lindex, lrange, etc. Especially when it comes from an untrusted source (in this case, untrusted means anything that might generate an improper list-structure)
i.e.

Code: Select all

bind msg n|n .kick kick

proc kick {nick host hand arg} {
 if {[scan $arg "%s %s" who chan] != 2} {
  puthelp "notice $nick :Usage: .kick <chan> <nick> \[reason\]"
  return 0
 }
 set why [join [lrange [split $arg] 2 end]]
 if {![onchan $who $chan]} {
  puthelp "NOTICE $nick :$who not on $chan."
 } {
  if {$why == ""} {
   putserv "KICK $chan $who :Requested by $nick"
  } {
   putserv "KICK $chan $who :$why"
  }
 }
}
User avatar
crux
Voice
Posts: 35
Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:

Post by crux »

thanks you
it's working now :D
Post Reply