From 0e7f42fcc1f5a385f2a7c5ff8440d32f4745d525 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Fri, 31 May 2019 10:45:56 +0200 Subject: [PATCH] Moved reply strings in variable. --- feed-to-muc.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/feed-to-muc.go b/feed-to-muc.go index f4d7e50..160e34a 100644 --- a/feed-to-muc.go +++ b/feed-to-muc.go @@ -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`. 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) } @@ -305,16 +307,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) }