mod_muc_bot: Add option to ignore error bounces from bots
Useful when they don't handle messages correctly, returning an error.
--- a/mod_muc_bot/mod_muc_bot.lua Mon May 24 16:18:29 2021 +0200
+++ b/mod_muc_bot/mod_muc_bot.lua Mon May 24 16:18:56 2021 +0200
@@ -68,4 +68,16 @@
end, -100);
end
+if module:get_option_boolean("ignore_bot_errors", true) then
+ module:hook("message/full", function (event)
+ local stanza = event.stanza;
+ if stanza.attr.type == "error" then
+ if bots:contains(jid.bare(stanza.attr.from)) or bots:contains(jid.host(stanza.attr.from)) then
+ module:log("debug", "Ignoring error from known bot");
+ return true;
+ end
+ end
+ end, 1);
+end
+
assert(string.sub("foo[bot]", -5, -1) == "[bot]", "substring indicies, how do they work?");