SVN: toys/stbr/stbr.tcl

shadzik shadzik at pld-linux.org
Sun Feb 7 02:29:46 CET 2010


Author: shadzik
Date: Sun Feb  7 02:29:46 2010
New Revision: 11130

Modified:
   toys/stbr/stbr.tcl
Log:
- add pub:setmaintenance procedure to ease my pain when setting bot in maintenance mode


Modified: toys/stbr/stbr.tcl
==============================================================================
--- toys/stbr/stbr.tcl	(original)
+++ toys/stbr/stbr.tcl	Sun Feb  7 02:29:46 2010
@@ -239,6 +239,7 @@
 bind pub * stbr, pub:stbr
 bind pub * !del pub:del
 bind pub * !stat pub:stat
+bind pub * !maintenance pub:setmaintenance
 
 proc pub:del {nick host hand chan arg} {
 global logfile cancellation unfilled
@@ -262,6 +263,26 @@
 	}
 }
 
+proc pub:setmaintenance {nick host hand chan arg} {
+	global maintenance
+	if {([matchattr $hand S])} {
+		set usage "Usage: !maintenance on|off \[comment\]"
+		set przelacznik [lindex $arg 0]
+		set comment [lrange $arg 1 end]
+		if {([string match on $przelacznik])} {
+			set fp [open $maintenance "w"]
+			puts -nonewline $fp $comment
+			close $fp
+			putserv "privmsg $chan :$nick: Maintenance Mode is On (reason: $comment)"
+		} elseif {([string match off $przelacznik])} {
+			file delete $maintenance
+			putserv "privmsg $chan :$nick: Maintenance Mode is Off"
+		} else {
+			putserv "privmsg $chan :$nick: $usage"
+		}	
+	}
+}
+
 proc pub:stbr {nick host hand chan arg} {
 global script back cntr logfile usage makereq cmdbook cmdtxt maintenance unfilled
 if {([file exists $maintenance]) && (![matchattr $hand S])} {


More information about the pld-cvs-commit mailing list