Software /
code /
prosody
Changeset
6217:657c707d9229
plugins/muc/muc.lib: Use util.iterators to count occupants
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Thu, 03 Apr 2014 16:10:43 -0400 |
parents | 6216:50b8b7caf200 |
children | 6218:bf11910bad5a |
files | plugins/muc/muc.lib.lua |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);