4 bot:add_plugin("resolvejid"); |
4 bot:add_plugin("resolvejid"); |
5 bot:hook("commands/ping", function (command) |
5 bot:hook("commands/ping", function (command) |
6 local jid = command.param; |
6 local jid = command.param; |
7 if jid then |
7 if jid then |
8 jid = bot:resolvejid(jid, command.room); |
8 jid = bot:resolvejid(jid, command.room); |
|
9 end |
|
10 if jid then |
9 bot.stream:ping(jid, function (time, jid, error) |
11 bot.stream:ping(jid, function (time, jid, error) |
10 if time then |
12 if time then |
11 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); |
13 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); |
12 else |
14 else |
13 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); |
15 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); |