[mod] custom strings

This commit is contained in:
fenris 2025-07-19 12:00:38 +02:00
parent 06b220dd27
commit 4d2b20f0b4
3 changed files with 77 additions and 23 deletions

View file

@ -72,6 +72,10 @@ namespace _munin.conf
receivers : Array<string>;
hide_tags : boolean;
reminders : Array<type_reminder_raw>;
language : string;
strings : {
notification_head : string;
};
}
}
|
@ -82,6 +86,10 @@ namespace _munin.conf
chat_id : int;
hide_tags : boolean;
reminders : Array<type_reminder_raw>;
language : string;
strings : {
notification_head : string;
};
}
}
)
@ -325,6 +333,21 @@ namespace _munin.conf
"type": "string",
"default": "deu"
},
"strings": {
"nullable": false,
"type": "object",
"properties": {
"notification_head": {
"nullable": false,
"type": "string",
"default": "[{{core}}] {{extra}}"
},
},
"additionalProperties": false,
"required": [
],
"default": {},
},
},
"additionalProperties": false,
"required": [
@ -387,6 +410,21 @@ namespace _munin.conf
"type": "string",
"default": "deu"
},
"strings": {
"nullable": false,
"type": "object",
"properties": {
"notification_head": {
"nullable": false,
"type": "string",
"default": "[{{core}}] {{extra}}"
},
},
"additionalProperties": false,
"required": [
],
"default": {},
},
},
"additionalProperties": false,
"required": [

View file

@ -33,6 +33,9 @@ namespace _munin.targets.email
hide_tags : boolean;
reminders : Array<_munin.type_reminder>;
language : string;
strings : {
notification_head : string;
};
};
@ -165,17 +168,22 @@ namespace _munin.targets.email
summarize_event(parameters, events[0])
:
lib_plankton.string.coin(
"[{{head}}] {{count}} {{events}}",
parameters.strings.notification_head,
{
"head": lib_plankton.string.coin(
"core": lib_plankton.string.coin(
"{{event}}-{{reminder}}",
{
"event": get_translation(parameters, "core.event.event").toLowerCase(),
"reminder": get_translation(parameters, "core.reminder.reminder").toLowerCase(),
}
),
"count": events.length.toFixed(0),
"events": get_translation(parameters, "core.event.events"),
"extra": lib_plankton.string.coin(
"{{count}} {{events}}",
{
"count": events.length.toFixed(0),
"events": get_translation(parameters, "core.event.events"),
}
),
}
)
),

View file

@ -29,6 +29,9 @@ namespace _munin.targets.telegram_bot
hide_tags : boolean;
reminders : Array<_munin.type_reminder>;
language : string;
strings : {
notification_head : string;
};
};
@ -116,29 +119,34 @@ namespace _munin.targets.telegram_bot
parameters.bot_token,
parameters.chat_id,
lib_plankton.string.coin(
"*{{head_core}}{{head_extra}}*\n\n{{events}}",
"*{{head}}*\n\n{{body}}",
{
"head_core": lib_plankton.string.coin(
"{{event}}-{{reminder}}",
"head": lib_plankton.string.coin(
parameters.strings.notification_head,
{
"event": lib_plankton.string.capitalize(get_translation(parameters, "core.event.event")),
"reminder": lib_plankton.string.capitalize(get_translation(parameters, "core.reminder.reminder")),
"core": lib_plankton.string.coin(
"{{label_event}}-{{label_reminder}}",
{
"label_event": lib_plankton.string.capitalize(get_translation(parameters, "core.event.event")),
"label_reminder": lib_plankton.string.capitalize(get_translation(parameters, "core.reminder.reminder")),
}
),
"extra": (
(events.length <= 1)
?
""
:
lib_plankton.string.coin(
" ({{count}} {{events}})",
{
"count": events.length.toFixed(0),
"events": get_translation(parameters, "core.event.events"),
}
)
),
}
),
"head_extra": (
(events.length <= 1)
?
""
:
lib_plankton.string.coin(
" ({{count}} {{events}})",
{
"count": events.length.toFixed(0),
"events": get_translation(parameters, "core.event.events"),
}
)
),
"events": (
"body": (
events
.map(event => render_event(parameters, event))
.join("\n\n--------\n\n")