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.
Help for those learning Tcl or writing their own scripts.
crux
Voice
Posts: 35 Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:
Post
by crux » Tue Jan 23, 2007 2:28 pm
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.
r0t3n
Owner
Posts: 507 Joined: Tue May 31, 2005 6:56 pm
Location: UK
Post
by r0t3n » Tue Jan 23, 2007 3:12 pm
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
crux
Voice
Posts: 35 Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:
Post
by crux » Tue Jan 23, 2007 3:31 pm
Thanks you much, I'll test..
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Tue Jan 23, 2007 3:35 pm
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
crux
Voice
Posts: 35 Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:
Post
by crux » Thu Jan 25, 2007 3:55 pm
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"
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Thu Jan 25, 2007 4:34 pm
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"
}
}
}
crux
Voice
Posts: 35 Joined: Fri Jan 05, 2007 12:41 pm
Location: Myanmar
Contact:
Post
by crux » Thu Jan 25, 2007 6:56 pm
thanks you
it's working now