From 031c87f665f87ac97f7791a34bd7a250ad5c69a8 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Thu, 26 Mar 2020 09:17:09 +0100 Subject: [PATCH] Added kuketzbot autoreply for MUC mentions. --- feed-to-muc.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/feed-to-muc.go b/feed-to-muc.go index 347273f..f3b696c 100644 --- a/feed-to-muc.go +++ b/feed-to-muc.go @@ -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. if v.Type == "groupchat" { + // Leave if option quiet is set. - if quiet { - break - } + //if quiet { + // break + //} // Get first word of the message and transform it to lower case. 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 // 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 // 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" { command = strings.ToLower(strings.Split(v.Text, " ")[0]) } else {