Created
February 4, 2011 14:23
-
-
Save sesam/811160 to your computer and use it in GitHub Desktop.
make !ping more explanative for noobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 766f4225110b plugins/ping.lua | |
--- a/plugins/ping.lua Tue Jan 11 23:35:42 2011 +0100 | |
+++ b/plugins/ping.lua Fri Feb 04 15:21:45 2011 +0100 | |
@@ -5,8 +5,10 @@ | |
local jid = command.param; | |
if jid then | |
bot.stream:ping(jid, function (time, jid, error) | |
+ local kind = "server"; | |
+ if string.find(jid, "@") then kind = "client"; | |
if time then | |
- command:reply(string.format("Pong from %s in %0.3f seconds", jid, time)); | |
+ command:reply(string.format("Pong from XMPP %s %s in %0.3f seconds", kind, jid, time)); | |
else | |
command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function riddim.plugins.ping(bot) | |
bot.stream:add_plugin("ping"); | |
bot:hook("commands/ping", function (command) | |
local jid = command.param; | |
if jid then | |
bot.stream:ping(jid, function (time, jid, error) | |
local kind = "server"; | |
if string.find(jid, "@") then kind = "client"; | |
if time then | |
command:reply(string.format("Pong from XMPP %s %s in %0.3f seconds", kind, jid, time)); | |
else | |
command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or "")); | |
end | |
end); | |
return true; | |
end | |
return "pong"; | |
end); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment