Created
November 6, 2010 11:40
-
-
Save zeen/665352 to your computer and use it in GitHub Desktop.
Messages sent to room bare JIDs by room owners get broadcasted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- mod_muc_broadcast.lua | |
| local jid_bare = require "util.jid".bare; | |
| local st = require "util.stanza"; | |
| module:hook("message/bare", function(event) | |
| local stanza = event.stanza; | |
| if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then | |
| local from = jid_bare(stanza.attr.from); | |
| local to = stanza.attr.to; | |
| local room = hosts[module.host].muc.rooms[to]; | |
| if room then | |
| if room:get_affiliation(from) == "owner" then | |
| local clone = st.clone(stanza); | |
| clone.attr.type = "groupchat"; | |
| clone.attr.from = to; | |
| room:broadcast_message(clone, true); | |
| return true; | |
| end | |
| end | |
| end | |
| end, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment