Sun, 20 May 2018 02:16:48 +0200
riddim.plugins.servercontact: Query for XEP-0157: Contact Addresses for XMPP Services
0 | 1 | |
2 | function riddim.plugins.ping(bot) | |
3 | bot.stream:add_plugin("ping"); | |
105
4234c8789cc6
plugins.{ping,version,resolvejid}: Break nickname/jid resolving into a common plugin
Kim Alvefur <zash@zash.se>
parents:
16
diff
changeset
|
4 | bot:add_plugin("resolvejid"); |
0 | 5 | bot:hook("commands/ping", function (command) |
16 | 6 | local jid = command.param; |
7 | if jid then | |
105
4234c8789cc6
plugins.{ping,version,resolvejid}: Break nickname/jid resolving into a common plugin
Kim Alvefur <zash@zash.se>
parents:
16
diff
changeset
|
8 | jid = bot:resolvejid(jid, command.room); |
16 | 9 | bot.stream:ping(jid, function (time, jid, error) |
10 | if time then | |
11 | command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); | |
12 | else | |
13 | command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); | |
14 | end | |
15 | end); | |
16 | return true; | |
17 | end | |
18 | return "pong"; | |
19 | end); | |
0 | 20 | end |