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-list

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
maniak
Voice


Joined: 24 Jul 2015
Posts: 3

PostPosted: Fri Jul 24, 2015 4:34 pm    Post subject: Todo-list Reply with quote

Hello people,

I have been looking for a simple todo-list script. But havent found anything.

Im thinking commands should be something like this:

!todo add
!todo del
!todo

!todo add Upgrade server to 1.1 (adds this to the todo-list)
!todo del Upgrade server to 1.1 (removes this from the todo-list)
!todo (announces all things added to the todo-list with what date its added)

Examples:

!todo add Updgrade server to 1.1
<Botnick> Upgrade server to 1.1 added to list

!todo del Upgrade server to 1.1
<Botnick> Upgrade server to 1.1 removed from list

!todo
<Botnick> --- Things to do ---
<Botnick> [2015-05-22] Upgrade server to 1.1
<Botnick> [2015-06-10] Fix auto-op
<Botnick> [2015-07-24] Fix new cool script
--- End of List ---

Something like that. Is there any script you know about that works similar to this? Or is this maybe something you could create?

Please tell me if anything is unclear or if you have any good ideas for this.

Thanks in advance!
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 632
Location: Tennessee, USA

PostPosted: Sun Jul 26, 2015 2:21 pm    Post subject: Reply with quote

Untested modification of my script at: http://forum.egghelp.org/viewtopic.php?t=19179

Please test and see what we have so far:)

Code:

# EditTextFile (ToDo-List ver) Version 0.4 #

# author:  SpiKe^^ #
# e-mail:  spike<at>mytclscripts<dot>com #
# webpage: http://mytclscripts.com/ #

# This file is Copyrighted under the GNU Public License. #
# http://www.gnu.org/copyleft/gpl.html #

########### General Script Settings ###########

# Set the channel(s) for this script to run in #
set eTxFile(chan) {#yourchannel #anotherchannel #someotherchan}

# Set the full route & file name of the ToDo-List file #
set eTxFile(file) {/usr/home/spike/eggdrop/scripts/filename.txt}

# Set the access flags to use the ToDo-List public commands #
set eTxFile(flags) {o|o}

########### Public Command Trigger ###########

# Set the public trigger for all the ToDo-List commands #
#    note: All ToDo-List commands start with this one word!
set eTxFile(cmd) {!todo}

########### Public Command Options ###########

# Set the command option for the add line command #
# to add a line at the end of the file:
#    example:  !todo add The text to add at file end.
#    example:  !todo add end The text to add at file end.
# to add a line at a specific line position in the file:
#    example:  !todo add 4 The text to add at file line 4.
#    note: this will renumber the original line 4 & all lines after it!
set eTxFile(add) {add}

# Set the command option for the delete line command #
# to delete a specific line (by line number) from the text file
#    example:  !todo del 4
#    note: this will renumber all lines after line 4!
set eTxFile(del) {del}


# Set the command option for the list file command #
# to list all lines from the text file
#    example:  !todo list
# note: list is also the default if no command option is given!
#    example:  !todo
set eTxFile(list) {list}

########### Extended Command Options ###########

# Set the command option for the read line command #
# to read a specific line (by line number) from the text file
#    example:  !todo read 4
#    note: use to check for correct line before doing !todo del or edit
set eTxFile(read) {read}

# Set the command option for the edit line command #
# to edit a specific line (by line number) in the text file
#    example:  !todo edit 4 New text to replace file line 4.
set eTxFile(edit) {edit}

# Set the command option to get help with this script #
# to see all valid ToDo-List command options
#    example:  !todo help
set eTxFile(help) {help}


################ End Settings ################


bind pub $eTxFile(flags) $eTxFile(cmd) etfProcCmd

set eTxFile(chan) [split $eTxFile(chan)]

proc etfProcCmd {nk uh hn ch tx} {
  global eTxFile
  if {[lsearch -nocase $eTxFile(chan) $ch]=="-1"} {  return 0  }

  set tx [split [string trim $tx]]
  set opt [lindex $tx 0]
  set tx [string trim [join [lrange $tx 1 end]]]

  if {$opt eq $eTxFile(add)} {
    etfProcAdd $nk $ch $tx
  } elseif {$opt eq $eTxFile(del)} {
    etfProcEdit $nk $ch $tx del
  } elseif {$opt eq "" || $opt eq $eTxFile(list)} {
    etfProcRead $nk $ch $tx file
  } elseif {$opt eq $eTxFile(read)} {
    etfProcRead $nk $ch $tx
  } elseif {$opt eq $eTxFile(edit)} {
    etfProcEdit $nk $ch $tx

  } else {
    if {$opt eq $eTxFile(help)} {
      puthelp "PRIVMSG $ch :--- ToDo-List script help ---"
    } else {
      puthelp "PRIVMSG $ch :Invalid ToDo-List command option: $opt"
    }

    puthelp "PRIVMSG $ch :Valid options for $eTxFile(cmd): \
             $eTxFile(add), $eTxFile(del), $eTxFile(list),\
             $eTxFile(read), $eTxFile(edit), $eTxFile(help)"

    puthelp "PRIVMSG $ch :To get help for an option, use it without arguments."
    puthelp "PRIVMSG $ch :Example: $eTxFile(cmd) $eTxFile(add)"
    puthelp "PRIVMSG $ch :Example: $eTxFile(cmd) $eTxFile(del)"
  }

  return 0

}

proc etfProcAdd {nk ch tx} {

  set tx [split $tx]

  if {[lindex $tx 0] eq "end" || [string is digit -strict [lindex $tx 0]]} {
    set addat [lindex $tx 0] ; set tx [string trim [join [lrange $tx 1 end]]]
  } else {  set addat end  ;  set tx [join $tx]  }

  if {$tx eq ""} {  set add "$::eTxFile(cmd) $::eTxFile(add)"
    puthelp "PRIVMSG $ch :Correct syntax is: $add \[position\] <text to add>"
    puthelp "PRIVMSG $ch :Example: $add Text to add at end of the list."
    puthelp "PRIVMSG $ch :Example: $add end Text to add at end of the list."
    puthelp "PRIVMSG $ch :Example: $add 4 Text to add at list line 4."
    return
  }

  set tf $::eTxFile(file)
  if {![file exists $tf]} {  set addat end  ;  set nofile 1  }
  if {$addat ne "end"} {  set tx "$addat $tx"
    etfProcEdit $nk $ch $tx add  ;  return
  }
  set id [open $tf a]  ;  puts $id $tx  ;  close $id
  if {![file exists $tf]} {
    puthelp "PRIVMSG $ch :Unable to find or make ToDo text file: $tf"
  } elseif {[info exists nofile]} {
    puthelp "PRIVMSG $ch :Added line to new ToDo-List: $tx"
  } else {
    puthelp "PRIVMSG $ch :Added line at end of ToDo-List: $tx"
  }
  return
}


proc etfProcRead {nk ch tx {do line} } {

  set tf $::eTxFile(file)
  if {![file exists $tf]} {
    puthelp "PRIVMSG $ch :ToDo-List is currently empty."  ;  return
  }

  if {$do eq "line" && ![string is digit -strict $tx]} {
    set read "$::eTxFile(cmd) $::eTxFile(read)"
    puthelp "PRIVMSG $ch :Correct syntax is: $read <line#>"
    puthelp "PRIVMSG $ch :Example: $read 4"
    return
  }

  set tid [open $tf]  ;  set lnum 0
  while {![eof $tid]} {  set line [gets $tid]
    if {$line ne ""} {  incr lnum
      if {$do eq "file"} {  puthelp "PRIVMSG $ch :\[$lnum\]  $line"
      } elseif {$lnum==$tx} {
        puthelp "PRIVMSG $ch :\[$lnum\]  $line"  ;  break
      }
    }
  }
  close $tid
  if {$lnum=="0"} {
    puthelp "PRIVMSG $ch :ToDo-List is currently empty." ;  return
  }
  if {$do eq "line" && $tx>$lnum} {  set tl line
    if {$lnum>"1"} {  set tl lines  }
    puthelp "PRIVMSG $ch :List line $tx doesn't exist ($lnum $tl in the list)"
  }
  return
}


proc etfProcEdit {nk ch tx {do edit} } {

  set tf $::eTxFile(file)
  if {![file exists $tf]} {
    puthelp "PRIVMSG $ch :ToDo-List is currently empty."  ;  return
  }

  set tx [split $tx]
  if {$do eq "edit"} {
    if {[llength $tx]<"2" || ![string is digit -strict [lindex $tx 0]]} {
      set edit "$::eTxFile(cmd) $::eTxFile(edit)"
      puthelp "PRIVMSG $ch :Correct syntax is: $edit <line#> <new edited text>"
      puthelp "PRIVMSG $ch :Example: $edit 4 New text to replace list line 4."
      return
    }
  } elseif {$do eq "del" && ![string is digit -strict [lindex $tx 0]]} {
    set del "$::eTxFile(cmd) $::eTxFile(del)"
    puthelp "PRIVMSG $ch :Correct syntax is: $del <line#>"
    puthelp "PRIVMSG $ch :Example: $del 4"  ;  return
  }

  set find [lindex $tx 0]  ;  set tx [string trim [join [lrange $tx 1 end]]]
  set new [file dirname $tf]/newfile.tmp  ;  set nid [open $new w]
  set tid [open $tf]  ;  set lnum 0
  while {![eof $tid]} {  set line [gets $tid]
    if {$line ne ""} {  incr lnum
      if {$lnum==$find} {
        if {$do eq "edit"} {
          puthelp "PRIVMSG $ch :Replaced line $lnum text: $line"
          puthelp "PRIVMSG $ch :with the new text line: $tx"
          puts $nid $tx
        } elseif {$do eq "del"} {
          puthelp "PRIVMSG $ch :Deleted line $lnum text: $line"
        } elseif {$do eq "add"} {
          puthelp "PRIVMSG $ch :Added new line $lnum text: $tx"
          puts $nid $tx  ;  puts $nid $line
        }
      } else {  puts $nid $line  }
    }
  }
  close $tid
  if {$find>$lnum} {
    if {$do eq "add"} {  incr lnum
      puthelp "PRIVMSG $ch :Added new line $lnum text: $tx"
      puts $nid $tx  ;  close $nid  ;  file rename -force $new $tf
    } else {
      if {$lnum>"0"} {  set tl line
        if {$lnum>"1"} {  set tl lines  }
        puthelp "PRIVMSG $ch :List line $find doesn't exist ($lnum $tl in the list)"
      } else {  puthelp "PRIVMSG $ch :ToDo-List is currently empty."  }
      close $nid  ;  file delete $new
    }
  } else {  close $nid  ;  file rename -force $new $tf  }
  return
}

putlog "EditTextFile (ToDo-List ver) Ver. 0.4 by SpiKe^^ loaded."


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
maniak
Voice


Joined: 24 Jul 2015
Posts: 3

PostPosted: Sun Jul 26, 2015 6:41 pm    Post subject: Reply with quote

Alright, thanks! Ill check it out!
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 33

PostPosted: Mon Apr 13, 2020 7:19 pm    Post subject: Reply with quote

This is a fantastic script...

One question... it indicates o as the access flag - but on testing, looks like just the owner can activate the todo commands. None of the other Ops can.

How do I change that so all Ops can activate the list?
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3645
Location: Mint Factory

PostPosted: Tue Apr 14, 2020 12:57 am    Post subject: Reply with quote

You mean channel operators that may not have access to your bot?
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 33

PostPosted: Tue Apr 14, 2020 8:57 am    Post subject: Reply with quote

Yes - in terms of IRC chan Ops, of which there are several different types, depending on the network.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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