Diff

plugins/mod_admin_telnet.lua @ 5172:3b93f92c613a

Merge 0.9 -> trunk
author Kim Alvefur <zash@zash.se>
date Sun, 14 Oct 2012 22:53:41 +0200
parent 5168:46fc0eff10b4
child 5186:ad898e50b8f3
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Mon Oct 01 20:15:39 2012 +0100
+++ b/plugins/mod_admin_telnet.lua	Sun Oct 14 22:53:41 2012 +0200
@@ -228,7 +228,7 @@
 		print [[user:create(jid, password) - Create the specified user account]]
 		print [[user:password(jid, password) - Set the password for the specified user account]]
 		print [[user:delete(jid) - Permanently remove the specified user account]]
-		print [[user:list(hostname) - List users on the specified host]]
+		print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]]
 	elseif section == "server" then
 		print [[server:version() - Show the server's version number]]
 		print [[server:uptime() - Show how long the server has been running]]
@@ -953,15 +953,21 @@
 	end
 end
 
-function def_env.user:list(host)
+function def_env.user:list(host, pat)
 	if not host then
 		return nil, "No host given";
+	elseif not hosts[host] then
+		return nil, "No such host";
 	end
 	local print = self.session.print;
+	local count = 0;
 	for user in um.users(host) do
-		print(user.."@"..host);
+		if not pat or user:match(pat) then
+			print(user.."@"..host);
+		end
+		count = count + 1;
 	end
-	return true;
+	return true, count .. " users total";
 end
 
 def_env.xmpp = {};