mod_admin_telnet: rename variable to make it defined (room -> room_name)
[prosody.git] / plugins / mod_admin_telnet.lua
index b45db3efaa2d69d682ed197bc4129db8e228d7c7..b2a013247c7026fa60dbdf6b46e215df9aa6fd97 100644 (file)
@@ -557,24 +557,18 @@ local function show_c2s(callback)
        c2s:sort(function(a, b)
                if a.host == b.host then
                        if a.username == b.username then
-                               return a.resource or "" > b.resource or "";
+                               return (a.resource or "") > (b.resource or "");
                        end
-                       return a.username or "" > b.username or "";
+                       return (a.username or "") > (b.username or "");
                end
-               return a.host or "" > b.host or "";
+               return (a.host or "") > (b.host or "");
        end):map(function (session)
                callback(get_jid(session), session)
        end);
 end
 
 function def_env.c2s:count(match_jid)
-       local count = 0;
-       show_c2s(function (jid, session)
-               if (not match_jid) or jid:match(match_jid) then
-                       count = count + 1;
-               end
-       end);
-       return true, "Total: "..count.." clients";
+       return true, "Total: "..  iterators.count(values(module:shared"/*/c2s/sessions")) .." clients";
 end
 
 function def_env.c2s:show(match_jid, annotate)
@@ -963,11 +957,11 @@ local function check_muc(jid)
 end
 
 function def_env.muc:create(room_jid)
-       local room, host = check_muc(room_jid);
+       local room_name, host = check_muc(room_jid);
        if not room_name then
                return room_name, host;
        end
-       if not room then return nil, host end
+       if not room_name then return nil, host end
        if hosts[host].modules.muc.rooms[room_jid] then return nil, "Room exists already" end
        return hosts[host].modules.muc.create_room(room_jid);
 end