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.

TODO.TCL get some Error

Support & discussion of released scripts, and announcements of new releases.
Post Reply
d
dvibe
Voice
Posts: 6
Joined: Tue Jun 28, 2005 8:45 pm
Contact:

TODO.TCL get some Error

Post by dvibe »

Hi !

Need Help please:

on Irc channel command

!todo #testchannel complete 1

get this error on bot

Tcl error [pub_todo]: cant read "channel": no such varaible

what can i do ? SOME TCL NEWBIE !


# Todo list
#
# Description: Todo list to track work and accomplished work.
# keeps history and what not.
#
# Features: History Storing. Startup and Completion tracking.
#
# Usage: !todo (It'll display commands and options)
#
# Author: eRUPT(erupt@ruptbot.com)

##################
# Version History
#
# - v0.1 -
# First Release
# - v0.1a -
# Fixed missing shortcut proc(putnot).
# - v0.2 -
# Added channel specific lists.
# Added move command to help support new channel specific lists.
# - v0.3 -
# Added channel allow lists.
#
############

#Channels allowed to use ToDo list.
#*TIP* If you have eggdrop1.5 or above use the channel set method *TIP*
#[Alternatively you can use "channel set #channel +todo" to turn on and "-todo" to turn off]
#[If you have the .tcl prompt on in dcc chat you can use .tcl channel set #channel +todo]
set todo_channels {
#testchannel
}


set todo_ver "v0.3"

if {![file exists scripts/todo.lst]} {
set wfile [open scripts/todo.lst w]
puts $wfile ""
close $wfile
}
if {![file exists scripts/todo_history.lst]} {
set wfile [open scripts/todo_history.lst w]
puts $wfile ""
close $wfile
}

if {[lindex $version 1]>=1050000} { setudef flag todo }

proc putnot {nick msg} { putserv "NOTICE $nick :$msg" }



proc load_todo {} {
global todo
set rfile [open scripts/todo.lst r]
set upgrade 0
while {![eof $rfile]} {
set line [gets $rfile]
if {$line==""} { continue }
set err ""
if {![string equal {g} [string index $line 0]] && ![string equal {#} [string index $line 0]]} {
set line [linsert $line 0 global]
set upgrade 1
}
set channel [lindex $line 0]
if {[info exists temp($channel)]} {
append temp($channel) " " [list [lindex $line 1] [lrange $line 2 end]]
} else {
set temp($channel) [list [lindex $line 1] [lrange $line 2 end]]
}
}
close $rfile
array set todo [array get temp]
if {$upgrade} { putlog "Upgraded Todo list files." ; save_todo }
}

proc load_history {} {
global todo_history
set rfile [open scripts/todo_history.lst r]
set upgrade 0
while {![eof $rfile]} {
set line [gets $rfile]
if {$line==""} { continue }
set err ""
if {![string equal {g} [string index $line 0]] && ![string equal {#} [string index $line 0]]} {
set line [linsert $line 0 global]
set upgrade 1
}
set channel [lindex $line 0]
if {[info exists temp($channel)]} {
append temp($channel) " " [list [lindex $line 1] [lrange $line 2 end]]
} else {
set temp($channel) [list [lindex $line 1] [lrange $line 2 end]]
}
}
close $rfile
array set todo_history [array get temp]
if {$upgrade} { putlog "Upgraded Todo_History list files." ; save_todo }
}

proc save_todo {} {
global todo
set wfile [open scripts/todo.lst w]
foreach channel [array names todo] {
catch {unset temp}
array set temp $todo($channel)
foreach entry [array names temp] {
puts $wfile "$channel $entry $temp($entry)"
}
}
close $wfile
}

proc save_history {} {
global todo_history
set wfile [open scripts/todo_history.lst w]
foreach entry [array names todo_history] {
catch {unset temp}
array set temp $todo_history($channel)
foreach entry [array names temp] {
puts $wfile "$channel $entry $temp($entry)"
}
}
close $wfile
}

bind pub m|o !todo pub_todo

proc pub_todo {nick uhost hand chan arg} {
global todo todo_history todo_channels version
if {[lindex $version 1]>1050000} {
if {![channel get $chan todo]} { if {[lsearch $todo_channels [string tolower $chan]] == -1} { return 0 } }
} else { if {[lsearch $todo_channels [string tolower $chan]] == -1} { return 0 } }
if {$arg==""} {
putnot $nick " Usage: !todo \[#channel\] <option> \[arguments\]"
putnot $nick "Options: add delete move list complete history"
return 0
}
set channel "global"
if {[string equal [string index $arg 0] #]} {
set channel [lindex $arg 0]
set arg [lrange $arg 1 end]
if {[lsearch [string tolower [channels]] $channel] == -1} {
putnot $nick "Invalid channel requested!"
return 0
}
}
set option [lindex $arg 0]
set args [lrange $arg 1 end]
switch $option {
add {
if {[string equal {} $args]} {
putnot $nick "Usage: !todo \[#channel\] add <message>"
return 0
}
if {[string equal {*} $hand]} { set who $nick } else { set who $hand }
if {[info exists todo($channel)]} { array set local_todo $todo($channel) }
set local_todo([clock seconds]) "$who $args"
set todo($channel) [array get local_todo]
save_todo
putnot $nick "Added new Todo item \002$args\002"
return 0
}
delete {
if {[string equal {} $args]} {
putnot $nick "Usage: !todo \[#channel\] delete <number> \[history\]"
putnot $nick "*TIP* Use !todo list to view numbers *TIP*"
putnot $nick "Valid Number Formats: #-#(Number Range) , #,#,#(Set of Numbers) , #(Single Number)"
return 0
}
if {[info exists todo($channel)]} {
array set local_todo $todo($channel)
}
if {[info exists todo_history($channel)]} {
array set local_todo_history $todo_history($channel)
}
if {[string equal -nocase {history} [lindex $args end]]} {
set arraylist [lsort -increasing [array names local_todo_history]]
} else { set arraylist [lsort -increasing [array names local_todo]] }
if {[string match *-* [lindex $args 0]]} {
set start [lindex [split [lindex $args 0] -] 0]
set end [lindex [split [lindex $args 0] -] 1]
if {$start>$end} {
putnot $nick "\002$start\002 can't be larger then \002$end\002 retard. Use a correct range."
return 0
}
if {[string equal {} [lindex $arraylist [expr $end - 1]]]} {
putnot $nick "Illegal range specified"
return 0
}
foreach stamp [lrange $arraylist [expr $start - 1] [expr $end - 1]] {
if {[string equal -nocase {history} [lindex $args end]]} {
unset local_todo_history($stamp)
} else { unset local_todo($stamp) }
}
if {[string equal -nocase {history} [lindex $args end]]} {
set todo_history($channel) [array get local_todo_history]
} else {
set todo($channel) [array get local_todo]
}
putnot $nick "Entries $start -> $end deleted"
save_todo ; save_history
return 1
}
if {[string match *,* [lindex $args 0]]} {
set unable ""
set usable ""
set list [split [lindex $args 0] ,]
foreach num $list {
if {[regexp {[^0-9]} $num]} { lappend unable $num } else { if {$num>[llength $arraylist]} { lappend unable $num } else { lappend usable $num } }
}
if {[string equal {} $usable]} {
putnot $nick "Nothing valid to delete."
putnot $nick "Invalid Entries: \002$unable\002"
return 0
}
putnot $nick "Deleting entries \002$usable\002"
foreach num $usable {
set key [lindex $arraylist [expr $num - 1]]
if {[string equal -nocase {history} [string tolower [lindex $args end]]]} {
unset local_todo_history($key)
} else {
unset local_todo($key)
}
}
if {[string equal -nocase {history} [lindex $args end]]} {
set todo_history($channel) [array get local_todo_history]
} else {
set todo($channel) [array get local_todo]
}
if {$unable!=""} {
putnot $nick "Invalid Entries: \002$unable\002"
}
save_todo ; save_history
return 1
}
set num [lindex $args 0]
if {$num>[llength $arraylist]} {
putnot $nick "Invalid Entry: \002$num\002"

}
set key [lindex $arraylist [expr $num - 1]]
if {[string equal -nocase {history} [lindex $args end]]} {
unset local_todo_history($key)
} else { unset local_todo($key) }
if {[string equal -nocase {history} [lindex $args end]]} {
set todo_history($channel) [array get local_todo_history]
} else {
set todo($channel) [array get local_todo]
}
putnot $nick "Deleted $num"
save_todo ; save_history
}
move {
if {[string equal {} $args]} {
putnot $nick "Usage: !todo move <entry number> <from_channel_list> <to_channel_list>"
putnot $nick "*NOTE* Use global as channel name to move from and to global area *NOTE*"
putnot $nick "Valid Number Formats: #-#(Number Range) , #,#,#(Set of Numbers) , #(Single Number)"
return 0
}
set from_channel [lindex $args 1]
set to_channel [lindex $args 2]
if {[string equal -nocase $from_channel $to_channel]} {
putnot $nick "Won't move to the same channel, waste of my brain power."
return 0
}
if {(![string equal {#} [string index $from_channel 0]] && ![string equal -nocase {global} $from_channel]) || (![string equal {#} [string index $to_channel 0]] && ![string equal -nocase {global} $to_channel])} {
putnot $nick "You need to specify channels, or otherwise the global area."
return 0
}
if {[string equal -nocase {global} $to_channel]} {
set to_channel "global"
} else {
if {[lsearch [string tolower [channels]] $to_channel] == -1} {
putnot $nick "Invalid channel requested!"
return 0
}
}
if {[string equal -nocase {global} $from_channel]} {
set from_channel "global"
} else {
if {[lsearch [string tolower [channels]] $from_channel] == -1} {
putnot $nick "Invalid channel requested!"
return 0
}
}
if {[info exists todo($to_channel)]} {
array set local_to_todo $todo($to_channel)
}
if {![info exists todo($from_channel)]} {
putnot $nick "No items in current todo list."
} else {
array set local_from_todo $todo($from_channel)
set from_arraylist [lsort -increasing [array names local_from_todo]]
}
if {[string match *-* [lindex $args 0]]} {
set start [lindex [split [lindex $args 0] -] 0]
set end [lindex [split [lindex $args 0] -] 1]
if {$start>$end} {
putnot $nick "\002$start\002 can't be larger then \002$end\002 retard. Use a correct range."
return 0
}
if {[string equal {} [lindex $from_arraylist [expr $end - 1]]]} {
putnot $nick "Illegal range specified"
return 0
}
foreach stamp [lrange $from_arraylist [expr $start - 1] [expr $end - 1]] {
set local_to_todo($stamp) $local_from_todo($stamp)
unset local_from_todo($stamp)
}
set todo($from_channel) [array get local_from_todo]
set todo($to_channel) [array get local_to_todo]
putnot $nick "Entries $start -> $end moved from $from_channel -> $to_channel"
save_todo ; save_history
return 1
}
if {[string match *,* [lindex $args 0]]} {
set unable ""
set usable ""
set list [split [lindex $args 0] ,]
foreach num $list {
if {[regexp {[^0-9]} $num]} { lappend unable $num } else { if {$num>[llength $from_arraylist]} { lappend unable $num } else { lappend usable $num } }
}
if {[string equal {} $usable]} {
putnot $nick "Nothing valid to move."
putnot $nick "Invalid Entries: \002$unable\002"
return 0
}
putnot $nick "Moving entries \002$usable\002"
foreach num [lsort -decreasing $usable] {
set key [lindex $from_arraylist [expr $num - 1]]
set local_to_todo($key) $local_from_todo($key)
unset local_from_todo($key)
}
set todo($from_channel) [array get local_from_todo]
set todo($to_channel) [array get local_to_todo]
if {$unable!=""} {
putnot $nick "Invalid Entries: \002$unable\002"
}
save_todo ; save_history
return 1
}
set num [lindex $args 0]
if {$num>[llength $from_arraylist]} {
putnot $nick "Invalid Entry: \002$num\002"

}
set key [lindex $from_arraylist [expr $num - 1]]
set local_to_todo($key) $local_from_todo($key)
unset local_from_todo($key)
set todo($from_channel) [array get local_from_todo]
set todo($to_channel) [array get local_to_todo]
putnot $nick "Moved $num from $from_channel -> $to_channel"
save_todo ; save_history
}
list {
if {![info exists todo($channel)]} {
putnot $nick "No items in current todo list."
return 0
}
array set local_todo $todo($channel)
set keys [array names local_todo]
if {[llength $keys]==0} {
putnot $nick "No items in current todo list."
return 0
}
set count 1
foreach key [lsort -increasing $keys] {
set curr [join $local_todo($key)]
putnot $nick "$count.) \002[lrange $curr 1 end]\002 by \002[lindex $curr 0]\002 at [clock format $key -format %m/%d/%Y-%l:%M]"
incr count
}
}
complete {
if {$args==""} {
putnot $nick "Usage: !todo \[#channel\] complete <number>"
putnot $nick "*TIP* Use !todo list to view numbers *TIP*"
putnot $nick "Valid Number Formats: #-#(Number Range) , #,#,#(Set of Numbers) , #(Single Number)"
return 0
}
if {![info exists todo($channel)]} {
putnot $nick "No items in current todo list."
}
array set local_todo $todo($channel)
if {[info exists todo_history($channel)]} { array set local_todo_history $todo_history($channel) }
set arraylist [lsort -increasing [array names local_todo]]
if {[string match *-* [lindex $args 0]]} {
set start [lindex [split [lindex $args 0] -] 0]
set end [lindex [split [lindex $args 0] -] 1]
if {$start>$end} {
putnot $nick "\002$start\002 can't be larger then \002$end\002 retard. Use a correct range."
return 0
}
if {[string equal {} [lindex $arraylist [expr $end - 1]]]} {
putnot $nick "Illegal range specified"
return 0
}
foreach stamp [lrange $arraylist [expr $start - 1] [expr $end - 1]] {
set local_todo_history($stamp) "[unixtime] $todo($stamp)"
unset local_todo($stamp)
}
set todo_history($channel) [array get local_todo_history]
set todo($channel) [array get local_todo]
putnot $nick "Entries $start -> $end completed"
save_todo ; save_history
return 1
}
if {[string match *,* [lindex $args 0]]} {
set unable ""
set usable ""
set list [split [lindex $args 0] ,]
foreach num $list {
if {[regexp {[^0-9]} $num]} { lappend unable $num } else { if {$num>[llength $arraylist]} { lappend unable $num } else { lappend usable $num } }
}
if {$usable==""} {
putnot $nick "Nothing valid to complete."
putnot $nick "Invalid Entries: \002$unable\002"
return 0
}
putnot $nick "Completing entries \002$usable\002"
foreach num $usable {
set key [lindex $arraylist [expr $num - 1]]
set local_todo_history($key) "[unixtime] $todo($key)"
unset local_todo($key)
}
if {$unable!=""} {
putnot $nick "Invalid Entries: \002$unable\002"
}
set todo_history($channel) [array get local_todo_history]
set todo($channel) [array get local_todo]
save_todo ; save_history
return 1
}
set num [lindex $args 0]
if {$num>[llength $arraylist]} {
putnot $nick "Invalid Entry: \002$num\002"

}
set key [lindex $arraylist [expr $num - 1]]
set local_todo_history($key) "[unixtime] $local_todo($key)"
unset local_todo($key)
putnot $nick "Completed $num"
set todo_history($channel) [array get local_todo_history]
set todo($channel) [array get local_todo]
save_todo
save_history
}
history {
if {[info exists todo_history($channel)]} {
array set local_todo_history $todo_history($channel)
} else {
putnot $nick "No items in current history list."
return 0
}
set keys [array names local_todo_history]
if {[llength $keys]=="0"} {
putnot $nick "No items in current history list."
return 0
}
set count 1
foreach key [lsort -increasing $keys] {
set curr $local_todo_history($key)
putnot $nick "$count.) \002[lrange $curr 2 end]\002 by \002[lindex $curr 1]\002 at [clock format $key -format %m/%d/%Y-%l:%M] Completed on: [clock format [lindex $curr 0] -format %m/%d/%Y-%l:%M]"
incr count
}
}
}
}
load_todo
load_history

putlog "Todo list tracking by eRUPT(erupt@ruptbot.com) $todo_ver"
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

type '.set errorInfo' in the partyline so we can know more about the error.
d
dvibe
Voice
Posts: 6
Joined: Tue Jun 28, 2005 8:45 pm
Contact:

Post by dvibe »

on dcc chat on bot

.set errorInfo

get

what? You need ´.help´

sorry newbie
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

In the eggdrop's conf file you have:
# Comment these two lines if you wish to enable the .tcl and .set commands.
# If you select your owners wisely, you should be okay enabling these.
#unbind dcc n tcl *dcc:tcl
#unbind dcc n set *dcc:set
where there's no # behind the unbinds, add them and rehash. And if you have must-be-owner set to 1, make sure your handle is added in the 'set owner'.
d
dvibe
Voice
Posts: 6
Joined: Tue Jun 28, 2005 8:45 pm
Contact:

Post by dvibe »

[11:27] Tcl error [pub_todo]: can't read "channel": no such variable
.set errorinfo
[11:27] #EBiV-D# set errorinfo
Error: can't read "errorinfo": no such variable
.set errorInfo
[11:27] #EBiV-D# set errorInfo
Currently: can't read "errorinfo": no such variable
Currently: while executing
Currently: "set errorinfo"
d
dvibe
Voice
Posts: 6
Joined: Tue Jun 28, 2005 8:45 pm
Contact:

Post by dvibe »

Currently: can't read "channel": no such variable
Currently: while executing
Currently: "array set temp $todo_history($channel)"
Currently: (procedure "save_history" line 6)
Currently: invoked from within
Currently: "save_history"
Currently: ("complete" arm line 73)
Currently: invoked from within
Currently: "switch $option {
Currently: add {
Currently: if {[string equal {} $args]} {
Currently: putnot $nick "Usage: !todo \[#channel\] add <message>"
Currently: return 0
Currently: }
Currently: ..."
Currently: (procedure "pub_todo" line 22)
Currently: invoked from within
Currently: "pub_todo $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try replacing

Code: Select all

proc save_history {} { 
 global todo_history 
 set wfile [open scripts/todo_history.lst w] 
 foreach entry [array names todo_history] {
  catch {unset temp} 
  array set temp $todo_history($channel) 
  foreach entry [array names temp] { 
   puts $wfile "$channel $entry $temp($entry)" 
  } 
 } 
 close $wfile 
}
with

Code: Select all

proc save_history {} { 
 global todo_history 
 set wfile [open scripts/todo_history.lst w] 
 foreach channel [array names todo_history] { 
  catch {unset temp} 
  array set temp $todo_history($channel) 
  foreach entry [array names temp] {
   puts $wfile "$channel $entry $temp($entry)" 
  } 
 } 
 close $wfile 
}

I don't know how the author haven't fixed this error since it's too obvious :?

PS: next time use

Code: Select all

 tags when posting a script.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Sir_Fz, I admire your patience reviewing messy, not formatted code :)
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

lol, this is not a constant patience though :P it depends on the mood :lol:
Post Reply