Moved reply strings in variable.

This commit is contained in:
Martin Dosch 2019-05-31 10:45:56 +02:00
parent 377d469179
commit c65088b455

View file

@ -262,38 +262,40 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
// Reply with a short summary of available commands for `help`.
case "help":
reply := ": The following commands are available:\n" +
"\"feeds\": List feeds I'm following.\n" +
"\"source\": Show source code URL."
if v.Type == "groupchat" {
_, err = client.Send(xmpp.Chat{Remote: muc,
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] +
": The following commands are available:\n" +
"\"feeds\": List feeds I'm following.\n" +
"\"source\": Show source code URL."})
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply})
if err != nil {
log.Fatal("Error: Failed sending message to MUC:", err)
}
} else if v.Type == "chat" {
_, err = client.Send(xmpp.Chat{Remote: v.Remote,
Type: "chat", Text: "The following commands are available:\n" +
"\"feeds\": List feeds I'm following.\n" +
"\"source\": Show source code URL."})
Type: "chat", Text: reply})
if err != nil {
log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err)
}
}
// Reply with repo address for `source`.
case "source":
reply := "My source can be found at " +
"https://salsa.debian.org/mdosch-guest/feed-to-muc"
if v.Type == "groupchat" {
_, err = client.Send(xmpp.Chat{Remote: muc,
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] +
": My source can be found at " +
"https://salsa.debian.org/mdosch-guest/feed-to-muc"})
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply})
if err != nil {
log.Fatal("Error: Failed sending message to MUC:", err)
}
} else if v.Type == "chat" {
_, err = client.Send(xmpp.Chat{Remote: v.Remote,
Type: "chat", Text: "My source can be found at " +
"https://salsa.debian.org/mdosch-guest/feed-to-muc"})
Type: "chat", Text: reply})
if err != nil {
log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err)
}
@ -306,16 +308,17 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
feedList = feedList + feed + "\n"
}
reply := "Feeds I'm following:\n" + feedList
if v.Type == "groupchat" {
_, err = client.Send(xmpp.Chat{Remote: muc,
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] +
": Feeds I'm following:\n" + feedList})
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] + ": " + reply})
if err != nil {
log.Fatal("Error: Failed sending message to MUC:", err)
}
} else if v.Type == "chat" {
_, err = client.Send(xmpp.Chat{Remote: v.Remote,
Type: "chat", Text: "Feeds I'm following:\n" + feedList})
Type: "chat", Text: reply})
if err != nil {
log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err)
}