summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2018-09-09 12:04:02 +0000
committerbill-auger <mr.j.spam.me@gmail.com>2018-10-02 19:02:24 -0400
commit1a05f98b33d11f9fe64eae4e51306a5fd2b34539 (patch)
treecffd906cc599b0f56ef2fb277973574b10ba8a44
parentca99c6d84aefd0303e920c62b3aeb74a5421c4b4 (diff)
refactor help messages into flat files
-rw-r--r--modules/m_translate.help.inc4
-rw-r--r--process_event67
-rw-r--r--process_event.help.inc17
3 files changed, 33 insertions, 55 deletions
diff --git a/modules/m_translate.help.inc b/modules/m_translate.help.inc
new file mode 100644
index 0000000..ea65177
--- /dev/null
+++ b/modules/m_translate.help.inc
@@ -0,0 +1,4 @@
+translate "Hello, Pedro" to spanish:
+ _BOT_NICK_: translate Hello, Pedro
+translate Pedro's chat from spanish to english:
+ _BOT_NICK_: translate Pedro
diff --git a/process_event b/process_event
index 413495a..494ddcd 100644
--- a/process_event
+++ b/process_event
@@ -439,73 +439,30 @@ function process_event
${my_own_name}:* | ','* )
local module
+ local modules_help=''
+ local help_msg_line
+
for module in ${config_modules}
do case ${module} in
'translate' )
[[ "${sentence}" =~ ^"${my_own_name}: translate " ]] && return 0
+
+ modules_help="${modules_help} modules/m_translate.help.inc"
;;
esac
done
- while read line
+ while IFS='' read help_msg_line
do
- send_msg "${personoslash}" "${line}"
- done <<< cat << EOF
-Command not recognised. Example commands:
-${my_own_name}: tell Jack: hi Jack
-${my_own_name}: when did you last see Jill?
-${my_own_name}: lemon is yummy
-${my_own_name}: lemon isn't yummy
-,lemon
-EOF
- for module in ${config_modules}
- do case ${module} in
- 'translate')
- send_msg "${personoslash}" 'translate "Hello, Pedro" to spanish:'
- send_msg "${personoslash}" " ${my_own_name}: translate Hello, Pedro"
- send_msg "${personoslash}" "translate Pedro's chat from spanish to english:"
- send_msg "${personoslash}" " ${my_own_name}: translate Pedro"
- ;;
- esac
- done
+ help_msg_line=$(sed "s|_BOT_NICK_|${my_own_name}|" <<< ${help_msg_line})
+ send_msg "${personoslash}" "${help_msg_line}" ; sleep 1 ;
+ done < <(cat process_event.help.inc ${modules_help})
;;
esac
-# ' this comment fixes a bug in emacs shell-script-mode that messes up the syntax highlighting
-
- # I'm dissabling this feature for now as it was being abused
- # and would need an overhaul to be abuse-proof + nobody uses it afaik
- # ##########################
- # # tell someone something #
- # ##########################
-
- # # TODO: this should be in the case statement
-
- # if [[ "${sentence}" =~ ${my_own_name}: tell\ [^\ ]+\ about\ [^\ ]+ ]]
- # then
- # # TODO: There should be the following three constraints to
- # # prevent abuse.
- # # 1. People may only ask the bot to tell someone about
- # # something in the #parabola channel, not by query.
- # # 2. pbot will only tell someone something if they're a user
- # # he has seen in the past week
- # # 3. each person may use tell no more than 10 times in
- # # three hours.
-
- # gotit="${BASH_REMATCH}" # will be like: `,tell jack about blah'
-
- # dudep1="${gotit#,tell }"
- # dude="${dudep1%% *}"
- # thing="${gotit##* }"
-
- # if [[ -n "${dude}" ]] && [[ -n "${thing}" ]]
- # then
- # tell_fact "${thing}" "${dude}" || send_msg "${channel_it_came_from}" "${personoslash}: Error, failed to tell ${dude} about ${thing}"
- # fi
- # fi
-
- # TODO: add a birthday announcement feature, cointoss feature, timer
- # feature.
+
+ # TODO: add a birthday announcement feature, cointoss feature, timer feature.
+
#########
# Tests #
diff --git a/process_event.help.inc b/process_event.help.inc
new file mode 100644
index 0000000..9a27cc4
--- /dev/null
+++ b/process_event.help.inc
@@ -0,0 +1,17 @@
+Command not recognised. Example commands:
+leave a memo for Jack:
+ _BOT_NICK_: tell Jack: hi Jack
+tell the last time Jill chatted:
+ _BOT_NICK_: when did you last see Jill?
+remember a factoid named lemon:
+ _BOT_NICK_: lemon is yummy
+forget the "yummy" lemon factoid:
+ _BOT_NICK_: lemon isn't yummy
+tell about the lemon factoid:
+ _BOT_NICK_: what is lemon
+ ,lemon
+list known factoids:
+ ,
+ ,list
+ ,factoids
+ _BOT_NICK_: list factoids