diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..208c2fb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +toot.json +log.txt +.bot.cfg + diff --git a/bot.sh b/bot.sh index 41874ba..d2a6638 100644 --- a/bot.sh +++ b/bot.sh @@ -3,11 +3,16 @@ . bot.properties input=".bot.cfg" now_playing=$(<$now_playing_file) +dj=$(parse_dj) echo "Starting session: $(date "+[%y:%m:%d %T]")">$log echo "NICK $nick" > $input echo "USER $user" >> $input echo "JOIN #$channel" >> $input +function parse_dj { + echo $now_playing | grep -Eo '^\([^)]*\)' | sed 's/[()]//g' +} + tail -f $input | telnet $server $port | while read res do # log the session @@ -19,6 +24,13 @@ do echo "PRIVMSG #tilderadio :$now_playing" >> $input fi + if [[ $dj != $(parse_dj) ]]; then + [ -z ${dj+x} ] && continue + 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!" + fi + # do things when you see output case "$res" in # respond to ping requests from the server diff --git a/toot.json.sample b/toot.json.sample new file mode 100644 index 0000000..07bac57 --- /dev/null +++ b/toot.json.sample @@ -0,0 +1,7 @@ +{ + "client_id": "", + "client_secret": "", + "access_token": "", + "base_url": "https://tilde.zone" +} +