marvvin

[archived] IRC bot
git clone https://hhvn.uk/marvvin
git clone git://hhvn.uk/marvvin
Log | Files | Refs | README | LICENSE

schedule (1076B)


      1 #!/bin/bash
      2 
      3 [ "$1" = "list" ] && {
      4 	prefix="PRIVMSG $CHANNEL "
      5 	echo "Scheduled in $CHANNEL:"
      6 	for msg in $(find schedule/$(echo "$CHANNEL" | sed 's~/~%~g' | tr '[:upper:]' '[:lower:]')/ -type f)
      7 	do
      8 		send "$prefix:$(sed '/^#/d' < $msg):$(grep '^#TIME' < $msg | awk '{$1="";print}')"
      9 		sleep 1
     10 	done
     11 	exit 1
     12 }
     13 
     14 echo "$NAME" | grep -E -- '^aldcor$|^n0a110w$|^haydenh$' >/dev/null || {
     15 	echo "Unauthorized, $NAME"
     16 	exit 1
     17 }
     18 
     19 [ "$1" = "help" ] || [ -z "$1" ] && echo "schedule [message] 'IN' [channels] 'AT' [time (dd/mm/yy hh:mm || \`date '+%d/%m/%y %H:%M'\`) (timezone is that of host; haydenh=GMT/BST)]" && exit 1
     20 
     21 message=$(echo "$@" | grep -o ".*IN" | sed 's/IN$//')
     22 chans=$(echo "$@" | grep -o "IN.*AT" | sed 's/^IN //;s/ AT$//')
     23 time=$(echo "$@" | grep -o "AT.*" | sed 's/^AT //')
     24 
     25 printf "m: $message\nc: $chans\nt: $time\n"
     26 chans=$(echo "$chans" | sed 's~/~%~g')
     27 
     28 for chan in $chans
     29 do
     30 	mkdir -p schedule/$chan
     31 	printf "#TIME: $time\n$message" > schedule/$chan/$(echo "$message" | tr -dc 'a-zA-Z_-') && echo "Scheduled $message for $(echo "$chan" | tr '%' '/')."
     32 done