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
function debug_print(message)
local function debug_print(message)
if debug == true then
Printf(tostring(message))
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
timeout = 5
timeout, seperator, message = args.partition(";")
local timeoutStr, message = split_first(args, ";")
timeout = tonumber(timeoutStr) or timeout
local messageTable = {
title = "Notification!",
message = tostring(message),
timeout = tonumber(timeout*1000),
timeout = timeout * 1000, -- convert seconds to milliseconds
timeoutResultCancel = false,
timeoutResultID = 99,
}
local returnTable = MessageBox(messageTable)
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