diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-10-02 18:42:09 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-10-02 19:05:30 -0400 |
commit | d955de148bbda4456746536b9196af7e3314b789 (patch) | |
tree | 1de83771873e8e91753359b096970e3a15c82357 | |
parent | 7bfbc120845cf679cf9aeb57efb9f90596bdbb42 (diff) |
ignore predictable spambot nicks in spamfilter module
-rw-r--r-- | modules/m_spamfilter.sh | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/modules/m_spamfilter.sh b/modules/m_spamfilter.sh index 0c3b21b..6f6253e 100644 --- a/modules/m_spamfilter.sh +++ b/modules/m_spamfilter.sh @@ -156,10 +156,11 @@ module_spamfilter_on_PART() module_spamfilter_on_PRIVMSG() # (hostmask , target , query) { - local sender - local hostmask=$1 ; parse_hostmask_nick "${hostmask}" 'sender' ; + local hostmask=$1 local target=$2 local query=$3 + local sender ; parse_hostmask_nick "${hostmask}" 'sender' ; + local ident ; parse_hostmask_ident "${hostmask}" 'ident' ; local was_handled DBG_SPAMFILTER_CRITERIA @@ -187,11 +188,14 @@ DBG_SPAMFILTER # handle otherwise legitimate chat from unregistered users else # greet unregistered users (remind them to read THROTTLED_MSG) - is_noob ${sender} && (( ${NOOB_MSG_DELAY_SECS} > 0 )) && \ - send_ipc_msg ${NOOB_MSG_DELAY_SECS} "${NOOB_MSG_PREFIX}${sender}" + should_greet ${sender} && send_ipc_msg ${GREET_DELAY_SECS} "${GREET_PREFIX}${sender}" + + # ignore unregistered users with predictable spambot nicks + if is_spambot_nick "${sender}" "${ident}" + then was_handled=1 # throttle chat from unregistered users - if is_throttled ${sender} + elif is_throttled ${sender} then # notify unregistered users of the chat throttle send_msg "${sender}" "${THROTTLED_MSG}" @@ -290,6 +294,22 @@ is_noob() # (sender) [[ ! -f "${person_dir}/seen" ]] } +is_spambot_nick() # (sender , ident) +{ + local sender=$1 + local ident=$2 + + [[ "~${sender}" =~ ^${ident}[0-9A-Za-z]{2}$ ]] +} + +should_greet() # (sender , ident) +{ + local sender=$1 + local ident=$2 + + is_noob ${sender} && ! is_spambot_nick "${sender}" "${ident}" && (( ${GREET_DELAY_SECS} > 0 )) +} + is_throttled() # (sender) { (( ${THROTTLE_SECS} > 0 )) || return false @@ -343,7 +363,9 @@ DBG_SPAMFILTER_CRITERIA() ! is_shared_lib_error "${query}" ) && echo " => is not shared lib error - suppressing" && return ; is_spam "${query}" && echo " => is known spam - suppressing" && return ; echo 'n/a' ; - echo -n "${pad}4: " ; is_noob "${sender}" && echo -n " => is noob - greeting" ; + echo -n "${pad}4: " ; is_noob "${sender}" && echo -n " => is noob" ; + echo -n "${pad}4: " ; should_greet "${sender}" && echo -n " - greeting" ; + is_spambot_nick "${sender}" "${ident}" && echo " => is spambot nick - suppressing" && return ; is_throttled "${sender}" && echo " => is throttled - suppressing" || echo 'OK' ; # restore "last seen" state |