Merge remote-tracking branches 'prism/master' and 'kmein/master'

This commit is contained in:
tv 2019-07-09 20:52:23 +02:00
commit 421a97927b

View file

@ -17,6 +17,8 @@ let
api = { api = {
enable = mkEnableOption "krebs.urlwatch"; enable = mkEnableOption "krebs.urlwatch";
customSendmail.enable = mkEnableOption "krebs.urlwatch.customSendmail";
dataDir = mkOption { dataDir = mkOption {
type = types.str; type = types.str;
default = "/var/lib/urlwatch"; default = "/var/lib/urlwatch";
@ -54,6 +56,15 @@ let
The format is described in systemd.time(7), CALENDAR EVENTS. The format is described in systemd.time(7), CALENDAR EVENTS.
''; '';
}; };
telegram = {
enable = mkEnableOption "krebs.urlwatch.telegram" // { default = false; };
botToken = mkOption {
type = types.str;
};
chatId = mkOption {
type = types.listOf types.str;
};
};
urls = mkOption { urls = mkOption {
type = with types; listOf (either str subtypes.job); type = with types; listOf (either str subtypes.job);
default = []; default = [];
@ -110,6 +121,11 @@ let
color = true; color = true;
enabled = true; enabled = true;
}; };
${if cfg.telegram.enable then "telegram" else null} = {
enabled = cfg.telegram.enable;
bot_token = cfg.telegram.botToken;
chat_id = cfg.telegram.chatId;
};
text = { text = {
details = true; details = true;
footer = true; footer = true;
@ -158,6 +174,7 @@ let
--urls=${shell.escape urlsFile} \ --urls=${shell.escape urlsFile} \
> changes || : > changes || :
${optionalString cfg.customSendmail.enable /* sh */ ''
if test -s changes; then if test -s changes; then
{ {
echo Date: $(date -R) echo Date: $(date -R)
@ -171,6 +188,7 @@ let
cat changes cat changes
} | /run/wrappers/bin/sendmail -t } | /run/wrappers/bin/sendmail -t
fi fi
''}
''; '';
}; };
}; };