Added kuketzbot autoreply for MUC mentions.

This commit is contained in:
Martin Dosch 2020-03-26 09:17:09 +01:00
parent 69a5eeb7b6
commit 031c87f665

View file

@ -231,10 +231,11 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
// Check for room mention of the bots nick if the the message type is groupchat. // Check for room mention of the bots nick if the the message type is groupchat.
if v.Type == "groupchat" { if v.Type == "groupchat" {
// Leave if option quiet is set. // Leave if option quiet is set.
if quiet { //if quiet {
break // break
} //}
// Get first word of the message and transform it to lower case. // Get first word of the message and transform it to lower case.
mention := strings.ToLower(strings.Split(v.Text, " ")[0]) mention := strings.ToLower(strings.Split(v.Text, " ")[0])
@ -254,9 +255,17 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
} }
// As the first word is the mention of the bots nickname, the command is // As the first word is the mention of the bots nickname, the command is
// the second word in a groupchat message. // the second word in a groupchat message.
command = strings.ToLower(strings.Split(v.Text, " ")[1]) // command = strings.ToLower(strings.Split(v.Text, " ")[1])
// If the message type is chat (e.g. private message), the command is the // If the message type is chat (e.g. private message), the command is the
// first word. // first word.
reply := "Bitte nicht mit dem Bot sprechen.\nhttps://www.kuketz-blog.de/chat/#bots"
_, err = client.Send(xmpp.Chat{Remote: muc,
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply})
if err != nil {
log.Fatal("Error: Failed sending message to MUC:", err)
}
break
} else if v.Type == "chat" { } else if v.Type == "chat" {
command = strings.ToLower(strings.Split(v.Text, " ")[0]) command = strings.ToLower(strings.Split(v.Text, " ")[0])
} else { } else {