index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/ii-answer | 29 |
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 |