diff mod_muc_inject_mentions/mod_muc_inject_mentions.lua @ 4142:6906562af2ee

mod_muc_inject_mentions: Allow preffixes to be used after a new line
author Seve Ferrer <seve@delape.net>
date Sun, 20 Sep 2020 14:45:58 +0200
parents aef6f5b9f6fd
children b2080f76e0aa
line wrap: on
line diff
--- a/mod_muc_inject_mentions/mod_muc_inject_mentions.lua	Sun Sep 20 13:45:32 2020 +0200
+++ b/mod_muc_inject_mentions/mod_muc_inject_mentions.lua	Sun Sep 20 14:45:58 2020 +0200
@@ -43,10 +43,12 @@
     -- There are no configured prefixes
     if not prefixes or #prefixes < 1 then return false end
 
-    -- Preffix must have a space before it
-    -- or be the first character of the body
+    -- Preffix must have a space before it,
+    -- be the first character of the body
+    -- or be the first character after a new line
     if body:sub(first - 2, first - 2) ~= "" and
-        body:sub(first - 2, first - 2) ~= " "
+        body:sub(first - 2, first - 2) ~= " " and
+        body:sub(first - 2, first - 2) ~= "\n"
     then
         return false
     end
@@ -131,7 +133,9 @@
 
                 -- @nickname ...
                 elseif has_preffix and not has_suffix then
-                    if body:sub(last + 1, last + 1) == " " then
+                    if body:sub(last + 1, last + 1) == " " or
+                        body:sub(last + 1, last + 1) == "\n"
+                    then
                         table.insert(mentions, {bare_jid=bare_jid, first=first, last=last})
                     end