msg function

This commit is contained in:
Ben Harris 2019-05-20 12:47:23 -04:00
parent 06414697d2
commit 715a5ee540
2 changed files with 22 additions and 12 deletions

View File

@ -4,5 +4,6 @@ npfile="now_playing.txt"
channel="tilderadio"
notify_channels="meta team yourtilde $channel"
link="https://ttm.sh/listen"
schedule="https://tilderadio.org/schedule/"
nick="radiobot"
log="log.txt"

33
bot.sh
View File

@ -16,6 +16,10 @@ function parse_dj {
grep -Eo '^\([^)]*\)' $npfile | sed 's/[()]//g' | xargs
}
function msg {
echo "PRIVMSG ${1} :${2}" >> $input
}
# save info
save_info
dj=$(parse_dj)
@ -31,11 +35,11 @@ do
dj=$(parse_dj)
if [[ ! -z "${dj}" ]]; then
for chan in $notify_channels; do
echo "PRIVMSG #$chan :$dj is now online! tune in now here: $link" >> $input
msg "#$chan" "$dj is now online! tune in now here: $link"
done
while read -u 10 subscriber; do
echo "PRIVMSG $subscriber :$dj is now online! tune in now here: $link" >> $input
msg $subscriber "$dj is now online! tune in now here: $link"
done 10< subscribers.txt
for json in . ./yourtilde ./team; do
@ -85,44 +89,48 @@ do
case "$com" in
subscribe)
if grep -q $who subscribers.txt; then
echo "PRIVMSG $from :you're already subscribed! :)" >> $input
msg $from "you're already subscribed! :)"
else
echo $who >> subscribers.txt
echo "PRIVMSG $from :i'll send you a direct message when a dj starts streaming!" >> $input
msg $from "i'll send you a direct message when a dj starts streaming!"
fi
;;
unsubscribe)
sed -i "/$who/d" subscribers.txt
echo "PRIVMSG $from :i'll stop sending you updates." >> $input
msg $from "i'll stop sending you updates."
;;
time)
echo "PRIVMSG $from :$(TZ=UTC date)" >> $input
msg $from "$(TZ=UTC date)"
;;
np)
echo "PRIVMSG $from :$now_playing" >> $input
msg $from "$now_playing"
;;
dj)
echo "PRIVMSG $from :${dj:-"no one"} is on the air now" >> $input
msg $from "${dj:-"no one"} is on the air now"
;;
link)
echo "PRIVMSG $from :$link" >> $input
msg $from "$link"
;;
schedule)
msg $from "$schedule"
;;
help)
echo "PRIVMSG $from :hey hi, my commands are subscribe, unsubscribe, np, dj, link, radio" >> $input
msg $from "hey hi, my commands are subscribe, unsubscribe, np, dj, link, slogan, and schedule"
;;
radio|slogan)
echo "PRIVMSG $from :$(curl -s https://ben.ttm.sh/slogans.txt | shuf -n1)" >> $input
msg $from "$(curl -s https://ben.ttm.sh/slogans.txt | shuf -n1)"
;;
paymybills)
echo "PRIVMSG $from :whaddya mean?! i'm broker than you!" >> $input
msg $from "whaddya mean?! i'm broker than you!"
;;
*)
@ -138,3 +146,4 @@ do
;;
esac
done