pastebin get 3dutQQeD ntfy (https://pastebin.com/3dutQQeD)
Finally, an (unofficial) ntfy.sh API! You can load my API with:
local ntfy = require("ntfy")
It has 1 function:
ntfy.send()
The arguments are as follows:
ntfy.send("topic", "message", "title")
"topic" is as in http://ntfy.sh/topic.
"message" is the "body" of the notification.
"title" is the title of the notification. (If the title is not supplied, it will be:
ntfy.sh/[topic].)
Example for sending a notification to "lol" upon redstone:
while true do
if os.pullEvent() == "redstone" then
sleep(1)
ntfy.send("lol", "sussy bussy box", "mincrafet")
end
end
To send to a phone, use the "ntfy" app.
To send to computer, just go to
ntfy.sh/[topic]
in its browser.
Enjoy the API I quickly whipped up!
pastebin get 3dutQQeD ntfy (https://pastebin.com/3dutQQeD)
os.loadAPI is the old way of doing things, you may want to convert your API into a
require module.
It's not difficult to do, tweaked.cc has a guide on it (https://tweaked.cc/guide/using_require.html).
Otherwise, this looks good.
A couple of recommendations:
- If title ~= nil then can be simplified to if title then, the functionality is a little different as the latter will also resolve as false if title's value is false, whereas the former would resolve as true since false is not equal to nil
- You may want to validate your inputs, computercraft adds a module for this cc.expect (https://tweaked.cc/library/cc.expect.html)
Did you test this before posting?
Because it doesn't work lol
You're returning a boolean, at the bottom add
return { send = send }