# HG changeset patch # User daurnimator # Date 1396555843 14400 # Node ID 657c707d9229c200e62d7811be5647ee87a67945 # Parent 50b8b7caf2003844d7b94ab4ee699ab061a60267 plugins/muc/muc.lib: Use util.iterators to count occupants diff -r 50b8b7caf200 -r 657c707d9229 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Thu Apr 03 16:04:04 2014 -0400 +++ b/plugins/muc/muc.lib.lua Thu Apr 03 16:10:43 2014 -0400 @@ -13,6 +13,7 @@ local setmetatable = setmetatable; local dataform = require "util.dataforms"; +local iterators = require "util.iterators"; local jid_split = require "util.jid".split; local jid_bare = require "util.jid".bare; local jid_prep = require "util.jid".prep; @@ -313,7 +314,7 @@ event.reply:tag("feature", {var = event.room:get_hidden() and "muc_hidden" or "muc_public"}):up(); end); module:hook("muc-disco#info", function(event) - local count = 0; for _ in event.room:each_occupant() do count = count + 1; end + local count = iterators.count(event.room:each_occupant()); table.insert(event.form, { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) }); end);