This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Multiple event-scripts in 1 script
#17
Hi,

Thanks Admin!

Then your code should be like this:

Code:
function utf8cps(str)   local codepoints = {}   local len = #str   local i = 1   while i <= len do     local c = str:byte(i, i)     if c > 0 and c <= 127 then       codepoints[ #codepoints + 1 ] = c       i = i + 1     elseif c >= 194 and c <= 223 then       local c2 = str:byte(i + 1, i + 1) or 0       local cp = bit.bor(bit.lshift(c - 0xC0, 6), c2 - 0x80)       codepoints[ #codepoints + 1 ] = cp       i = i + 2     elseif c >= 224 and c <= 239 then       i = i + 3     elseif c >= 240 and c <= 244 then       i = i + 4     end   end   return codepoints end function toutf16hex(str)   local cps = utf8cps(str)   local res = {}   for _, cp in ipairs(cps) do     res[ #res + 1 ] = string.format('%04x', cp)   end   return table.concat(res) end -- Perform action only on value true if event.getvalue() == true then      -- Load lib   require('ssl.https')        -- Set parameters   APIUser = 'YOUR_API_USERTOKEN'   APIPassw = 'YOUR_API_PASSWORD'   APIId = 'YOUR_API_ID'   Sender = '123456789'   PhoneNumber = '987654321'  SMSText = 'value of ' ..  grp.find(event.dst).name .. ' is true'   -- Convert SMS text to UTF-16BE   SMSText = toutf16hex(SMSText)      -- Build URL   url = "https://api.clickatell.com/http/sendmsg?user="..APIUser.."&password="..APIPassw.."&api_id="..APIId.."&from=+"..Sender.."&to="..PhoneNumber.."&text="..SMSText.."&unicode=1"      -- Send Request   res, code, headers, status = ssl.https.request(url) end
BR,

Erwin
Reply


Messages In This Thread
Multiple event-scripts in 1 script - by Mr.D - 24.04.2017, 17:33
RE: Multiple event-scripts in 1 script - by Erwin van der Zwart - 08.05.2017, 08:20

Forum Jump: