From 48abda2dd07cb8379996d0046bd99fdbb9dbd29d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 6 Jul 2018 10:31:08 +0200 Subject: bin/wtp new to query package database --- bin/ii-answer | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'bin/ii-answer') diff --git a/bin/ii-answer b/bin/ii-answer index 8bbdbb1..0fa032c 100755 --- a/bin/ii-answer +++ b/bin/ii-answer @@ -93,6 +93,31 @@ find "${irc_dir}" \ irc_say "${channel}" 'copy' done fi + # answer "wtp?" + regex='^\S\+ <\(\S\+\)> '"${prefix}"'!\?wtp ' + if grep -q "${regex}" "${out_file}"; then + sed -i ' + s/'"${regex}"'/\1 / + T + w /dev/stdout + d + ' "${out_file}" | \ + while read -r asker line; do + reason=$("${base_dir}/bin/wtp" "${line}"); + if [ -z "${reason}" ]; then + reason="No, we don't have that." + fi + reason="${asker}: ${reason}" + if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then + echo "${reason}" + else + echo "${reason}" | \ + head -n5 + printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)" + fi | \ + irc_say "${channel}" 'copy' + done + fi # answer "What's up?" regex='^\S\+ <\S\+> .*[Ww]hat'"'"'\?s *[Uu]p' if grep "${regex}" "${out_file}" | \ -- cgit v1.2.3-70-g09d2