Attempt to cut down on spam from greet and bye triggers. Add ping/pong to help deal with flakey connections.?
This commit is contained in:
@@ -3,8 +3,28 @@
|
||||
|
||||
farewellsFile="triggers/bye/farewells.txt"
|
||||
|
||||
# Time tracking to prevent spam from flaky connections
|
||||
# Track last bye time for each user (in seconds since epoch)
|
||||
declare -A lastByeTime
|
||||
|
||||
# Only say bye if user hasn't been farewelled in the last hour (3600 seconds)
|
||||
currentTime=$(date +%s)
|
||||
userName="${1,,}"
|
||||
cooldownPeriod=3600
|
||||
|
||||
if [[ -n "${lastByeTime[$userName]}" ]]; then
|
||||
timeSinceLastBye=$((currentTime - lastByeTime[$userName]))
|
||||
if [[ $timeSinceLastBye -lt $cooldownPeriod ]]; then
|
||||
# User was farewelled recently, skip bye message
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update last bye time for this user
|
||||
lastByeTime[$userName]=$currentTime
|
||||
|
||||
# All names to match are completely lowercase.
|
||||
case "${1,,}" in
|
||||
case "$userName" in
|
||||
storm_dragon)
|
||||
msg "${2%% :*}" "NOOOOOOOOOO!!! $1: come back!!!"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user