AnsweredAssumed Answered

When using an Auto Operator with a LUA script, the alarm.get() will that pull the alarm from the current alarm that triggered the Auto Operator?

Question asked by rtirak on Dec 18, 2018
Latest reply on Dec 20, 2018 by chrja08

I have an LUA script that cleans HTML tags out of my alarm message, and what I am trying to do is have it triggered by the Auto Operator on arrival. So on arrival this script would be ran:

 

First step is to pull in the alarm and assign the message to a string, this is the part I am not sure of can I use the alarm.get() to do something like this?

    

s = alarm.get()

local t = tostring(s) 

 

Than I can run the string through the rest of my script that cleans out the HTML tags and gives me back the clean string:

 

local cleaner = {
{ "&", "&" }, -- decode ampersands
{ "—", "-" }, -- em dash
{ "’", "'" }, -- right single quote
{ "“", "\"" }, -- left double quote
{ "”", "\"" }, -- right double quote
{ "–", "-" }, -- en dash
{ " ", " " }, -- non-breaking space
{ "<br ?/?>", "\n" }, -- all <br> tags whether terminated or not (<br> <br/> <br />) become new lines
{ "</p>", "\n" }, -- ends of paragraphs become new lines
{ "(%b<>)", "" }, -- all other html elements are completely removed (must be done last)
{ "\r", "\n" }, -- return carriage become new lines
{ "[\n\n]+", "\n" }, -- reduce all multiple new lines with a single new line
{ "^\n*", "" }, -- trim new lines from the start...
{ "\n*$", "" }, -- ... and end
}


for i=1, #cleaner do
local cleans = cleaner[i]
t = string.gsub( t, cleans[1], cleans[2] )
end

 

Then I want the alarm to use the cleaned string as the alarm message. Anyone have any idea on how to finish to accomplish this and if I am pulling the alarm message properly into the script from the auto operator?

Outcomes