mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-23 06:28:39 +01:00
Added kuketzbot autoreply for MUC mentions.
This commit is contained in:
parent
69a5eeb7b6
commit
031c87f665
1 changed files with 13 additions and 4 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue