changeset 4567:bcf4518d18d4

mod_muc_bot: Add option to ignore error bounces from bots Useful when they don't handle messages correctly, returning an error.
author Kim Alvefur <zash@zash.se>
date Mon, 24 May 2021 16:18:56 +0200
parents 174c7a3c819b
children 88089c61121d
files mod_muc_bot/mod_muc_bot.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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?");