|
1 function riddim.plugins.msgforward(bot) |
|
2 local compare_jid = require "util.jid".compare; |
|
3 local forwards = bot.config.forwards or {}; |
|
4 bot:hook("message", function(event) |
|
5 local message = event.stanza; |
|
6 local from = message.attr.from; |
|
7 local body = message:get_child("body"); |
|
8 body = body and body:get_text(); |
|
9 if not body then return end |
|
10 for jid, room in pairs(forwards) do |
|
11 if compare_jid(from, jid) and bot.rooms[room] then |
|
12 bot.rooms[room]:send_message(body); |
|
13 return true; |
|
14 end |
|
15 end |
|
16 end); |
|
17 end |