Well, no, but it’s so awfully stupidly simple that GPT3.5 will probably get it correct from the first try.
Now that’s an interesting one. You’ll need Dbus, Json and some time processing, but I suppose there are Guile libs that do that? Scheme does have a special place in my heart
Here’s the script for reference:
#!/usr/bin/env ruby
require 'bundler/setup'
require "rubygems"
require "net/http"
require "pp"
require "time"
require "cgi"
require "dbus"
require "json"
VUB_RESTO_URL = URI("https://vub-resto.opencloudedge.be/v1/etterbeek.nl.json")
TUSSENFIX = "\n"
EMOJI = {
"Soup" => "🥣",
"Soep" => "🥣",
"Menu 1" => "🍲",
"Menu 2" => "🍳",
"Veggie" => "🥗",
"Fish" => "🐟",
"Vis" => "🐟",
"Pasta" => "🍝",
"Wok" => "🥢",
}
EMOJI.default = "🥙"
def get_JSON()
res = nil
uri = URI(VUB_RESTO_URL)
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == "https") do |http|
request = Net::HTTP::Get.new uri.request_uri
res = http.request request
return res.body
end
end
def postit(data, location)
parsed_data = JSON.parse(data)
rockwork_svc = DBus.session_bus["org.rockwork"]
mgr = rockwork_svc["/org/rockwork/Manager"]
mgr = mgr["org.rockwork.Manager"]
pebbles = mgr.ListWatches()
pebbles.map! { |pebble_name|
pebble = rockwork_svc[pebble_name]
pebble["org.rockwork.Pebble"]
}
parsed_data.each do |node|
today = Date.strptime(node["date"], "%Y-%m-%d")
noon = DateTime.new(today.year, today.month, today.day, 12, 0, 0, Time.now.getlocal.zone)
lines = []
headings = []
paragraphs = []
items = node["menus"]
until items.empty?
dish = items.shift
headings.push(dish["name"])
paragraphs.push(dish["dish"])
line = "#{EMOJI[dish["name"]]} #{dish["name"]}: #{dish["dish"]}"
lines.push(line)
end
pin = {
id: "vub-resto-" + node["date"],
time: noon.iso8601,
duration: 60, # 1h
layout: {
type: "genericPin",
title: "Resto menu",
body: lines.join(TUSSENFIX),
lastUpdated: DateTime.now.iso8601,
tinyIcon: "system://images/DINNER_RESERVATION",
headings: headings,
paragraphs: paragraphs,
}
}
puts pin
puts JSON.generate(pin)
pebbles.each do |pebble|
pebble.insertTimelinePin(JSON.generate(pin))
end
end
end
if ENV["VUBFOOD_LOCATION"].nil?
warn "location not set, assume etterbeek"
location = :etterbeek
elsif ENV["VUBFOOD_LOCATION"].downcase == "etterbeek"
location = :etterbeek
elsif ENV["VUBFOOD_LOCATION"].downcase == "jette"
location = :jette
end
postit(get_JSON(), location)
It may or may not be an immediate adaption of the Ruby script that I used for posting this to Matrix, which may or may not be an immediate translation of the Ruby script that people used to post this to IRC