# HG changeset patch # User Kim Alvefur # Date 1294738812 -3600 # Node ID 4dcb349bb66730afc97440f469c45c153d90a0b8 # Parent 6e9f9fd3f64b88394b588bab53b90735adab3d5e plugins.msgforward: Clone messages, not just the body. diff -r 6e9f9fd3f64b -r 4dcb349bb667 plugins/msgforward.lua --- a/plugins/msgforward.lua Sat Jan 08 11:58:39 2011 +0100 +++ b/plugins/msgforward.lua Tue Jan 11 10:40:12 2011 +0100 @@ -1,6 +1,8 @@ function riddim.plugins.msgforward(bot) local compare_jid = require "util.jid".compare; + local st_clone = require "util.stanza".clone; local forwards = bot.config.forwards or {}; + bot:hook("message", function(event) local message = event.stanza; local from = message.attr.from; @@ -9,7 +11,9 @@ if not body then return end for jid, room in pairs(forwards) do if compare_jid(from, jid) and bot.rooms[room] then - bot.rooms[room]:send_message(body); + local out = st_clone(message); + out.attr.to, out.attr.from, out.attr.type = nil, nil, "groupchat"; + bot.rooms[room]:send(out); return true; end end