diff options
author | Joseph Graham <joseph@fibreglass.tunachunks> | 2014-05-24 18:03:27 +0100 |
---|---|---|
committer | Joseph Graham <joseph@fibreglass.tunachunks> | 2014-05-24 18:03:27 +0100 |
commit | f8fb6cc2fd8f046652978dc0748f567be7dcd5fe (patch) | |
tree | 1f8461afdb2bda24ae84f6ceab1a21d0ee377a3f | |
parent | 43a5c1e0c16c241a3db26a57bb983f1fc4c35a33 (diff) |
Added a "footnotes" feature. Seems to work OK so far.
-rw-r--r-- | hack_of_all_hacks | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/hack_of_all_hacks b/hack_of_all_hacks index 345c81e..e5039e2 100644 --- a/hack_of_all_hacks +++ b/hack_of_all_hacks @@ -261,7 +261,7 @@ EOF send_msg "${channel_it_came_from}" "${personoslash}: ${response}" fi ;; - "${my_own_name}: "+([![:space:]])" is "+([![:space:]])* ) + "${my_own_name}: "+([!/])" is "+([![:space:]])* ) declare -l thing="${sentence#${my_own_name}: }" thing="${thing%% is *}" is="${sentence#* is }" @@ -274,7 +274,7 @@ EOF send_msg "${channel_it_came_from}" "${personoslash}: Remembered." fi ;; - "${my_own_name}: "+([![:space:]])" is: "+([![:space:]])* ) + "${my_own_name}: "+([!/])" is: "+([![:space:]])* ) declare -l thing="${sentence#${my_own_name}: }" thing="${thing%% is: *}" is="${sentence#* is: }" @@ -327,11 +327,41 @@ EOF ;; esac ;; - ','+([![:space:]]) ) + ','+([!/]) ) thing="${sentence#,}" tell_fact "${thing}" "${channel_it_came_from}" ;; + *\[[[:digit:]]\]* ) + ############# + # Footnotes # + ############# + declare -a fn + + while read -d $'\0' file + do + #if match = grep "${file##*/}[ ]\?\[[[:digit:]]\]" <<< "${sentence}" + filename="${file##*/}" + + declare -l lowersentence="${sentence}" + + if [[ "${lowersentence}" =~ ${filename}[\ ]?\[[[:digit:]]\] ]] + then + index="${BASH_REMATCH: -2:1}" + + fn[${index}]=$(head -1 "${file}") + fi + done < <(find info -print0) + + for (( n=0 ; n<50 ; n++ )) + do + str="${fn[${n}]}" + + [[ -z "${str}" ]] && continue + + send_msg "${channel_it_came_from}" "[${n}] ${str}" + done + ;; ${my_own_name}:* | ','* ) while read line do |