mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-13 01:36:49 +01:00
Added ping command.
This commit is contained in:
parent
0e7f42fcc1
commit
54c5bfce0b
1 changed files with 18 additions and 0 deletions
|
@ -264,6 +264,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
|
|||
|
||||
reply := ": The following commands are available:\n" +
|
||||
"\"feeds\": List feeds I'm following.\n" +
|
||||
"\"ping\": Sends back a pong.\n" +
|
||||
"\"source\": Show source code URL."
|
||||
|
||||
if v.Type == "groupchat" {
|
||||
|
@ -323,6 +324,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.
|
||||
|
|
Loading…
Reference in a new issue