diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-09-26 23:14:25 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-10-02 19:05:18 -0400 |
commit | 7bfbc120845cf679cf9aeb57efb9f90596bdbb42 (patch) | |
tree | 988a1cf113617245698630c1a7067b6d1fb3b2bc /lib | |
parent | 0726ca8903399c026bd9be8009e6742c145d911f (diff) |
throttle spam filter relay messages
Diffstat (limited to 'lib')
-rw-r--r-- | lib/main.sh | 2 | ||||
-rw-r--r-- | lib/send.sh | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lib/main.sh b/lib/main.sh index b51716a..ac28f05 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -334,7 +334,7 @@ debug_init log_info_stdout "Loading transport" source "${config_transport_dir}/${config_transport}.sh" -source "${config_transport_dir}/transport_plus_ipc.sh.inc" +source "${config_transport_dir}/transport_plus_ipc.sh.inc" # common transport_read_line() if [[ $? -ne 0 ]]; then log_fatal "Couldn't load transport. Couldn't load the file..." envbot_quit 2 diff --git a/lib/send.sh b/lib/send.sh index accdc5f..59f90df 100644 --- a/lib/send.sh +++ b/lib/send.sh @@ -179,10 +179,16 @@ send_quit() { send_ipc_msg() { - local delay_secs=$1 ; shift ; - local delivery_time=$(( $(date +%s) + ${delay_secs} )) - local message=$* - - echo "${delivery_time},${IPC_NOTICE_CHANNEL},${message}" >> "${IPC_STORE_FILE}" - sort -o "${IPC_STORE_FILE}" "${IPC_STORE_FILE}" + if [[ -z "${IPC_NOTICE_CHANNEL}" ]] + then echo '[SEND]: no target channel set in IPC_NOTICE_CHANNEL' + elif ! touch "${IPC_STORE_FILE}" 2> /dev/null + then echo "[SEND]: no such file set in IPC_STORE_FILE: '${IPC_STORE_FILE}'" + else + local delay_secs=$1 ; shift ; + local message=$* + local delivery_time=$(( $(date +%s) + ${delay_secs} )) + + echo "${delivery_time} ${IPC_NOTICE_CHANNEL} ${message}" >> "${IPC_STORE_FILE}" + sort -o "${IPC_STORE_FILE}" "${IPC_STORE_FILE}" + fi } |