Add new radio service using mpd. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 6933d425fc2e922a0e3b9c8b3244106d1f03ecab | |
parent b84cff428a6f7fe86c9f5681e41222f3a8b41d2a | |
Author: Annna Robert-Houdin <[email protected]> | |
Date: Tue, 30 Jul 2024 23:25:57 +0200 | |
Add new radio service using mpd. | |
Diffstat: | |
M annna-channel-service | 4 ++++ | |
M annna-message-radio | 19 ++++++++----------- | |
M annna-stop-services | 1 + | |
A modules/radio/radio-channel-servic… | 29 +++++++++++++++++++++++++++… | |
4 files changed, 42 insertions(+), 11 deletions(-) | |
--- | |
diff --git a/annna-channel-service b/annna-channel-service | |
@@ -22,6 +22,10 @@ case "${channel}" in | |
"${ircuser}" "${idlebase}" "${ircbase}" "${server}" "${channel… | |
exit $? | |
;; | |
+\#bitreich-radio) | |
+ radiobase="${modbase}/radio" | |
+ $radiobase/radio-channel-service.sh \ | |
+ "${ircuser}" "${radiobase}" "${ircbase}" "${server}" "${channe… | |
esac | |
ls "${serverbase}/${channel}/out" \ | |
diff --git a/annna-message-radio b/annna-message-radio | |
@@ -13,20 +13,17 @@ text="$4" | |
[ "$user" = "${ircuser}" ] && exit | |
case "${text}" in | |
-"${ircuser}, next please.") | |
- /br/bin/bitreich-radio-playlist-next | |
- annna-say -s "${server}" -c "${channel}" "You are very kind ${user}. T… | |
+"${ircuser}, next song please.") | |
+ /usr/bin/mpc -q next | |
exit # no common messages | |
;; | |
-"${ircuser}, please mark this.") | |
- songtitle="$(/br/bin/bitreich-radio-playlist-mark)" | |
- annna-say -s "${server}" -c "${channel}" "${user}, I have marked \"${s… | |
- exit | |
+"${ircuser}, please shuffle.") | |
+ /usr/bin/mpc -q shuffle | |
+ exit # no common messages | |
;; | |
-"${ircuser}, please help.") | |
- annna-say -s "${server}" -c "${user}" "»next please.« gets the playl… | |
- annna-say -s "${server}" -c "${user}" "»please help.« gives you this… | |
- # Fall back to annna-message-common help message. | |
+"${ircuser}, please toggle random.") | |
+ /usr/bin/mpc -q random | |
+ exit # no common messages | |
;; | |
esac | |
diff --git a/annna-stop-services b/annna-stop-services | |
@@ -3,4 +3,5 @@ | |
pkill -f "entr tail -n 1 /home/annna/irc.*" | |
pkill -f "annna-channel-service" | |
pkill -f "idlerpg-channel-service.py" | |
+pkill -f "radio-channel-service.sh" | |
diff --git a/modules/radio/radio-channel-service.sh b/modules/radio/radio-chann… | |
@@ -0,0 +1,29 @@ | |
+#!/bin/sh | |
+ | |
+export PATH="/home/annna/bin:$PATH" | |
+ | |
+ircuser="$1" | |
+radiobase="$2" | |
+ircbase="$3" | |
+server="$4" | |
+channel="$5" | |
+ | |
+# Wait for mpd to be alive. | |
+while /bin/true; | |
+do | |
+ while ! mpc -q; | |
+ do | |
+ sleep 5 | |
+ done | |
+ | |
+ while mpc -q; | |
+ do | |
+ currentsong="$(mpc current --wait)" | |
+ if [ -n "${currentsong}" ]; | |
+ then | |
+ annna-say -s "${server}" -c "${channel}" "Now playing:… | |
+ fi | |
+ done | |
+ sleep 5 | |
+done | |
+ |