add now playing to announcements

This commit is contained in:
Ben Harris 2019-07-10 01:01:28 -04:00
parent 97468cd6a2
commit 7e856523fa
Signed by: ben
GPG Key ID: 4E0AF802FFF7960C
2 changed files with 17 additions and 11 deletions

25
bot.sh
View File

@ -2,7 +2,7 @@
. bot.properties
input=".bot.cfg"
echo "Starting session: $(date "+[%y:%m:%d %T]")">$log
echo "Starting session: $(date "+[%y:%m:%d %T]")" > $log
echo "NICK $nick" > $input
echo "USER $nick 0 * :$nick" >> $input
echo "MODE $nick +B" >> $input
@ -20,7 +20,7 @@ function msg {
echo "PRIVMSG ${1} :${2}" >> $input
}
# save info
# save info on startup
save_info
dj=$(parse_dj)
@ -30,20 +30,29 @@ do
# log the session
echo "$(date "+[%y:%m:%d %T]")$res" >> $log
# now playing
if [[ $now_playing != "$(<$npfile)" ]]; then
save_info
[[ ! -z "${dj}" ]] && echo -e "PRIVMSG #$channel :\x0303$now_playing" >> $input
fi
# new dj!
if [[ $dj != $(parse_dj) ]]; then
dj=$(parse_dj)
if [[ ! -z "${dj}" ]]; then
for chan in $notify_channels; do
msg "#$chan" "$dj is now online! tune in now here: $link"
msg "#$chan" "$dj is now online playing $now_playing! tune in now here: $link"
done
while read -u 10 subscriber; do
msg $subscriber "$dj is now online! tune in now here: $link"
msg $subscriber "$dj is now online playing $now_playing! tune in now here: $link"
done 10< subscribers.txt
while read -u 11 subscriber email_addr; do
sed -e "s/<dj>/$dj/g" -e "s|<link>|$link|g" dj-online-email.tmpl \
sed -e "s/<dj>/$dj/g" \
-e "s|<link>|$link|g" \
-e "s/<now_playing>/$now_playing/g" \
-e "s/<email_addr>/$email_addr/g" dj-online-email.tmpl \
| sendmail $email_addr
done 11< email-subscribers.txt
@ -53,12 +62,6 @@ do
fi
fi
# now playing
if [[ $now_playing != "$(<$npfile)" ]]; then
save_info
[[ ! -z "${dj}" ]] && echo -e "PRIVMSG #$channel :\x0303$now_playing" >> $input
fi
# do things when you see output
case "$res" in
# respond to ping requests from the server

View File

@ -1,8 +1,11 @@
From: radiobot <radiobot@tilde.chat>
To: <email_addr>
Subject: tilderadio: dj <dj> is now streaming!
<dj> just came on the air on tilderadio.org!
now playing: <now_playing>
have a listen here: <link>
~radiobot