fixed lugin

Signed-off-by: Ebbe <ebbe@ping-mee.de>
main
Ebbe Baß 2025-04-26 19:26:12 +02:00
parent c0021241e1
commit 2af4bc8a7e
1 changed files with 19 additions and 5 deletions

View File

@ -1,26 +1,40 @@
debug = true debug = true
function debug_print(message) local function debug_print(message)
if debug == true then if debug == true then
Printf(tostring(message)) Printf(tostring(message))
end end
end end
function main(display_handle, args)
local function split_first(inputstr, sep)
local sep = sep or ";"
local sep_pos = string.find(inputstr, sep)
if not sep_pos then
return inputstr, nil
end
local first = string.sub(inputstr, 1, sep_pos - 1)
local rest = string.sub(inputstr, sep_pos + 1)
return first, rest
end
local function main(display_handle, args)
if args then if args then
timeout = 5 timeout = 5
timeout, seperator, message = args.partition(";") local timeoutStr, message = split_first(args, ";")
timeout = tonumber(timeoutStr) or timeout
local messageTable = { local messageTable = {
title = "Notification!", title = "Notification!",
message = tostring(message), message = tostring(message),
timeout = tonumber(timeout*1000), timeout = timeout * 1000, -- convert seconds to milliseconds
timeoutResultCancel = false, timeoutResultCancel = false,
timeoutResultID = 99, timeoutResultID = 99,
} }
local returnTable = MessageBox(messageTable) local returnTable = MessageBox(messageTable)
else else
Printf('You must atleast specify your notification message. You can do this by running the following command: Plugin "custom notifications" "5;Hello this is a notification!"\nThis will create a message with a duration of 5 seconds.') Printf('You must at least specify your notification message. Example:\nPlugin "custom notifications" "5;Hello this is a notification!"\nThis will create a message with a duration of 5 seconds.')
end end
end end