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.

garbage can trigger
#4
Here's an example that you can use a starting point. data variable should contain the ICS file contents that you get externally.

First the script parses ICS events into a table. Then it looks for an event with a matching date. summary variable is the summary field (kind of garbage in your case) of the found event or an empty string. Change 1/1/1 as needed and use 250 byte string as the data type of this object.

Code:
url = 'https://p35-caldav.icloud.com/published/2/MTQzMzA1NjcxOTE0MzMwNXFFkpAlN-RmUw02iYPAHdjXli1qufT3m2kVvFAFS2VXJLUhJ6r02NrhV15B8p_WoReJ0k5wrU4I1th5F6eq8UI'
data, err = require('socket.http').request(url)

if not data then
  log('request failed', err)
  return
end

data = data:split('\n')

events = {}

for _, line in ipairs(data) do
  line = line:trim()

  if line == 'BEGIN:VEVENT' then
    event = {}
  elseif line == 'END:VEVENT' then
    events[ #events + 1 ] = event
    event = nil
  elseif event then
    pos = line:find(':')
    if pos then
      key = line:sub(1, pos - 1)
      value = line:sub(pos + 1)

      event[ key ] = value
    end
  end
end

now = os.date('%Y%m%d')
summary = ''

for _, event in ipairs(events) do
  if event['DTSTART;VALUE=DATE'] == now then
    summary = event['SUMMARY']
    break
  end
end

grp.checkupdate('1/1/1', summary)
Reply


Messages In This Thread
garbage can trigger - by pioneersteffen - 05.01.2022, 16:52
RE: garbage can trigger - by admin - 14.01.2022, 12:02
RE: garbage can trigger - by pioneersteffen - 14.01.2022, 19:15
RE: garbage can trigger - by admin - 17.01.2022, 08:34
RE: garbage can trigger - by pioneersteffen - 17.01.2022, 17:56
RE: garbage can trigger - by admin - 18.01.2022, 08:53
RE: garbage can trigger - by pioneersteffen - 18.01.2022, 09:22
RE: garbage can trigger - by admin - 18.01.2022, 09:31
RE: garbage can trigger - by pioneersteffen - 18.01.2022, 12:30
RE: garbage can trigger - by pioneersteffen - 18.01.2022, 13:39
RE: garbage can trigger - by admin - 18.01.2022, 13:41
RE: garbage can trigger - by pioneersteffen - 18.01.2022, 14:11

Forum Jump: