This commit is contained in:
Ben Harris 2018-10-23 09:44:45 -04:00
commit fe38f96235
3 changed files with 47 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# radiobot
super simple bot
it:
* responds to pings
* sends a message to #tilderadio when `$now_playing_file` changes

7
bot.properties Normal file
View File

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

33
bot.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
. bot.properties
input=".bot.cfg"
now_playing=$(cat $now_playing_file)
echo "Starting session: $(date "+[%y:%m:%d %T]")">$log
echo "NICK $nick" > $input
echo "USER $user" >> $input
echo "JOIN #$channel" >> $input
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 != $(cat $now_playing_file)]; then
now_playing=$(cat $now_playing_file)
echo "PRIVMSG #tilderadio :Now Playing on tilderadio: $now_playing" >> $input
fi
# do things when you see output
case "$res" in
# respond to ping requests from the server
PING*)
echo "$res" | sed "s/I/O/" >> $input
;;
# else
*)
echo "$res"
;;
esac
done