Moved reply strings in variable.

This commit is contained in:
Martin Dosch 2019-05-31 10:45:56 +02:00 committed by Martin Dosch
parent 0d5b08147d
commit 0e7f42fcc1

View file

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