From 83fb13d54186f4fa7fa364fa0fcd8149421d7bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 21 May 2021 08:14:43 +0200 Subject: [PATCH] feat(telegram-bots): add bot for ancient greek word of the day --- configs/telegram-bots/default.nix | 1 + configs/telegram-bots/tlg-wotd.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 configs/telegram-bots/tlg-wotd.nix diff --git a/configs/telegram-bots/default.nix b/configs/telegram-bots/default.nix index d3b2a26..81d7245 100644 --- a/configs/telegram-bots/default.nix +++ b/configs/telegram-bots/default.nix @@ -24,6 +24,7 @@ in { ./autorenkalender.nix ./proverb.nix ./nachtischsatan.nix + ./tlg-wotd.nix ]; diff --git a/configs/telegram-bots/tlg-wotd.nix b/configs/telegram-bots/tlg-wotd.nix new file mode 100644 index 0000000..d2f6b69 --- /dev/null +++ b/configs/telegram-bots/tlg-wotd.nix @@ -0,0 +1,17 @@ +{ pkgs, lib, ... }: +{ + niveum.telegramBots.tlg-wotd = { + enable = true; + time = "8:00"; + token = lib.strings.fileContents ; + chatIds = [ "@tlgwotd" ]; + command = toString (pkgs.writers.writeDash "tlg-wotd" '' + ${pkgs.curl}/bin/curl -sSL http://stephanus.tlg.uci.edu/Iris/Wotd \ + | ${pkgs.recode}/bin/recode html..utf8 \ + | ${pkgs.jq}/bin/jq -r ' + "*\(.word)* '\'''\(.definition | rtrimstr(" "))'\'''\n\nFirst occurrence: \(.firstOccurrence)\nNumber of occurrences: \(.totalOccurrences)" + ' + ''); + parseMode = "Markdown"; + }; +}