From c06fb3f50c9a01ccb91549a2b651ca0b7f25fd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 19 Oct 2021 22:42:29 +0200 Subject: [PATCH] feat(pls): use ircaids --- configs/packages/default.nix | 1 + packages/scripts/pls.nix | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/configs/packages/default.nix b/configs/packages/default.nix index a459d07..be949c3 100644 --- a/configs/packages/default.nix +++ b/configs/packages/default.nix @@ -198,6 +198,7 @@ in { kpaste irc-announce git-preview + ircaids ]; } diff --git a/packages/scripts/pls.nix b/packages/scripts/pls.nix index 381ff50..4e8bdc3 100755 --- a/packages/scripts/pls.nix +++ b/packages/scripts/pls.nix @@ -2,21 +2,15 @@ let inherit (pkgs) lib; - irc = { - host = "irc.hackint.org"; - port = 6697; - tls = true; - channel = "#the_playlist"; - nick = "musikkritiker"; - }; - playlistAPI = "prism.r:8001"; sendIRC = pkgs.writers.writeDash "send-irc" '' - ${pkgs.nur.repos.mic92.untilport}/bin/untilport ${irc.host} ${toString irc.port} && \ - ${pkgs.nur.repos.mic92.irc-announce}/bin/irc-announce \ - ${irc.host} ${toString irc.port} ${irc.nick} ${lib.escapeShellArg irc.channel} ${toString (if irc.tls then 1 else 0)} \ - "$*" 2>&1 >/dev/null + ${pkgs.ircaids}/bin/ircsink \ + --nick musikkritiker \ + --server irc.hackint.org \ + --port 6697 \ + --secure \ + --target '#the_playlist' >/dev/null 2>&1 ''; messages.good = [ @@ -31,6 +25,7 @@ let "that just sounds awesome!" "that's a good song!" "👍" + "vibin'" ]; messages.bad = [ "how can anyone listen to this?" @@ -41,16 +36,17 @@ let "nope" "that sucks!" "👎" + "turn that down" ]; in pkgs.writers.writeDashBin "pls" '' case "$1" in good|like|cool|nice|noice|top|yup|yass|yes|+) - ${sendIRC} "$(echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1)" & + echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1 | ${sendIRC} ${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/good" ;; skip|next|bad|sucks|no|nope|flop|-) - ${sendIRC} "$(echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1)" & + echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1 | ${sendIRC} ${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/skip" ;; *)