forked from tilderadio/radiobot
init
This commit is contained in:
commit
fe38f96235
|
@ -0,0 +1,7 @@
|
|||
# radiobot
|
||||
|
||||
super simple bot
|
||||
|
||||
it:
|
||||
* responds to pings
|
||||
* sends a message to #tilderadio when `$now_playing_file` changes
|
|
@ -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"
|
|
@ -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
|
Loading…
Reference in New Issue