From 7e856523fa6f979ba45427afd8b48cc7f7d0f4f6 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 10 Jul 2019 01:01:28 -0400 Subject: [PATCH] add now playing to announcements --- bot.sh | 25 ++++++++++++++----------- dj-online-email.tmpl | 3 +++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/bot.sh b/bot.sh index 28c43bb..06bedae 100644 --- a/bot.sh +++ b/bot.sh @@ -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/g" -e "s||$link|g" dj-online-email.tmpl \ + sed -e "s//$dj/g" \ + -e "s||$link|g" \ + -e "s//$now_playing/g" \ + -e "s//$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 diff --git a/dj-online-email.tmpl b/dj-online-email.tmpl index 2cd5cec..bb3f675 100644 --- a/dj-online-email.tmpl +++ b/dj-online-email.tmpl @@ -1,8 +1,11 @@ From: radiobot +To: Subject: tilderadio: dj is now streaming! just came on the air on tilderadio.org! +now playing: + have a listen here: ~radiobot