[Tkabber-dev] r261 - trunk/plugins/reminder

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Dec 30 01:01:03 MSK 2009


Author: bigote
Date: 2009-12-30 01:01:03 +0300 (Wed, 30 Dec 2009)
New Revision: 261

Modified:
   trunk/plugins/reminder/reminder.tcl
Log:
A command /delrem <num> added that deletes a specified reminder.


Modified: trunk/plugins/reminder/reminder.tcl
===================================================================
--- trunk/plugins/reminder/reminder.tcl	2009-12-29 02:01:40 UTC (rev 260)
+++ trunk/plugins/reminder/reminder.tcl	2009-12-29 22:01:03 UTC (rev 261)
@@ -1,4 +1,4 @@
-# "Reminder" plugin for Tkabber. 2009-12-29 v. 0.5
+# "Reminder" plugin for Tkabber. 2009-12-29 v. 0.6
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # Its purpose is to remind about your contact birthdays automatically
 # and about some tasks that you assign by means of "/remind" command.
@@ -8,7 +8,6 @@
 # either take a look at reminder::help procedure here.
 #####################################
 #
-# TODO: Add a possibility to delete some reminders.
 # TODO: Think about saving and restoring long term reminders.
 # TODO: Add some sound reminder notification.
 # TODO: Birthday reminding isn't ready yet, at all.
@@ -66,7 +65,7 @@
     upvar 0 $compsvar comps
 
     if {!$wordstart} {
-        lappend comps {/remind } {/listrems }
+        lappend comps {/remind } {/listrems } {/delrem }
     }
 }
 
@@ -77,12 +76,16 @@
         set cmd /remind
     } elseif {[string match {/listrems*} $body]} {
         set cmd /listrems
+    } elseif {[string match {/delrem*} $body]} {
+        set cmd /delrem
     } else return
 
     if {[string equal [string range $body 0 7] "/remind "]} {
         lassign [muc::parse_nick_reason $body 8] timeout message
     } elseif {[string equal [string range $body 0 8] "/listrems"]} {
         [namespace current]::list_reminders $chatid
+    } elseif {[string equal [string range $body 0 7] "/delrem "]} {
+        set num [muc::parse_nick $body 8]
     } else {
         return stop
     }
@@ -117,6 +120,23 @@
             lappend rem_list $listrem_item
             [namespace current]::list_reminders $chatid
         }
+        /delrem {
+            if {[info exists rem_list] && [llength $rem_list] > 0} {
+                if {$num > 0 && $num <= [llength $rem_list]} {
+                    set rem [lindex $rem_list [expr $num - 1]]
+                } else {
+                    set group [chat::get_jid $chatid]
+                    chat::add_message $chatid $group error "Wrong reminder index.\
+                    It should be between 1 and [llength $rem_list]." {}
+                    return stop
+                }
+                after cancel [lindex $rem 0]
+                set rem_list [lreplace $rem_list $num-1 $num-1]
+                [namespace current]::list_reminders $chatid
+            } else {
+                return stop
+            }
+        }
     }
     return stop
 }
@@ -254,7 +274,9 @@
         \n\tPlease note the date must be in the format MM/DD/YYYY HH:MM:SS\
         \n\tOtherwise, there could be errors or wrong timing calculation.\
         \n\n/listrems\
-        \n\tThis will show you a list of all running reminders you have set."
+        \n\tThis will show you a list of all running reminders you have set.\
+        \n\n/delrem 1\
+        \n\tThis will delete reminder number one (from a list obtained by /listrems)."
     chat::add_message $chatid $group error "Some examples of using /remind command:" {}
     chat::add_message $chatid $group info "[join $help_msg]" {}
     return stop



More information about the Tkabber-dev mailing list