From dc824ea96667b60ede3ac62b75f18e1faded977d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Mon, 24 Mar 2025 16:59:26 -0400 Subject: initial support for triggered lua functions --- plugins/hello.lua | 5 +++++ plugins/repology.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 plugins/hello.lua create mode 100644 plugins/repology.lua (limited to 'plugins') diff --git a/plugins/hello.lua b/plugins/hello.lua new file mode 100644 index 0000000..b9c5bc2 --- /dev/null +++ b/plugins/hello.lua @@ -0,0 +1,5 @@ +local milla = require("milla") + +function hello() milla.reply_to("hello") end + +milla.register_cmd("/plugins/hello.lua", "hello", "hello") diff --git a/plugins/repology.lua b/plugins/repology.lua new file mode 100644 index 0000000..f3de647 --- /dev/null +++ b/plugins/repology.lua @@ -0,0 +1,33 @@ +local milla = require("milla") +local os = require("os") +local json = require("json") + +-- /repology void_x86_64 +function repology(arg) + os.setenv("http_proxy", "http://172.17.0.1:8120") + + local http = require("http") + + local url = "https://repology.org/api/v1/repository/" .. arg .. "/problems" + + local response = http.request("GET", url) + + io.write(response.body) + + local json_response, err = json.decode(response.body) + io.write(json_response) + if err ~= nil then print(err) end + + for _, item in pairs(json_response) do + for k, v in ipairs(item) do print(k, v) end + end + + local result = "" + for key, value in pairs(json_response) do + result = result .. key .. ": " .. value .. " -- " + end + + return result +end + +milla.register_cmd("/plugins/repology.lua", "repology", "repology") -- cgit v1.2.3