From ce9992005454376ee068e7bea3cf14fe8f6a0267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 25 Nov 2022 11:27:16 +0100 Subject: [PATCH] feat: celan telegram bot --- configs/telegram-bots/celan.nix | 35 +++++++++++++++++++++++++++++++ configs/telegram-bots/default.nix | 1 + 2 files changed, 36 insertions(+) create mode 100644 configs/telegram-bots/celan.nix diff --git a/configs/telegram-bots/celan.nix b/configs/telegram-bots/celan.nix new file mode 100644 index 0000000..c4273e4 --- /dev/null +++ b/configs/telegram-bots/celan.nix @@ -0,0 +1,35 @@ +{ + pkgs, + lib, + ... +}: let + celan = pkgs.fetchzip { + url = "http://c.krebsco.de/celan.tar.gz"; + sha256 = "sha256-nA+EwAH2vkeolsy9AoPLEMt1uGKDZe/aPrS95CZvuus="; + }; +in { + niveum.telegramBots.celan = { + enable = true; + time = "08:00"; + token = lib.strings.fileContents ; + chatIds = ["@PaulCelan"]; + command = toString (pkgs.writers.writeDash "random-celan" '' + cd ${celan} + poem="$(${pkgs.findutils}/bin/find . -type f | ${pkgs.coreutils}/bin/shuf -n1)" + source="$(${pkgs.coreutils}/bin/dirname "$poem" | ${pkgs.gnused}/bin/sed 's#^\./##;s/[-_]/ /g;s!/! › !g;s/0\([0-9]\+\)/\1/g')" + cat "$poem" + echo + printf "Aus: %s\n" "$source" + ''); + }; + + systemd.timers.telegram-bot-hesychius.timerConfig.RandomizedDelaySec = "10h"; + + niveum.passport.services = [ + { + title = "Paul Celan Bot"; + description = "sends a random poem by Paul Celan to Telegram."; + link = "https://t.me/PaulCelan"; + } + ]; +} diff --git a/configs/telegram-bots/default.nix b/configs/telegram-bots/default.nix index 42e307f..9131db7 100644 --- a/configs/telegram-bots/default.nix +++ b/configs/telegram-bots/default.nix @@ -22,6 +22,7 @@ in { ./smyth.nix ./nachtischsatan.nix ./tlg-wotd.nix + ./celan.nix ];