egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TODO.TCL get some Error

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
dvibe
Voice


Joined: 28 Jun 2005
Posts: 6

PostPosted: Thu Jun 30, 2005 6:21 am    Post subject: TODO.TCL get some Error Reply with quote

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"
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Jun 30, 2005 6:26 am    Post subject: Reply with quote

type '.set errorInfo' in the partyline so we can know more about the error.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
dvibe
Voice


Joined: 28 Jun 2005
Posts: 6

PostPosted: Thu Jun 30, 2005 6:58 am    Post subject: Reply with quote

on dcc chat on bot

.set errorInfo

get

what? You need “.help“

sorry newbie
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Jun 30, 2005 7:18 am    Post subject: Reply with quote

In the eggdrop's conf file you have:
Quote:
# 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'.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
dvibe
Voice


Joined: 28 Jun 2005
Posts: 6

PostPosted: Thu Jun 30, 2005 7:23 am    Post subject: Reply with quote

[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"
Back to top
View user's profile Send private message Visit poster's website
dvibe
Voice


Joined: 28 Jun 2005
Posts: 6

PostPosted: Thu Jun 30, 2005 7:26 am    Post subject: Reply with quote

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"
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Jun 30, 2005 12:02 pm    Post subject: Reply with quote

Try replacing
Code:
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:
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 Confused

PS: next time use [code] tags when posting a script.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Jul 01, 2005 9:25 pm    Post subject: Reply with quote

Sir_Fz, I admire your patience reviewing messy, not formatted code Smile
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jul 02, 2005 8:54 am    Post subject: Reply with quote

lol, this is not a constant patience though Razz it depends on the mood Laughing
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber