Helpful messages.

change-name
Robert Jacob 5 years ago
parent 794f6d7375
commit 0e1dc803ac
  1. 38
      xmpp/xmpp.go

@ -12,9 +12,21 @@ import (
)
const (
commandOpen = "!open"
commandClose = "!closed"
openNotPossible = "Bist du auch wirklich da? Ich traue dir nicht."
commandHelp = "!help"
commandState = "!state"
commandClose = "!closed"
helpMessage = `Spacebot hat folgende Kommandos:
!help - Diese Nachricht.
!state - Ist der Space offen?
!closed - Space ist zu.
Gern geschehen.`
stateUnknown = "Ich weiß leider nicht ob der Space offen ist."
stateOpen = "Space ist OFFEN."
stateClosed = "Space ist zu."
)
func AddXMPPListener(storage *spaceapi.Storage, jid, password, target, handle string) error {
@ -56,8 +68,24 @@ func AddXMPPListener(storage *spaceapi.Storage, jid, password, target, handle st
switch v := chat.(type) {
case xmpp.Chat:
switch v.Text {
case commandOpen:
if err := sendGroupMessage(client, target, openNotPossible); err != nil {
case commandHelp:
if err := sendGroupMessage(client, target, helpMessage); err != nil {
log.Printf("Error sending message: %s", err)
}
case commandState:
state := storage.Status().State
msg := stateUnknown
if state.Open != nil {
switch *state.Open {
case true:
msg = stateOpen
case false:
msg = stateClosed
}
}
if err := sendGroupMessage(client, target, msg); err != nil {
log.Printf("Error sending message: %s", err)
}
case commandClose:

Loading…
Cancel
Save