Changeset

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 4141:aef6f5b9f6fd
children 4143:b2080f76e0aa
files mod_muc_inject_mentions/mod_muc_inject_mentions.lua
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
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