plugins/ping.lua

Wed, 24 Aug 2011 12:58:39 +0200

author
Kim Alvefur <zash@zash.se>
date
Wed, 24 Aug 2011 12:58:39 +0200
changeset 88
b7f628541981
parent 16
ae69cea97598
child 105
4234c8789cc6
permissions
-rw-r--r--

plugins.pubsub2room: Fix to use pubsub on stream instead of bot


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)
				if time then
					command:reply(string.format("Pong from %s in %0.3f seconds", 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

mercurial