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.

Is this correct?

Old posts that have not been replied to for several years.
Locked
I
Ice-Beck

Is this correct?

Post by Ice-Beck »

bind msg f kick do_kick

proc do_kick {n u h t} {
set targ [lindex $t 1]
set chan [lindex $t 0]
putkick $chan $targ $reason
}

is this tcl correct for /msg bot kick <channel> <nick> <reason>?
t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

Does it work? :P
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

LOL - COme on, poor bloke must be getting excited, when you know it doesn't :P

This is a pretty good first attempt at a script, however, there are a few issues that should be addressed.

First off, you are using the variable $reason, to specify a reason for the kick. The major issue here is, you havn't defined the variable reason, and as such, it doesn't exist.

Second, the way you named your variables. You usage is correct, but for simplicity, you should name tham better. Once you start on scripts that involve 20 lines upwards, youw ill start to get confused, as to what contains what. Using variables like $nick, show what it is supposed to contain.

Third. This isn't your fault, it's just part of the learning cycle. When using the [lindex] command, Tcl is expecting a "Tcl encoded" list, as it's argument.

In a nutshell, a list, is a string of data, than can contain one or more, items, that can be of pretty much any length. Where in your script, you want to pick 1 item of many (EG, you only what the channel, or only the nickname), Tcl lists can contain multiwork aguments. (EG, index 0 could be "hello" and index 2 could be "hello to all").

In your script, you are using the rest of the text sent to the bot. This is exactly what it is, a string, and not a list.

Tcl provides 2 commands, that can convert to and from a list. IE, a string to a list, and list to a string. These are what you can use, to correctly provide the lindex command with what it needs.

The split command (the one you want) will convert the text into a list, and join command, will convert it the otherway.

Failure to do this, will not produce any noticable results in most usage, however, once you start trying to kick nicknames like "[clan]onetwo", it will start spitting errors.
t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

Sorry! :D I was just in one of them moods..
Locked