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.

Invkick.tcl help

Support & discussion of released scripts, and announcements of new releases.
Post Reply
F
F-user
Voice
Posts: 2
Joined: Sat Feb 06, 2010 4:51 am

Invkick.tcl help

Post by F-user »

Okey i have found this script invkick.tcl on egghelp but one problem it isnt working properly!

This error comes in partyline everytime i try to invite bot channel.
Tcl error [invitechan]: invalid channel prefix

Is this problem on script or in my bot?

command /invite botnick #chan
# Bot invite and kick script, makes the bot respond to invitations and stay away after being kicked.
# There is a build in check for +o status you might want to disable, look at the commented line in the code.
# By [NUT] (nut@fun-industries.nl) a.k.a. dFt^Nut http://www.dftclan.nl

### Config ###

###
# If you dont want invite to be opper only, change this value [1 = on, 0 is off]
###

set oponly "1"

###
# If you are not using an irc network that has a channel limit, set the number of max channels to 0,
# this will disable the maxchan value. Simply set this to your networks maxchan value otherwise.
# [Set to 20 as default (Quakenet)]
###

set chanlim "20"

### Change Log ###
# Version 1
# - Initial release
# Version 1.01
# - Fixed a small bug
# - Changed some configuration options
# Version 1.02
# - Fixed another small bug :|
# Version 1.03
# - discovered quick and dirty (untested) bug fixes are bad :P
# - discovered my nickname was disliked by TCL :P
# - fixed bugs :P
###

###
# Remember to quit and restart the bot and check for conflicting scripts!
# Not doing this will result in a nonfunctional script. After loading this script and discovering
# it doesnt work dcc into your bot and type .binds (be sure to have scroll back on!) and check the
# binds for command types kick and raw.
###

bind raw - INVITE invitechan
bind kick - * gotkicked

proc invitechan {mask word args} {
global chanlim oponly
set opts [split $mask "!"]
set nick [lindex $opts 0]
set opts [split $args "{:}"]
set chan [lindex $opts 2]
set uhand [nick2hand $nick]

if {$oponly} {
if {![matchattr $uhand "o"]} { return 0 }
}

if {$chanlim > 0} {
if {[llength [channels]] >= $chanlim} {
puthelp "NOTICE $nick :Sadly I cannot join any more channels."
return 0
}
}

channel add $chan {}
save
}

proc gotkicked {nick mask handle chan target reason} {
global botnick chanfile

if {[string match $botnick $target]} {
set isdynamic 0
set channelconf [open $chanfile r]
while {![eof $channelconf]} {
gets $channelconf regel
if {$regel == "" || [string match "#*" $regel]} { continue }
if {[string match -nocase "channel?add?$chan*" $regel]} { set isdynamic 1 } else { continue }
}

if {$isdynamic == "1"} {
channel remove $chan
save
}
}
}

putlog "invkick 1.03 Loaded. Made by NUT"
Thanks for help
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

It's because the coder of this script is making the mistake of using the special token "args" within his procedure header for invitechan. Then they craft crude work-arounds to cleanup what this does.

Code: Select all

set opts [split $args "{:}"]
set chan [lindex $opts 2] 
Usually when you split raws this way, you want lindex position 1. But here, notice they've used lindex position 2. This is because of the extra bracings introduced by using the special token "args" when using it to replace one argument within a bind. This throws everything off, and special characters will now cause problems and break this script easily. I've rewritten it for you clean, and according to the golden rules of tcl. Enjoy ;)

Code: Select all

# 0 = no, 1 = yes
set oponly "1"
# how many channels is the max
# you want your bot in?
# set to zero to not use a limit.
set chanlim "20"

# binds
bind raw - INVITE invitechan
bind kick - * gotkicked

# invite
proc invitechan {from key text} {
	global chanlim oponly
	set nick [lindex [split $from "!"] 0]
	set chan [lindex [split $text :] 1]
	if {$oponly && ![matchattr [nick2hand $nick] "o"]} { return 0 }
	if {$chanlim > 0 && [llength [channels]] >= $chanlim} {
		puthelp "NOTICE $nick :Sadly I cannot join any more channels."
		return 0
	}
	channel add $chan
	save
}

# kick
proc gotkicked {nick uhost hand chan target reason} {
	global chanfile
	if {[isbotnick $target]} {
		set channelconf [open $chanfile r]
		while {![eof $channelconf]} {
			gets $channelconf regel
			if {$regel == "" || [string match "#*" $regel]} { continue }
			if {[string match -nocase "channel?add?$chan*" $regel]} {
				channel remove $chan
				break
			}
		}
		close $channelconf
	}
}

putlog "invite script loaded."

# the reason for using eof is simple, if you downloaded this
# and do NOT see "#eof" as the last line here, then you
# do not have the complete script....

#eof
F
F-user
Voice
Posts: 2
Joined: Sat Feb 06, 2010 4:51 am

Post by F-user »

Ok thanks. Now leave for kick works perfectly but still /invite botnick #channel doesn't work

From dcc partyline.

13:53 <botnick> [13:53] Tcl error [invitechan]: invalid channel prefix
13:53 <botnick> [13:53] Anom!anonym@anonymworksi.com invited me to #channel
Post Reply