wow i'm dumb

This commit is contained in:
Ben Harris 2018-10-27 02:11:48 -04:00
parent 471c98fec8
commit 8f7bc9a396
2 changed files with 22 additions and 15 deletions

View File

@ -1,6 +1,6 @@
server="localhost"
port="6667"
now_playing_file="/home/ben/public_html/radio/now_playing.txt"
npfile="/home/ben/public_html/radio/now_playing.txt"
channel="tilderadio"
nick="radiobot"
user="radiobot tilderadio radiobot :radiobot"

35
bot.sh
View File

@ -7,31 +7,38 @@ echo "NICK $nick" > $input
echo "USER $user" >> $input
echo "JOIN #$channel" >> $input
function parse_dj {
echo $now_playing \
| grep -Eo '^\([^)]*\)' \
| sed 's/[()]//g' \
| xargs
function save_info {
now_playing=$(<$npfile)
}
now_playing=$(<$now_playing_file)
function parse_dj {
grep -Eo '^\([^)]*\)' $npfile | sed 's/[()]//g' | xargs
}
# save info
save_info
dj=$(parse_dj)
# main loop
tail -f $input | telnet $server $port | while read res
do
# log the session
echo "$(date "+[%y:%m:%d %T]")$res" >> $log
# now playing
if [[ $now_playing != "$(<$now_playing_file)" ]]; then
now_playing=$(<$now_playing_file)
echo -e "PRIVMSG #tilderadio :\x0303$now_playing" >> $input
# new dj!
if [[ $dj != $(parse_dj) ]]; then
dj=$(parse_dj)
if [[ ! -z "${dj}" ]]; then
echo "PRIVMSG #$channel :$dj is now online! tune in now here: https://bhh.sh/listen" >> $input
TOOT_JSON_PATH=. toot "dj $dj is now streaming live on https://tilderadio.org! tune in here: https://bhh.sh/listen"
fi
fi
if [[ $dj != $(parse_dj) ]] && [[ ! -z ${dj+x} ]]; then
dj=$(parse_dj)
echo "PRIVMSG #tilderadio :$dj is now online!" >> $input
TOOT_JSON_PATH=. toot "dj $dj is now streaming live at https://tilderadio.org!"
# now playing
if [[ $now_playing != "$(<$npfile)" ]]; then
save_info
echo -e "PRIVMSG #$channel :\x0303$now_playing" >> $input
fi
# do things when you see output