index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2019-01-10 18:04:51 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-01-10 18:04:51 +0100 |
commit | b0e5814f1fece32f6d42e6cb0b88bdb68fe5368a (patch) | |
tree | 1eff55a3afce606848ec0f1bf3d40a537738101e | |
parent | 18e9ac261efcc127811baad009738d38c8493785 (diff) |
-rwxr-xr-x | bin/ii-answer | 48 |
diff --git a/bin/ii-answer b/bin/ii-answer index ced8867..3fb9926 100755 --- a/bin/ii-answer +++ b/bin/ii-answer @@ -35,10 +35,10 @@ find "${irc_dir}" \ channel="${channel##*/}" if [ -z "${channel%%#*}" ]; then prefix='buildmaster: ' - sloppy_salutation='^\S\+\s\+<\(\S\+\)>\s.*buildmaster' + sloppy_salutation='^\S\+\s\+\S\+\s.*buildmaster' else prefix='' - sloppy_salutation='^\S\+\s\+<\(\S\+\)>\s' + sloppy_salutation='' fi # answer "why don't you?" regex='^\S\+ <\(\S\+\)> '"${prefix}"'!\?why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) ' @@ -147,29 +147,31 @@ find "${irc_dir}" \ irc_say "${channel}" 'copy' fi # answer "say/tell ... new/random/more" - regex="${sloppy_salutation}"'.*\(say\|tell\).*\(new\|random\|more\).*' - askers=$( - sed -i ' - /'"${regex}"'/ { - s/'"${regex}"'/\1/ + regex='^\S\+ <\(\S\+\)> \(.* \)\?\([Ss]ay\|[Tt]ell\).*\(new\|random\|more\).*' + if grep "${regex}" "${out_file}" | \ + grep -q "${sloppy_salutation}"; then + askers=$( + sed -i ' + /'"${sloppy_salutation}"'/ s/'"${regex}"'/\1/ + T w /dev/stdout d - } - ' "${out_file}" | \ - sort -u - ) - if [ -n "${askers}" ]; then - # markov's source is there: https://git.eckner.net/Erich/markov - # its parameters are: a word list, the depth of the markov chain - # and the count of words to print - "${base_dir}/bin/markov" ~/.words.irc 3 "$(printf '%s\n' "${askers}" | wc -l)" | \ - for asker in ${askers}; do - if ! read -r random; then - continue - fi - printf '%s: %s\n' "${asker}" "${random}" - done | \ - irc_say "${channel}" 'copy' + ' "${out_file}" | \ + sort -u + ) + if [ -n "${askers}" ]; then + # markov's source is there: https://git.eckner.net/Erich/markov + # its parameters are: a word list, the depth of the markov chain + # and the count of words to print + "${base_dir}/bin/markov" ~/.words.irc 3 "$(printf '%s\n' "${askers}" | wc -l)" | \ + for asker in ${askers}; do + if ! read -r random; then + continue + fi + printf '%s: %s\n' "${asker}" "${random}" + done | \ + irc_say "${channel}" 'copy' + fi fi if [ -z "${channel%%#*}" ]; then # answer "Shut up!" |