command regex and who
[svn42.git] / r3-netstatus / main.go
index 81411f0..7016404 100644 (file)
@@ -42,18 +42,18 @@ func IfThenElseStr(c bool, strue, sfalse string) string {
 }
 
 func composeMessage(present, locked, shut bool, who string, ts int64) string {
-    return fmt.Sprintf("%s (Door is %s and %s and was last used by %s at %s)",
+    return fmt.Sprintf("%s (Door is %s and %s and was last used%s at %s)",
         IfThenElseStr(present,  "Somebody is present!" , "Everybody left."),
         IfThenElseStr(locked, "locked","unlocked"),
         IfThenElseStr(shut, "shut","ajar"),
-        who,
+        IfThenElseStr(who == "","", " by" + who),
         time.Unix(ts,0).String())
 }
 
 func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface{}) {
     events := ps.Sub("presence","door","buttons")
     var present, locked, shut bool = false, true, true
-    var who string = "Unknown"
+    var who string
     button_msg := "The button has been pressed ! Propably someone is bored and in need of company ! ;-)"
 
     for eventinterface := range(events) {