A few updates, cleanup updated weather module.

This commit is contained in:
Storm Dragon
2025-10-24 17:14:52 -04:00
parent 221e14a85a
commit 3669e07a9a
43 changed files with 794 additions and 153 deletions

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
[ -f functions.sh ] && source functions.sh
userNick="$1"
@@ -7,20 +8,56 @@ shift
time="$1"
shift
# Validate time argument is provided
if [[ -z "$time" ]]; then
msg "$chan" "$userNick: Please provide a time (e.g., 30s, 5m, 1h)."
exit 0
fi
# Normalize time format
if ! [[ "$time" =~ ^[0-9]+[HhMmSs]$ ]]; then
time="${time}s"
fi
# Validate time is numeric
if ! [[ "${time%[HhMmSs]}" =~ ^[0-9]+$ ]]; then
reminderMessage="Times must be numeric (seconds)."
msg "$chan" "$userNick: $reminderMessage"
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"&
msg "$chan" "$userNick: Time must be numeric (e.g., 30s, 5m, 1h)."
exit 0
fi
# Validate time is reasonable (max 24 hours)
timeValue="${time%[HhMmSs]}"
timeUnit="${time: -1}"
case "${timeUnit,,}" in
h) maxTime=24; timeInSeconds=$((timeValue * 3600)) ;;
m) maxTime=1440; timeInSeconds=$((timeValue * 60)) ;;
s) maxTime=86400; timeInSeconds=$timeValue ;;
*) maxTime=86400; timeInSeconds=$timeValue ;;
esac
if [[ $timeValue -gt $maxTime ]]; then
msg "$chan" "$userNick: Maximum time is 24 hours."
exit 0
fi
# Validate reminder message is provided
if [[ -z "$*" ]]; then
msg "$chan" "$userNick: Please provide a reminder message."
exit 0
fi
msg "$chan" "ok, $userNick, reminder in $time."
reminderMessage="$@"
# Handle 'tell' syntax for targeting other users
if [[ "$reminderMessage" =~ ^[Tt]ell[[:space:]]+ ]]; then
targetNick="$(echo "${reminderMessage#[T|t]ell }" | cut -d ' ' -f1)"
# Validate nick doesn't contain invalid characters
if [[ "$targetNick" =~ ^[a-zA-Z0-9_\[\]\{\}\\|\`\^\-]+$ ]]; then
userNick="$targetNick"
reminderMessage="${reminderMessage#[Tt]ell }"
reminderMessage="${reminderMessage#* }"
fi
fi
sleep "$timeInSeconds" && msg "$chan" "$userNick: $reminderMessage" &