diff options
author | Erich Eckner <git@eckner.net> | 2018-06-28 13:52:56 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-06-28 13:52:56 +0200 |
commit | d749b217cbce706aca19a16a5a93f0e2f670bd3c (patch) | |
tree | 16abe2151b6840abe83e1b85fbc10c7a93574e08 /bin | |
parent | 97b4c81b374610948dab596acef5639264cee1cf (diff) | |
download | builder-d749b217cbce706aca19a16a5a93f0e2f670bd3c.tar.xz |
bin/ii-answer: address the asker
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ii-answer | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/bin/ii-answer b/bin/ii-answer index 3f6f94e..0a3468d 100755 --- a/bin/ii-answer +++ b/bin/ii-answer @@ -42,18 +42,21 @@ find "${irc_dir}" \ sloppy_salutation='' fi # answer "why don't you?" - regex='^\S\+ <\S\+> '"${prefix}"'!\?why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) ' + regex='^\S\+ <\(\S\+\)> '"${prefix}"'!\?why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) ' if grep -q "${regex}" "${out_file}"; then sed -i ' - s/'"${regex}"'/\1 / + s/'"${regex}"'/\1 \2 / T w /dev/stdout d ' "${out_file}" | \ - while read -r line; do + while read -r asker line; do reason=$( echo "${line}" | \ - xargs "${base_dir}/bin/why-dont-you" 2>&1 + xargs "${base_dir}/bin/why-dont-you" 2>&1 | \ + sed ' + 1 s/^/'"${asker}"': / + ' ) if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then echo "${reason}" @@ -66,19 +69,20 @@ find "${irc_dir}" \ done fi # answer "wtf?" - regex='^\S\+ <\S\+> '"${prefix}"'!\?wtf ' + regex='^\S\+ <\(\S\+\)> '"${prefix}"'!\?wtf ' if grep -q "${regex}" "${out_file}"; then sed -i ' - s/'"${regex}"'// + s/'"${regex}"'/\1 / T w /dev/stdout d ' "${out_file}" | \ - while read -r line; do + while read -r asker line; do reason=$("${base_dir}/bin/wtf" "${line}"); if [ -z "${reason}" ]; then reason="Huh, I don't know that one." fi + reason="${asker}: ${reason}" if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then echo "${reason}" else @@ -106,11 +110,16 @@ find "${irc_dir}" \ irc_say "${channel}" 'copy' fi # answer "Thanks!" - regex='^\S\+ <\S\+> \(.* \)\?[Tt]h\(anks\|x\)\([ ,.!]\|$\)' + regex='^\S\+ <\(\S\+\)> \(.* \)\?[Tt]h\(anks\|x\)\([ ,.!].*\)\?$' if grep "${regex}" "${out_file}" | \ grep -q "${sloppy_salutation}"; then - sed -i "/${regex}/d" "${out_file}" - printf 'np\n' | \ + sed -i ' + s/'"${regex}"'/np, \1/ + T + w /dev/stdout + d + ' "${out_file}" | \ + sort -u | \ irc_say "${channel}" 'copy' fi if [ -z "${channel%%#*}" ]; then |