Reorganization to hopefully prevent git conflicts.
This commit is contained in:
@@ -4,8 +4,35 @@
|
||||
user=$1
|
||||
shift
|
||||
shift
|
||||
if [[ "$user" =~ $allowList ]]; then
|
||||
./modules/do/do.sh "$1" "#$channel" "does a magical gesture and turns into ${1}!"
|
||||
nick $1
|
||||
sed -i bot.cfg -e "s/nick=.*/nick=\"$1\"/"
|
||||
|
||||
newNick="$1"
|
||||
|
||||
# Validate that user is authorized
|
||||
if [[ ! "$user" =~ $allowList ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Validate IRC nickname format (RFC 2812)
|
||||
# Nicknames can contain: a-z A-Z 0-9 _ - [ ] { } \ | ^
|
||||
if [[ -z "$newNick" ]]; then
|
||||
msg "#$channel" "$user: Please provide a nickname."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [[ "$newNick" =~ ^[a-zA-Z0-9_\[\]\{\}\\|\^-]+$ ]]; then
|
||||
msg "#$channel" "$user: Invalid nickname format. Only alphanumeric and _-[]{}\\|^ allowed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ${#newNick} -gt 30 ]]; then
|
||||
msg "#$channel" "$user: Nickname too long (max 30 characters)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Change the nick
|
||||
./modules/do/do.sh "$newNick" "#$channel" "does a magical gesture and turns into ${newNick}!"
|
||||
nick "$newNick"
|
||||
|
||||
# Safely update config file - escape forward slashes for sed
|
||||
escapedNick="${newNick//\//\\/}"
|
||||
sed -i "s/^nick=.*/nick=\"${escapedNick}\"/" bot.cfg
|
||||
|
||||
Reference in New Issue
Block a user