plugins/version.lua

changeset 16
ae69cea97598
parent 7
59129c1e4e07
child 33
37caf7bd2021
equal deleted inserted replaced
15:22e6c003a83a 16:ae69cea97598
20 else 20 else
21 who = param; 21 who = param;
22 end 22 end
23 end 23 end
24 24
25 bot.stream:query_version(who, 25 bot.stream:query_version(who, function (reply)
26 function (reply) 26 if not reply.error then
27 if not reply.error then 27 local saywho = (who == command.sender.jid and "You are") or (param.." is");
28 local saywho = (who == command.sender.jid and "You are") or (param.." is"); 28 command:reply(saywho.." running "..(reply.name or "something")
29 command:reply(saywho.." running "..(reply.name or "something") 29 .." version "..(reply.version or "unknown")
30 .." version "..(reply.version or "unknown") 30 .." on "..(reply.platform or "an unknown platform"));
31 .." on "..(reply.platform or "an unknown platform")); 31 else
32 else 32 local type, condition, text = reply.type, reply.condition, reply.text;
33 local type, condition, text = reply.type, reply.condition, reply.text; 33 local r = "There was an error requesting "..param.."'s version";
34 local r = "There was an error requesting "..param.."'s version"; 34 if condition == "service-unavailable" then
35 if condition == "service-unavailable" then 35 r = param.." doesn't reply to version requests";
36 r = param.." doesn't reply to version requests"; 36 elseif condition == "feature-not-implemented" then
37 elseif condition == "feature-not-implemented" then 37 r = param.." doesn't support feature requests";
38 r = param.." doesn't support feature requests"; 38 elseif condition == "remote-server-not-found" then
39 elseif condition == "remote-server-not-found" then 39 r = param.." can't be reached via XMPP";
40 r = param.." can't be reached via XMPP"; 40 elseif condition and not text then
41 elseif condition and not text then 41 r = r..": "..condition;
42 r = r..": "..condition;
43 end
44 if text then
45 r = r .. " ("..text..")";
46 end
47 command:reply(r);
48 end 42 end
49 end); 43 if text then
44 r = r .. " ("..text..")";
45 end
46 command:reply(r);
47 end
48 end);
50 return true; 49 return true;
51 end); 50 end);
52 end 51 end

mercurial