plugins/ping.lua

changeset 105
4234c8789cc6
parent 16
ae69cea97598
child 144
68dc84e72bef
equal deleted inserted replaced
104:8202cdfb99b4 105:4234c8789cc6
1 1
2 function riddim.plugins.ping(bot) 2 function riddim.plugins.ping(bot)
3 bot.stream:add_plugin("ping"); 3 bot.stream:add_plugin("ping");
4 bot:add_plugin("resolvejid");
4 bot:hook("commands/ping", function (command) 5 bot:hook("commands/ping", function (command)
5 local jid = command.param; 6 local jid = command.param;
6 if jid then 7 if jid then
8 jid = bot:resolvejid(jid, command.room);
7 bot.stream:ping(jid, function (time, jid, error) 9 bot.stream:ping(jid, function (time, jid, error)
8 if time then 10 if time then
9 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); 11 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time));
10 else 12 else
11 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); 13 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or ""));

mercurial