mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-22 14:08:39 +01:00
Added ping command.
This commit is contained in:
parent
c65088b455
commit
0e5d19bf5b
1 changed files with 18 additions and 0 deletions
|
@ -265,6 +265,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
|
||||||
|
|
||||||
reply := ": The following commands are available:\n" +
|
reply := ": The following commands are available:\n" +
|
||||||
"\"feeds\": List feeds I'm following.\n" +
|
"\"feeds\": List feeds I'm following.\n" +
|
||||||
|
"\"ping\": Sends back a pong.\n" +
|
||||||
"\"source\": Show source code URL."
|
"\"source\": Show source code URL."
|
||||||
|
|
||||||
if v.Type == "groupchat" {
|
if v.Type == "groupchat" {
|
||||||
|
@ -324,6 +325,23 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "ping":
|
||||||
|
|
||||||
|
reply := "pong"
|
||||||
|
|
||||||
|
if v.Type == "groupchat" {
|
||||||
|
_, 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)
|
||||||
|
}
|
||||||
|
} else if v.Type == "chat" {
|
||||||
|
_, err = client.Send(xmpp.Chat{Remote: v.Remote,
|
||||||
|
Type: "chat", Text: reply})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error: Failed sending message to ", v.Remote, ": ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply to pings and disco queries.
|
// Reply to pings and disco queries.
|
||||||
|
|
Loading…
Reference in a new issue