+func IfThenElseStr(c bool, strue, sfalse string) string {
+ if c {return strue} else {return sfalse}
+}
+
+func composeMessage(present, locked, shut bool, who string, ts int64) string {
+ 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"),
+ IfThenElseStr(len(who) == 0,"", " by " + who),
+ time.Unix(ts,0).String())
+}
+