summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2018-09-13 06:55:00 +0000
committerbill-auger <mr.j.spam.me@gmail.com>2018-10-02 19:02:25 -0400
commitdf72b0ecd56396e9acc3bb23f661cc7c4deb78be (patch)
treeb08cadb8eda349b6c08fa1ce5479ca1145dbf281
parentd741c6c8831fc44e89e8158d10f01ddbd1c951b8 (diff)
process PRIVMSG hooks before 'process_event' triggers
-rw-r--r--bot_settings.sh2
-rw-r--r--lib/main.sh25
-rw-r--r--process_event3
3 files changed, 14 insertions, 16 deletions
diff --git a/bot_settings.sh b/bot_settings.sh
index fbd5e6c..85d33ab 100644
--- a/bot_settings.sh
+++ b/bot_settings.sh
@@ -120,7 +120,7 @@ config_commands_private_always=1
# 1 = Return error to sender.
# 2 = Pass them on to modules that may handle "generic" PRIVMSG.
# Note that non-commands always get passed on to "generic" PRIVMSG handling modules.
-config_feedback_unknown_commands=1
+config_feedback_unknown_commands=2
###########
diff --git a/lib/main.sh b/lib/main.sh
index 2e8fb26..4c11672 100644
--- a/lib/main.sh
+++ b/lib/main.sh
@@ -439,21 +439,6 @@ while true; do
query="${BASH_REMATCH[3]}"
# Check if there is a command.
commands_call_command "$sender" "$target" "$query"
-
- # What happens next is important
- config_update_time=-100
-
- time_n0w=$( date +%s )
-
- # If it's been more than a minute since we updated the config.
- if (( ( time_n0w - 60 ) > config_update_time ))
- then
- source process_event
- config_update_time=${time_n0w}
- fi
-
- process_event
-
# Check return code
case $? in
1)
@@ -467,12 +452,22 @@ while true; do
fi
;;
esac
+
+ was_handled=0 # TODO: refactor 'process_event' triggers into modules
for module in $modules_on_PRIVMSG; do
module_${module}_on_PRIVMSG "$sender" "$target" "$query"
if [[ $? -ne 0 ]]; then
+ was_handled=1 # TODO: refactor 'process_event' triggers into modules
break
fi
done
+
+ if ! (( ${was_handled} )) # TODO: refactor 'process_event' triggers into modules
+ then
+ (( $PROCESS_EVENT_SOURCED )) || source process_event
+ process_event
+ fi
+
elif [[ "$line" =~ ^:([^ ]*)\ +NOTICE\ +([^:]+)\ +:(.*) ]]; then
sender="${BASH_REMATCH[1]}"
target="${BASH_REMATCH[2]}"
diff --git a/process_event b/process_event
index 1526e1d..396982a 100644
--- a/process_event
+++ b/process_event
@@ -1,5 +1,8 @@
#! /bin/bash
+readonly PROCESS_EVENT_SOURCED=1
+
+
# This function reads tags of xml in the same way read normally reads lines.
function rdom
{