Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/ii-answer
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-01-10 14:14:18 +0100
committerErich Eckner <git@eckner.net>2019-01-10 14:14:18 +0100
commit61c3c5c3a35d3f2cc4022b3f96742734b154eea4 (patch)
treef19f69addfe1efbc1eefb16c4ad659282550c11d /bin/ii-answer
parent1b8aea42314197d4258e8dd218b2eb5af9a7dfc9 (diff)
bin/ii-answer: use bin/markov (not in repo) to return random words
Diffstat (limited to 'bin/ii-answer')
-rwxr-xr-xbin/ii-answer22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/ii-answer b/bin/ii-answer
index 7db226f..de6d3c9 100755
--- a/bin/ii-answer
+++ b/bin/ii-answer
@@ -146,6 +146,28 @@ find "${irc_dir}" \
sort -u | \
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/
+ w /dev/stdout
+ d
+ }
+ ' "${out_file}" | \
+ sort -u
+ )
+ if [ -n "${askers}" ]; then
+ "${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
if [ -z "${channel%%#*}" ]; then
# answer "Shut up!"
regex='^\S\+ <\S\+> \(.* \)\?[Ss][Hh][Uu][Tt] \?[Uu][Pp]'