plugins/ping.lua

changeset 16
ae69cea97598
parent 4
1eaa469140e9
child 105
4234c8789cc6
equal deleted inserted replaced
15:22e6c003a83a 16:ae69cea97598
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: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, jid, error) 7 bot.stream:ping(jid, function (time, jid, error)
8 if time then 8 if time then
9 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); 9 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time));
10 else 10 else
11 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); 11 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or ""));
12 end 12 end
13 end); 13 end);
14 return true; 14 return true;
15 end 15 end
16 return "pong"; 16 return "pong";
17 end); 17 end);
18 end 18 end

mercurial