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.

Tcl error in script for 'timer209':

Old posts that have not been replied to for several years.
Locked
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Tcl error in script for 'timer209':

Post by Alchera »

Hi,

I am testing a rather neat script that does autogreets with a difference, it doesn't greet every Tom, Dick & Harry that enters a channel (a feature I really like). The problem is that it generates the following error (of and on)...

Tcl error in script for 'timerxxx':
invalid command name "1"

I am unable to contact the author as his e-mail addresses are no longer valid and even a memo on an IRC network proved fruitless.

Here is the main code:

bind join - ***** greet_join
proc greet_join {nick uhost hand chan} {
global botnick publics
if {$publics == 0} {return 0}

if {$botnick == $nick} {return 1}
if {![greetchan $chan]} {return 1}

utimer [expr [rand 15] + 5] [greet_do $nick $chan]
return 1
}

proc greet_do {nick chan} {
global greet
set gnick $nick
set anick ""
set gloop 0;
while {$gloop < [string length $nick]} {
if {[string match "*[string index $nick $gloop]*" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"]} {set anick "$anick[string index $nick $gloop]"}
incr gloop 1
}
if {[string length $anick] < 3} {set anick $nick}
# putlog "greet_do $nick $chan anick:$anick gnick:$gnick"
if {![onchan $nick $chan]} {return 1}
if {![probability $greet(greetprob)]} {return 1}
if {![probability $greet(snaprob)]} {set gnick $anick}
if {![probability $greet(nlowprob)]} {set gnick [string tolower $gnick]}

set outmsg [randomline $greet(lines)]
if {[probability $greet(mlowprob)]} {set outmsg [string tolower $outmsg]}
if {([probability $greet(end1prob)]) && ([string index $outmsg [expr [string length $outmsg] - 1]] != "?")} {append outmsg [randomline $greet(endings1)]}
if {[probability $greet(end2prob)]} {append outmsg [randomline $greet(endings2)]}
regsub -all {\$nick} $outmsg $gnick outmsg
regsub -all {\$chan} $outmsg $chan outmsg
regsub -all {\\001} $outmsg \001 outmsg
regsub -all {\\002} $outmsg \002 outmsg
switch $greet(notification) {
1 {putserv "PRIVMSG $chan :$outmsg"}
2 {putserv "PRIVMSG $nick :$outmsg"}
3 {putserv "NOTICE $nick :$outmsg"}
}
}

proc randomline {text} {
return [lindex $text [rand [llength $text]]]
}

proc greetchan {chan} {
global greet
set chan [string tolower $chan]
set chans [string tolower $greet(chans)]
if {$chan == "*"} {set chans [string tolower [channels]]}
set dothechan 0
foreach c $chans {
if {($chan == $c)} {set dothechan 1}
}
if {$dothechan == 0} {return 0} else {return 1}
}


proc probability {prob} {
if {$prob == 100} {return 1}
set r [rand 100]
set rng [rand [expr 100 - $prob]]
set rngu [expr $rng + $prob]
# putlog "prob:$prob r:$r range: $rng - $rngu"
if {($r > $rng) && ($r < $rngu)} {return 1}
return 0
}

I am not exactly sure what to do to fix it. Everytime I "fiddle" I seem to upset something and every nick that enters a channel ends up getting greeted, which is not what I want.

Many thanks for *any* help on this. :)

PS: This script is about 3 years old.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Tcl error in script for 'timer209':

Post by user »

Alchera wrote:utimer [expr [rand 15] + 5] [greet_do $nick $chan]
This will execute greet_do immediately and the returned value (usually an empty string) is eval'ed when the timer ends.

change [greet_do ...] to [list greet_do ...] and everything should be fine
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Thank you very much. Modification made and all should be well with the world :D
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Locked