mirror of
https://github.com/kmein/niveum
synced 2026-03-30 09:11:10 +02:00
Compare commits
5 Commits
a28fca11a7
...
d78e738f51
| Author | SHA1 | Date | |
|---|---|---|---|
| d78e738f51 | |||
| c9770d065a | |||
| f42d1ebf28 | |||
| f6621a5bb9 | |||
| 136d4e699f |
@@ -14,17 +14,20 @@
|
|||||||
chatIds = ["-1001760262519"];
|
chatIds = ["-1001760262519"];
|
||||||
parseMode = "Markdown";
|
parseMode = "Markdown";
|
||||||
};
|
};
|
||||||
mastodon = {
|
matrix = {
|
||||||
enable = true;
|
enable = true;
|
||||||
homeserver = "c.im";
|
homeserver = "matrix.4d2.org";
|
||||||
tokenFile = config.age.secrets.mastodon-token-logotheca.path;
|
tokenFile = config.age.secrets.matrix-token-lakai.path;
|
||||||
language = "de";
|
chatIds = [
|
||||||
|
"!zlwCuPiCNMSxDviFzA:4d2.org"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
command = "${niveumPackages.literature-quote}/bin/literature-quote";
|
command = "${niveumPackages.literature-quote}/bin/literature-quote";
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
mastodon-token-logotheca.file = ../../secrets/mastodon-token-logotheca.age;
|
mastodon-token-logotheca.file = ../../secrets/mastodon-token-logotheca.age;
|
||||||
|
matrix-token-lakai.file = ../../secrets/matrix-token-lakai.age;
|
||||||
};
|
};
|
||||||
|
|
||||||
niveum.passport.services = [
|
niveum.passport.services = [
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ with lib; let
|
|||||||
"telegram-token:${bot.telegram.tokenFile}"
|
"telegram-token:${bot.telegram.tokenFile}"
|
||||||
] ++ lib.optionals (bot.mastodon.enable) [
|
] ++ lib.optionals (bot.mastodon.enable) [
|
||||||
"mastodon-token:${bot.mastodon.tokenFile}"
|
"mastodon-token:${bot.mastodon.tokenFile}"
|
||||||
|
] ++ lib.optionals (bot.matrix.enable) [
|
||||||
|
"matrix-token:${bot.matrix.tokenFile}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
wants = ["network-online.target"];
|
wants = ["network-online.target"];
|
||||||
@@ -25,6 +27,17 @@ with lib; let
|
|||||||
if [ -n "$QUOTE" ]; then
|
if [ -n "$QUOTE" ]; then
|
||||||
echo $QUOTE >&2
|
echo $QUOTE >&2
|
||||||
|
|
||||||
|
${lib.optionalString (bot.matrix.enable) ''
|
||||||
|
export MATRIX_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/matrix-token")"
|
||||||
|
export JSON_PAYLOAD=$(${pkgs.jq}/bin/jq -n --arg msgtype "m.text" --arg body "$QUOTE" '{msgtype: $msgtype, body: $body}')
|
||||||
|
${strings.concatStringsSep "\n" (map (chatId: ''
|
||||||
|
${pkgs.curl}/bin/curl -X POST "https://${bot.matrix.homeserver}/_matrix/client/r0/rooms/${chatId}/send/m.room.message" \
|
||||||
|
-d "$JSON_PAYLOAD" \
|
||||||
|
-H "Authorization: Bearer $MATRIX_TOKEN" \
|
||||||
|
-H "Content-Type: application/json"
|
||||||
|
'') bot.matrix.chatIds)}
|
||||||
|
''}
|
||||||
|
|
||||||
${lib.optionalString (bot.mastodon.enable) ''
|
${lib.optionalString (bot.mastodon.enable) ''
|
||||||
export MASTODON_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/mastodon-token")"
|
export MASTODON_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/mastodon-token")"
|
||||||
${pkgs.curl}/bin/curl -X POST "https://${bot.mastodon.homeserver}/api/v1/statuses" \
|
${pkgs.curl}/bin/curl -X POST "https://${bot.mastodon.homeserver}/api/v1/statuses" \
|
||||||
@@ -56,6 +69,21 @@ in {
|
|||||||
enable = mkEnableOption "Mastodon and Telegram bot";
|
enable = mkEnableOption "Mastodon and Telegram bot";
|
||||||
time = mkOption {type = types.str;};
|
time = mkOption {type = types.str;};
|
||||||
command = mkOption {type = types.str;};
|
command = mkOption {type = types.str;};
|
||||||
|
matrix = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkEnableOption "Posting to Matrix";
|
||||||
|
tokenFile = mkOption {type = types.path;};
|
||||||
|
homeserver = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
chatIds = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
mastodon = mkOption {
|
mastodon = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = types.submodule {
|
type = types.submodule {
|
||||||
|
|||||||
2
secrets
2
secrets
Submodule secrets updated: 310bc64174...d621ecc885
@@ -46,6 +46,7 @@ secrets/mastodon-token-logotheca.age
|
|||||||
secrets/mastodon-token-smyth.age
|
secrets/mastodon-token-smyth.age
|
||||||
secrets/mastodon-token-tlgwotd.age
|
secrets/mastodon-token-tlgwotd.age
|
||||||
secrets/mastodon-token-transits.age
|
secrets/mastodon-token-transits.age
|
||||||
|
secrets/matrix-token-lakai.age
|
||||||
secrets/maxmind-license-key.age
|
secrets/maxmind-license-key.age
|
||||||
secrets/mega-password.age
|
secrets/mega-password.age
|
||||||
secrets/miniflux-api-token.age
|
secrets/miniflux-api-token.age
|
||||||
@@ -58,7 +59,6 @@ secrets/onlyoffice-jwt-key.age
|
|||||||
secrets/openweathermap-api-key.age
|
secrets/openweathermap-api-key.age
|
||||||
secrets/restic.age
|
secrets/restic.age
|
||||||
secrets/secrets.nix
|
secrets/secrets.nix
|
||||||
secrets/secrets.sync-conflict-20241007-194311-GSOGYT3.nix
|
|
||||||
secrets/spotify-password.age
|
secrets/spotify-password.age
|
||||||
secrets/spotify-username.age
|
secrets/spotify-username.age
|
||||||
secrets/stw-berlin-card-code.age
|
secrets/stw-berlin-card-code.age
|
||||||
|
|||||||
@@ -13,6 +13,23 @@
|
|||||||
retiolumLink = true;
|
retiolumLink = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
matrix = {
|
||||||
|
server ? "matrix.4d2.org",
|
||||||
|
target,
|
||||||
|
}:
|
||||||
|
pkgs.writers.writeDash "matrix-reporter" ''
|
||||||
|
export RAW_MESSAGE="$(cat)"
|
||||||
|
export MESSAGE=$(printf '<b>%s</b><br><pre>%s</pre>' "$PANOPTIKON_WATCHER" "$RAW_MESSAGE")
|
||||||
|
export MATRIX_TOKEN="$(cat ${config.age.secrets.matrix-token-lakai.path})"
|
||||||
|
export JSON_PAYLOAD=$(${pkgs.jq}/bin/jq -n --arg msgtype "m.text" --arg body "$RAW_MESSAGE" --arg formattedBody "$MESSAGE" '{msgtype: $msgtype, body: $body, format: "org.matrix.custom.html", formatted_body: $formattedBody}')
|
||||||
|
${pkgs.curl}/bin/curl -X POST "https://${server}/_matrix/client/r0/rooms/${target}/send/m.room.message" \
|
||||||
|
-d "$JSON_PAYLOAD" \
|
||||||
|
-H "Authorization: Bearer $MATRIX_TOKEN" \
|
||||||
|
-H "Content-Type: application/json"
|
||||||
|
'';
|
||||||
|
|
||||||
|
matrix-kmein = matrix { target = "!zlwCuPiCNMSxDviFzA:4d2.org"; };
|
||||||
|
|
||||||
telegram-kmein = let
|
telegram-kmein = let
|
||||||
chatId = "-1001796440545";
|
chatId = "-1001796440545";
|
||||||
in
|
in
|
||||||
@@ -32,6 +49,12 @@
|
|||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
age.secrets.telegram-token-kmein.file = ../../secrets/telegram-token-kmein.age;
|
age.secrets.telegram-token-kmein.file = ../../secrets/telegram-token-kmein.age;
|
||||||
|
age.secrets.matrix-token-lakai = {
|
||||||
|
file = ../../secrets/matrix-token-lakai.age;
|
||||||
|
owner = "panoptikon";
|
||||||
|
group = "panoptikon";
|
||||||
|
mode = "400";
|
||||||
|
};
|
||||||
|
|
||||||
services.panoptikon = {
|
services.panoptikon = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -49,79 +72,79 @@ in {
|
|||||||
};
|
};
|
||||||
lammla = {
|
lammla = {
|
||||||
script = panoptikon.url "http://lammla.info/index.php?reihe=30";
|
script = panoptikon.url "http://lammla.info/index.php?reihe=30";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
kratylos = {
|
kratylos = {
|
||||||
script = panoptikon.url "https://kratylos.reichert-online.org/current_issue/KRATYLOS";
|
script = panoptikon.url "https://kratylos.reichert-online.org/current_issue/KRATYLOS";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
kobudo-tesshinkan = {
|
kobudo-tesshinkan = {
|
||||||
script = panoptikon.url "https://kobudo-tesshinkan.eu/index.php/de/termine-berichte/lehrgaenge/";
|
script = panoptikon.url "https://kobudo-tesshinkan.eu/index.php/de/termine-berichte/lehrgaenge/";
|
||||||
reporters = [irc-kmein telegram-kmein];
|
reporters = [irc-kmein telegram-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
zeno-free = {
|
zeno-free = {
|
||||||
script = panoptikon.urlSelector ".zenoCOMain" "http://www.zeno.org/Lesesaal/M/E-Books";
|
script = panoptikon.urlSelector ".zenoCOMain" "http://www.zeno.org/Lesesaal/M/E-Books";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
carolinawelslau = {
|
carolinawelslau = {
|
||||||
script = panoptikon.urlSelector "#main" "https://carolinawelslau.de/";
|
script = panoptikon.urlSelector "#main" "https://carolinawelslau.de/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
humboldt-preis = {
|
humboldt-preis = {
|
||||||
script = panoptikon.urlSelector "#content-core" "https://www.hu-berlin.de/de/ueberblick/menschen/ehrungen/humboldtpreis";
|
script = panoptikon.urlSelector "#content-core" "https://www.hu-berlin.de/de/ueberblick/menschen/ehrungen/humboldtpreis";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann = {
|
lisalittmann = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann-archive = {
|
lisalittmann-archive = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/archive/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/archive/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann-projects = {
|
lisalittmann-projects = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/projects/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/projects/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
tatort = {
|
tatort = {
|
||||||
script = panoptikon.urlSelector ".linklist" "https://www.daserste.de/unterhaltung/krimi/tatort/sendung/index.html";
|
script = panoptikon.urlSelector ".linklist" "https://www.daserste.de/unterhaltung/krimi/tatort/sendung/index.html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-idiomarium = {
|
warpgrid-idiomarium = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/idiomarium/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/idiomarium/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-futurism = {
|
warpgrid-futurism = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/futurism/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/futurism/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-imagiary = {
|
warpgrid-imagiary = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/imagiary/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/imagiary/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-alchemy = {
|
warpgrid-alchemy = {
|
||||||
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/alchemy/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/alchemy/";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
indogermanische-forschungen = {
|
indogermanische-forschungen = {
|
||||||
script = panoptikon.urlSelector "#latestIssue" "https://www.degruyter.com/journal/key/INDO/html";
|
script = panoptikon.urlSelector "#latestIssue" "https://www.degruyter.com/journal/key/INDO/html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
ig-neuigkeiten = {
|
ig-neuigkeiten = {
|
||||||
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/aktuelles/neuigkeiten.html";
|
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/aktuelles/neuigkeiten.html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
ig-tagungen = {
|
ig-tagungen = {
|
||||||
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/tagungen/tagungen-der-ig.html";
|
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/tagungen/tagungen-der-ig.html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
fu-distant = {
|
fu-distant = {
|
||||||
script = panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/en/e/ma-distant/Termine/index.html";
|
script = panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/en/e/ma-distant/Termine/index.html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
fu-aegyptologie = {
|
fu-aegyptologie = {
|
||||||
script = panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/e/aegyptologie/termine/index.html";
|
script = panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/e/aegyptologie/termine/index.html";
|
||||||
reporters = [irc-kmein];
|
reporters = [irc-kmein matrix-kmein];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ in {
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
make_streams("lyrikline", random_url("${lyrikline-poem}"), description="lyrikline. listen to the poet (unofficial)", genre="poetry")
|
# make_streams("lyrikline", random_url("${lyrikline-poem}"), description="lyrikline. listen to the poet (unofficial)", genre="poetry")
|
||||||
make_streams("qasida", random_url("${qasida-poem}"), description="Qasa'id. Classical arabic poetry", genre="poetry")
|
make_streams("qasida", random_url("${qasida-poem}"), description="Qasa'id. Classical arabic poetry", genre="poetry")
|
||||||
make_streams("lyrik", random_url("${stavenhagen-poem}"), description="Fritz Stavenhagen – Lyrik für alle | www.deutschelyrik.de", genre="poetry")
|
make_streams("lyrik", random_url("${stavenhagen-poem}"), description="Fritz Stavenhagen – Lyrik für alle | www.deutschelyrik.de", genre="poetry")
|
||||||
make_streams("wikipedia", random_url("${wikipedia-article}"), description="Zufällige Artikel von Wikipedia", genre="useless knowledge")
|
# make_streams("wikipedia", random_url("${wikipedia-article}"), description="Zufällige Artikel von Wikipedia", genre="useless knowledge")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
systemd.services.radio = {
|
systemd.services.radio = {
|
||||||
|
|||||||
@@ -181,6 +181,39 @@ in {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
# ref https://github.com/Mic92/dotfiles/blob/f44bac5dd6970ed3fbb4feb906917331ec3c2be5/machines/eva/modules/prometheus/default.nix
|
||||||
|
systemd.services.matrix-hook = {
|
||||||
|
description = "Matrix Hook";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
environment = {
|
||||||
|
HTTP_ADDRESS = "[::1]";
|
||||||
|
HTTP_PORT = "9088";
|
||||||
|
MX_HOMESERVER = "https://matrix.4d2.org";
|
||||||
|
MX_ID = "@lakai:4d2.org";
|
||||||
|
MX_ROOMID = "!zlwCuPiCNMSxDviFzA:4d2.org";
|
||||||
|
MX_MSG_TEMPLATE = "${pkgs.matrix-hook}/message.html.tmpl";
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
EnvironmentFile = [
|
||||||
|
# format: MX_TOKEN=<token>
|
||||||
|
config.age.secrets.matrix-token-lakai-env.path
|
||||||
|
];
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${pkgs.matrix-hook}/bin/matrix-hook";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "10";
|
||||||
|
DynamicUser = true;
|
||||||
|
User = "matrix-hook";
|
||||||
|
Group = "matrix-hook";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
age.secrets = {
|
||||||
|
matrix-token-lakai-env.file = ../../../secrets/matrix-token-lakai-env.age;
|
||||||
|
};
|
||||||
|
|
||||||
services.prometheus.alertmanager = {
|
services.prometheus.alertmanager = {
|
||||||
enable = true;
|
enable = true;
|
||||||
listenAddress = "localhost";
|
listenAddress = "localhost";
|
||||||
@@ -190,39 +223,17 @@ in {
|
|||||||
route = {
|
route = {
|
||||||
group_wait = "30s";
|
group_wait = "30s";
|
||||||
repeat_interval = "24h";
|
repeat_interval = "24h";
|
||||||
receiver = "all";
|
receiver = "matrix";
|
||||||
};
|
};
|
||||||
receivers = [
|
receivers = [
|
||||||
{
|
{
|
||||||
name = "all";
|
name = "matrix";
|
||||||
telegram_configs = [
|
webhook_configs = [
|
||||||
{
|
{
|
||||||
bot_token = "$TELEGRAM_TOKEN";
|
url = "http://localhost:9088/alert";
|
||||||
chat_id = 18980945;
|
max_alerts = 5;
|
||||||
parse_mode = "";
|
|
||||||
api_url = "https://api.telegram.org";
|
|
||||||
send_resolved = true;
|
|
||||||
message = ''
|
|
||||||
{{range .Alerts -}}
|
|
||||||
{{ .Status }}: {{ index .Annotations "summary" }}
|
|
||||||
{{end -}}
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
email_configs = let
|
|
||||||
inherit (import ../../../lib) kieran;
|
|
||||||
inherit (import ../../../lib/email.nix {inherit lib;}) cock;
|
|
||||||
cockConfig = {
|
|
||||||
send_resolved = true;
|
|
||||||
to = kieran.email;
|
|
||||||
from = cock.user;
|
|
||||||
smarthost = "${cock.smtp}:587";
|
|
||||||
auth_username = cock.user;
|
|
||||||
auth_identity = cock.user;
|
|
||||||
auth_password = "$EMAIL_PASSWORD";
|
|
||||||
};
|
|
||||||
in [
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user