stormbot/modules/reminder/reminder.sh

27 lines
661 B
Bash
Raw Normal View History

2016-09-13 19:39:22 -04:00
[ -f functions.sh ] && source functions.sh
userNick="$1"
shift
chan="$1"
shift
time="$1"
shift
if ! [[ "$time" =~ ^[0-9]+[HhMmSs]$ ]]; then
time="${time}s"
fi
if ! [[ "${time%[HhMmSs]}" =~ ^[0-9]+$ ]]; then
2016-09-13 19:39:22 -04:00
reminderMessage="Times must be numeric (seconds)."
msg "$chan" "$userNick: $reminderMessage"
2016-09-13 19:39:22 -04:00
else
msg "$chan" "ok, $userNick, reminder in $time."
reminderMessage="$@"
if [[ "$reminderMessage" =~ ^[Tt]ell* ]]; then
userNick="$(echo "${reminderMessage#[T|t]ell }" | cut -d ' ' -f1)"
reminderMessage="${reminderMessage#[Tt]ell }"
reminderMessage="${reminderMessage#* }"
fi
sleep $time && msg "$chan" "$userNick: $reminderMessage"&
2016-09-13 19:39:22 -04:00
fi