# HG changeset patch # User Kim Alvefur # Date 1294484319 -3600 # Node ID 6e9f9fd3f64b88394b588bab53b90735adab3d5e # Parent cd9b25249098072a08e6e3968c677eb49d0c70cd plugins.msgforward: New plugin that forwards messages to rooms based on sender. diff -r cd9b25249098 -r 6e9f9fd3f64b plugins/msgforward.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/msgforward.lua Sat Jan 08 11:58:39 2011 +0100 @@ -0,0 +1,17 @@ +function riddim.plugins.msgforward(bot) + local compare_jid = require "util.jid".compare; + local forwards = bot.config.forwards or {}; + bot:hook("message", function(event) + local message = event.stanza; + local from = message.attr.from; + local body = message:get_child("body"); + body = body and body:get_text(); + 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); + return true; + end + end + end); +end