############################################################# # # TODO.TCL v1.2 by stumper @ irc.MindForge.org # set todo_version "1.2" # ############################################################# ############################################################# # # Description : # This script allows to build a ToDo list # # Usage : # !todo # !addtodo # !remtodo # # Changelog : # v1.0 - stumper # Script creation # v1.1 - ToM # Added this header and comments # Added a channel selection configuration # Added a db file path configuration # # To Do : # # # ############################################################# ############################################################# # # Configuration # # List of channels where this script is active ( salons ou todo.tcl pourras etre utlisé ) # Separate channels by spaces set todochans { #windrops #tonchan1 #tonchan2 } # The file where todos are saved in ( endroit où seras ton fichier todo ) set todofile "scripts/data/todo.txt" # # End of configuration # DO NOT EDIT BELOW UNTIL YOU KNOW WHAT YOU ARE DOING # ############################################################# # Create a bind for each active channel foreach todochan $todochans { bind pubm - "$todochan !addtodo" laddtodo bind pubm - "$todochan !remtodo*" lremtodo bind pubm - "$todochan !todo*" listtodo } ############################################## ####TRIGGER TO ADD A TODO IN THE TODO LIST#### ############################################## proc laddtodo { nick uhost handle chan arg } { global todofile if { [isvoice $nick $chan] } { if { [file exists $todofile] } { set readtodo [open $todofile r] while { ![eof $readtodo] } { gets $readtodo todlist if { $todlist!="" } { lappend linestodo [lrange $todlist 1 end] } } lappend linestodo "[date] $nick: [lrange $arg 1 end]" for { set write 0 } { $write<[llength $linestodo] } { incr write } { if { $write==0 } { set first [open $todofile w] puts $first "[expr $write+1] [lindex $linestodo $write]" close $first } else { set next [open $todofile a] puts $next "[expr $write+1] [lindex $linestodo $write]" close $next } } putserv "PRIVMSG $chan : pense bête ajouté" } else { set writefirst [open $todofile w] puts $writefirst "1 [date] $nick: [lrange $arg 1 end]" close $writefirst } } } ################################################# ####TRIGGER TO REMOVE A TODO IN THE TODO LIST#### ################################################# proc lremtodo { nick uhost handle chan arg } { global todofile if { [isvoice $nick $chan] } { if { [file exists $todofile] } { set readtodo [open $todofile r] while { ![eof $readtodo] } { gets $readtodo todlist if { $todlist!="" } { lappend linestodo [lrange $todlist 1 end] } } if { [isnumber [lindex $arg 1]] } { if { ([lindex $arg 1]>0 && [lindex $arg 1]<=[llength $linestodo]) } { set linestorem [expr [lindex $arg 1]-1] set linestodo [lreplace $linestodo $linestorem $linestorem] for { set write 0 } { $write<[llength $linestodo] } { incr write } { if { $write==0 } { set first [open $todofile w] puts $first "[expr $write+1] [lindex $linestodo $write]" close $first } else { set next [open $todofile a] puts $next "[expr $write+1] [lindex $linestodo $write]" close $next } } putserv "PRIVMSG $chan : pense bête effacé lol" } else { putserv "PRIMSG $chan : There is not such todo number" } } elseif {[lindex $arg 1]=="all" } { file del $todofile putserv "PRIVMSG $chan : Effacé avec succés" } else { putserv "PRIVMSG $chan : This is not a valid request. I Cannot remove any line" } } else { putserv "PRIVMSG $chan : There is not any todo list to remove anything from" } } else { putserv "PRIVMSG $chan $nick : essaye en te reop , je ne te reconnais pas en tant que @ sur $chan" } } ################################################ ####TRIGGER TO SEE THE LIST OF THE TODO LIST#### ################################################ proc listtodo { nick uhost handle chan arg } { global todofile if { [isvoice $nick $chan] } { if { [file exists $todofile] } { set readtodo [open $todofile r] while { ![eof $readtodo] } { gets $readtodo todlist if { $todlist!="" } { lappend linestodo [lrange $todlist 1 end] } } putserv "PRIVMSG $chan : -- Les choses à se souvenir à la [date] sont :--" for { set b 0 } { $b<[llength $linestodo] } { incr b } { putserv "PRIVMSG $chan : [expr $b+1]-[lindex $linestodo $b]" } putserv "PRIVMSG $chan : -- Fin de la liste --" } else { putserv "PRIVMSG $chan : -!-!- il n'y a rien dans la liste -!-!-" } } } #putlog "todo.tcl by stumper v$todo_version successfully loaded" putlog "todo.tcl by stumper ( ircop sur mindforge) francisé par cestlemien chargé ( les commandes sont !addtodo , !remtodo , !todo"