summaryrefslogtreecommitdiff
path: root/hack_of_all_hacks
diff options
context:
space:
mode:
authorJoseph Graham <joseph@fibreglass.tunachunks>2013-07-28 12:28:55 +0100
committerJoseph Graham <joseph@fibreglass.tunachunks>2013-07-28 12:28:55 +0100
commit012a3442a330684bbb7fbcf4b49cdd00912d2da9 (patch)
treed87cf01675e850d3f44e5d5826bd12b5335bb830 /hack_of_all_hacks
parent27270d542bdfabe28414be233ff2797db6c5c59f (diff)
Added a phrase remembering feature
Diffstat (limited to 'hack_of_all_hacks')
-rw-r--r--hack_of_all_hacks58
1 files changed, 50 insertions, 8 deletions
diff --git a/hack_of_all_hacks b/hack_of_all_hacks
index d44d177..dbc23c0 100644
--- a/hack_of_all_hacks
+++ b/hack_of_all_hacks
@@ -168,12 +168,17 @@ EOF
shopt -s extglob
+ # We want to get only the message part of the line
+ sentence="${line#* }"
+ sentence="${sentence#* }"
+ sentence="${sentence#* :}"
+
# This one depends on the previous to record the last time the person
# was seen and create the `the_time_now' var.
- case "${line}" in
- *"pbot: when did you last see"* )
- subject="${line##*pbot: when did you last see }"
- subject="${subject##*pbot: when did you last see: }" # If there's an `:', we can still handle it.
+ case "${sentence}" in
+ "pbot: when did you last see"* )
+ subject="${sentence##pbot: when did you last see }"
+ subject="${subject##pbot: when did you last see: }" # If there's an `:', we can still handle it.
subject="${subject%?}"
subject="${subject%% *}"
if [[ -f announcements/people/${subject}/seen ]]
@@ -206,20 +211,57 @@ EOF
send_msg "${channel_it_came_from}" "I never saw ${subject} speak."
fi
;;
- *"pbot: tell "+([[:alnum:]])":"* )
+ "pbot: tell "+([![:space:]])":"+([![:space:]]) )
# The line will be something such as:
# pbot: tell fauno: you suck
- process="${line##*pbot: tell }"
+ process="${sentence##pbot: tell }"
subject="${process%%:*}"
message="${process#*:}"
message="${message# }"
+ [[ -d "announcements/people/${subject}" ]] || mkdir -p "announcements/people/${subject}"
echo "${personoslash} told me to tell you: ${message}" >> "announcements/people/${subject}/messages"
response=$(shuf -e 'certainly' 'I will do' 'OK' | head -1)
send_msg "${channel_it_came_from}" "${personoslash}: ${response}"
;;
- *pbot:* )
+ "pbot: "+([![:space:]])" is "+([![:space:]]) )
+ thing="${sentence#pbot: }"
+ thing="${thing%% is *}"
+ is="${sentence#* is }"
+
+ echo "${is}" >> "info/${thing}"
+ send_msg "${channel_it_came_from}" "${personoslash}: Remembered."
+ ;;
+ "pbot: "+([![:space:]])" isn't "+([![:space:]]) )
+ thing="${sentence#pbot: }"
+ thing="${thing%% isn\'t *}"
+ isnt="${sentence#* isn\'t }"
+
+ if grep "${isnt}" "info/${thing}"
+ then
+ grep -v "${isnt}" "info/${thing}" | sponge "info/${thing}"
+ send_msg "${channel_it_came_from}" "${personoslash}: OK, entry removed."
+ else
+ send_msg "${channel_it_came_from}" "${personoslash}: I know."
+ fi
+ ;;
+ ','+([![:space:]]) )
+ thing="${sentence#,}"
+
+ if [[ -f "info/${thing}" ]]
+ then
+ # For the first entry we will say like: `thing is: '
+ first="${thing} is: "
+ uniq "info/${thing}" |
+ while read line
+ do
+ send_msg "${channel_it_came_from}" "${first}${line}"
+ first=''
+ done
+ fi
+ ;;
+ pbot:* )
while read line
do
send_msg "${channel_it_came_from}" "${line}"
@@ -232,7 +274,7 @@ EOF
esac
# TODO: add a birthday announcement feature, cointoss feature, timer
- # feature, store phrase feature.
+ # feature.
#########
# Tests #