25.10.2022, 09:04
Try this. This example assumes that strings like "1-0:1.8.2" are unique value keys that are unchanged between requests.
Code:
url = 'http://{IP address}/api/v1/telegram'
response = require('socket.http').request(url)
lines = response:split('\n')
result = {}
for _, line in ipairs(lines) do
line = line:trim()
pos = line:find('(', 1, true)
if pos then
key = line:sub(1, pos - 1)
val = line:sub(pos + 1, -2)
val = val:gsub('[^%d%.]+', '')
result[ key ] = tonumber(val)
end
end
log(result)
grp.checkupdate('1/1/1', result['1-0:1.8.1'])
grp.checkupdate('1/1/2', result['1-0:1.8.2'])