Make radio commands easier, add preliminary like/unlike function. - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit b70eafe6f2101a83d81af91fad38da70b5cd065d
DIR parent e8c5f18ae31193b0f830133c3503446179e96a29
HTML Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Wed, 11 Feb 2026 20:03:57 +0100
Make radio commands easier, add preliminary like/unlike function.
Diffstat:
M annna-message-radio | 41 ++++++++++++++++++++-----------
M modules/radio/radio-random-channel… | 12 +++++-------
2 files changed, 32 insertions(+), 21 deletions(-)
---
DIR diff --git a/annna-message-radio b/annna-message-radio
@@ -3,35 +3,35 @@
[ "$IRC_CMD_USER" = "${IRC_USER}" ] && exit
case "${IRC_PRIVMSG_TEXT}" in
-"${IRC_USER}, next please"*) /usr/bin/mpc -q next; exit;;
-"${IRC_USER}, prev please"*) /usr/bin/mpc -q prev; exit;;
-"${IRC_USER}, please shuffle"*) /usr/bin/mpc -q shuffle; exit;;
-"${IRC_USER}, please toggle random"*) /usr/bin/mpc -q random; exit;;
-"${IRC_USER}, please toggle single"*) /usr/bin/mpc -q single; exit;;
-"${IRC_USER}, please toggle consume"*) /usr/bin/mpc -q consume; exit;;
-"${IRC_USER}, please rescan"*) /usr/bin/mpc -q rescan; exit;;
-"${IRC_USER}, please change channel"*) /home/annna/bin/modules/radio/radio-random-channel-cronjob.sh; exit;;
+"${IRC_USER}, next"*) /usr/bin/mpc -q next; exit;;
+"${IRC_USER}, prev"*) /usr/bin/mpc -q prev; exit;;
+"${IRC_USER}, shuffle"*) /usr/bin/mpc -q shuffle; exit;;
+"${IRC_USER}, random radio"*) /home/annna/bin/modules/radio/radio-random-channel-cronjob.sh; exit;;
+"${IRC_USER}, random mode"*) /usr/bin/mpc -q random; exit;;
+"${IRC_USER}, single mode"*) /usr/bin/mpc -q single; exit;;
+"${IRC_USER}, consume mode"*) /usr/bin/mpc -q consume; exit;;
+"${IRC_USER}, rescan"*) /usr/bin/mpc -q rescan; exit;;
"${IRC_USER}, how many people listen to the radio"*) annna-say "${IRC_CMD_USER}, $(/br/bin/bitreich-radio-listener-count)"; exit;;
-"${IRC_USER}, how long is the playlist"*) annna-say "${IRC_CMD_USER}, $(mpc playlist | wc -l)"; exit;;
+"${IRC_USER}, playlist"*) annna-say "${IRC_CMD_USER}, $(mpc playlist | wc -l)"; exit;;
"${IRC_USER}, what is playing"*)
currentsong="$(mpc current 2>/dev/null)"
[ -n "${currentsong}" ] && annna-say "Now playing: ${currentsong}"
exit;;
-"${IRC_USER}, please radio play "*)
+"${IRC_USER}, radio play "*)
url="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 25- | sed 's,\t, ,g')"
{
ytdl-mpd -a -m -q "$url"
annna-say "Your download ${url} is done."
} &
exit;;
-"${IRC_USER}, please radio say "*)
+"${IRC_USER}, radio say "*)
word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 25- | sed 's,\t, ,g')"
{
printf "%s\n" "${word}" | bitreich-radio-speak
annna-say "The speech is done."
} &
exit;;
-"${IRC_USER}, please stop speaking on radio"*)
+"${IRC_USER}, stop speaking on radio"*)
if pkill -f bitreich-radio-speak >/dev/null 2>&1;
then
annna-say "${IRC_CMD_USER}, I stopped speaking."
@@ -39,11 +39,24 @@ case "${IRC_PRIVMSG_TEXT}" in
annna-say "${IRC_CMD_USER}, sorry, no instances found."
fi
exit;;
-"${IRC_USER}, please radio status"*)
- mpc_status="$(/usr/bin/mpc status | grep '\[.*\]' -o | tr -d '[]')"
+"${IRC_USER}, radio status"*)
+ mpc_status="$(/usr/bin/mpc status "%state%")"
[ -z "$mpc_status" ] && mpc_status="gone"
annna-say "The radio is ${mpc_status}."
exit;;
+"${IRC_USER}, like"*|"${IRC_USER}, unlike"*)
+ # TODO: Make sticker db work.
+ currenturi="$(/usr/bin/mpc -f "%file%" current)"
+ if [ -n "${currenturi}" ];
+ then
+ likes="$(/usr/bin/mpc sticker "${currenturi}" get likes)"
+ case "${IRC_PRIVMSG_TEXT}" in
+ "${IRC_USER}, like"*) newlikes="$(( ${likes} + 1 ))";;
+ "${IRC_USER}, unlike"*) newlikes="$(( ${likes} - 1 ))";;
+ esac
+ /usr/bin/mpc -q sticker "${currenturi}" set likes "${newlikes}"
+ annna-say "${currenturi} = ${likes} <3"
+ fi;;
esac
annna-message-common
DIR diff --git a/modules/radio/radio-random-channel-cronjob.sh b/modules/radio/radio-random-channel-cronjob.sh
@@ -5,16 +5,14 @@ randomuri="$(curl -s -k gophers://bitreich.org/1/radio/lawn/random \
| cut -f 2 \
| cut -d':' -f 2-)"
-# Be sure mpc is playing.
mpc play >/dev/null 2>&1
-# We randomly shuffle around in the playlist.
+mpc shuffle >/dev/null 2>&1
mpc random on >/dev/null 2>&1
-# If the cronjob does not work, keep on repeating.
mpc repeat on >/dev/null 2>&1
-# Do not remove off the playlist.
mpc consume off >/dev/null 2>&1
-# Add the new radio station.
-printf "%s\n" "${randomuri}" | mpc add >/dev/null 2>&1
-# Go to the next random station.
+mpc single off >/dev/null 2>&1
+mpc crossfade 5 >/dev/null 2>&1
+mpc replaygain track >/dev/null 2>&1
+printf "%s\n" "${randomuri}" | mpc insert >/dev/null 2>&1
mpc next >/dev/null 2>&1