From 68219a9ce8a7b6de2a00f3043ed190cc9689ca48 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Mon, 3 Dec 2018 19:01:25 +0100 Subject: [PATCH] Example republisher by binarybucks addresses #274 --- contrib/lua/repub.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 contrib/lua/repub.lua diff --git a/contrib/lua/repub.lua b/contrib/lua/repub.lua new file mode 100644 index 0000000..dbe027e --- /dev/null +++ b/contrib/lua/repub.lua @@ -0,0 +1,25 @@ +-- requires: +-- a) Compile recorder with -DLUA and configure +-- b) OTR_LUASCRIPT = ".../repub.lua" +-- also requires Lua JSON from http://regex.info/blog/lua/json + +JSON = (loadfile "/etc/ot-recorder/JSON.lua")() + +function otr_hook(topic, _type, data) + otr.log("DEBUG_PUB:" .. topic .. " " .. JSON:encode(data)) + if(data['_http'] == true) then + if(data['_repub'] == true) then + return + end + data['_repub'] = true + local payload = JSON:encode(data) + otr.publish(topic, payload, 1, 1) + end +end + +function otr_putrec(u, d, s) + j = JSON:decode(s) + if (j['_repub'] == true) then + return 1 + end +end