plugins.version: Report own version in first person, and don't crash if it's not in a room

Mon, 08 Nov 2010 23:19:57 +0100

author
Kim Alvefur <zash@zash.se>
date
Mon, 08 Nov 2010 23:19:57 +0100
changeset 37
85b3f2a96edb
parent 36
ccce42f781de
child 38
e1479af7ec9a

plugins.version: Report own version in first person, and don't crash if it's not in a room

plugins/version.lua file | annotate | diff | comparison | revisions
--- a/plugins/version.lua	Mon Nov 08 23:06:48 2010 +0100
+++ b/plugins/version.lua	Mon Nov 08 23:19:57 2010 +0100
@@ -10,7 +10,7 @@
 	};
 
 	bot:hook("commands/version", function (command)
-		local who, param = bot.stream.jid, command.param or (command.room and command.room.nick);
+		local who, param = bot.stream.jid, command.param;
 		if param then
 			if command.room and command.room.occupants[param] then
 				who = command.room.occupants[param].jid;
@@ -23,7 +23,7 @@
 		
 		bot.stream:query_version(who, function (reply)
 			if not reply.error then
-				local saywho = (who == command.sender.jid and "You are") or (param.." is");
+				local saywho = (who == command.sender.jid and "You are") or (param and param.." is" or "I am");
 				command:reply(saywho.." running "..(reply.name or "something")
 					.." version "..(reply.version or "unknown")
 					.." on "..(reply.platform or "an unknown platform"));

mercurial