1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat(scripts): remove IRC client from pls :(

This commit is contained in:
2021-05-25 21:07:07 +02:00
parent 78f490cdfb
commit e521a82246
3 changed files with 62 additions and 54 deletions

View File

@@ -128,11 +128,7 @@ in rec {
packages = [ pkgs.curl pkgs.gnused pkgs.pandoc pkgs.man ];
};
playlist = wrapScript {
name = "pls";
script = ./playlist.sh;
packages = [ pkgs.curl pkgs.jq ];
};
playlist = import ./pls.nix { inherit pkgs; };
favicon = wrapScript {
packages = [ pkgs.imagemagick ];

View File

@@ -1,49 +0,0 @@
#!/bin/sh
send_irc() {
echo "
USER $USER $(hostname) tolmoon $USER
NICK musikkritiker
JOIN #the_playlist
PRIVMSG #the_playlist :$*
QUIT
" | nc irc.freenode.net 6667 >/dev/null
}
good="what a banger
ooh i love this song
this is top notch stuff!
nice!
noice!
yesss!
cool song!
i like this
that just sounds awesome!
that's a good song!
👍"
bad="how can anyone listen to this?
(╯°□°)╯ ┻━┻
skip this!
next, please! i'm suffering!
that's just bad music
nope
that sucks!
👎"
endpoint=prism.r:8001
case "$1" in
good|like|cool|nice|noice|top|yass|yes|+)
send_irc "$(echo "$good" | shuf -n1)" &
curl -sS -XPOST "$endpoint/good"
;;
skip|next|bad|sucks|no|nope|flop|-)
send_irc "$(echo "$bad" | shuf -n1)" &
curl -sS -XPOST "$endpoint/skip"
;;
*)
curl -sS -XGET "$endpoint/current" | jq
;;
esac
wait

61
packages/scripts/pls.nix Executable file
View File

@@ -0,0 +1,61 @@
{ pkgs }:
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)} \
"$*"
'';
messages.good = [
"what a banger"
"ooh i love this song"
"this is top notch stuff!"
"nice!"
"noice!"
"yesss!"
"cool song!"
"i like this"
"that just sounds awesome!"
"that's a good song!"
"👍"
];
messages.bad = [
"how can anyone listen to this?"
"(°° "
"skip this!"
"next, please! i'm suffering!"
"that's just bad music"
"nope"
"that sucks!"
"👎"
];
in
pkgs.writers.writeDashBin "pls" ''
case "$1" in
good|like|cool|nice|noice|top|yass|yes|+)
# ${sendIRC} "$(echo "${lib.concatStringsSep "\n" messages.good}" | shuf -n1)" &
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/good"
;;
skip|next|bad|sucks|no|nope|flop|-)
# ${sendIRC} "$(echo "${lib.concatStringsSep "\n" messages.bad}" | shuf -n1)" &
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/skip"
;;
*)
${pkgs.curl}/bin/curl -sS -XGET "${playlistAPI}/current" | ${pkgs.jq}/bin/jq
;;
esac
wait
''