-func EventToXMPP(bot *r3xmppbot.XmppBot, events <- chan interface{}, xmpp_presence_events_chan chan <- interface{}) {
+func composePresence(present bool, temp_cx float64, light_lothr, last_buttonpress int64) r3xmppbot.XMPPStatusEvent {
+ present_msg := "Somebody is present"
+ notpresent_msg := "Nobody is here"
+ button_msg := "The button has been pressed :-)"
+ msg := "%s (CX: %.2f°C, LoTHR light: %d)"
+
+ if present {
+ if last_buttonpress > 0 && time.Now().Unix() - last_buttonpress < button_press_timeout_ {
+ return r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowFreeForChat, fmt.Sprintf(msg, button_msg, temp_cx, light_lothr)}
+ } else {
+ return r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowOnline, fmt.Sprintf(msg, present_msg, temp_cx, light_lothr)}
+ }
+ } else {
+ return r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowNotAvailabe, fmt.Sprintf(msg, notpresent_msg, temp_cx, light_lothr)}
+ }
+}