plugins/ping.lua

changeset 4
1eaa469140e9
parent 0
7d84f4403d67
child 16
ae69cea97598
equal deleted inserted replaced
3:d1a9fb6495c6 4:1eaa469140e9
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:hook("commands/ping", function (command) 4 bot:hook("commands/ping", function (command)
5 local jid = command.param; 5 local jid = command.param;
6 if jid then 6 if jid then
7 bot.stream:ping(jid, function (time) 7 bot.stream:ping(jid, function (time, jid, error)
8 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); 8 if time then
9 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time));
10 else
11 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or ""));
12 end
9 end); 13 end);
10 return true; 14 return true;
11 end 15 end
12 return "pong"; 16 return "pong";
13 end); 17 end);

mercurial