plugins.version: Don't include unknown version or platform in reply

Thu, 09 Jul 2015 22:52:22 +0200

author
Kim Alvefur <zash@zash.se>
date
Thu, 09 Jul 2015 22:52:22 +0200
changeset 126
99781a97f582
parent 125
2c570064f582
child 127
6c977fbf6d0b

plugins.version: Don't include unknown version or platform in reply

plugins/version.lua file | annotate | diff | comparison | revisions
--- a/plugins/version.lua	Thu Jul 09 22:48:55 2015 +0200
+++ b/plugins/version.lua	Thu Jul 09 22:52:22 2015 +0200
@@ -26,9 +26,14 @@
 		bot.stream:query_version(who, function (reply)
 			if not reply.error then
 				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"));
+				local isrunning = saywho.." running "..(reply.name or "something");
+				if reply.version then
+					isrunning = isrunning .." version "..reply.version;
+				end
+				if reply.platform then
+					isrunning = isrunning .." on "..reply.platform;
+				end
+				command:reply(isrunning);
 			else
 				local type, condition, text = reply.type, reply.condition, reply.text;
 				local r = "There was an error requesting "..param.."'s version";

mercurial