Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-06-04 09:45:25 +0200
committerErich Eckner <git@eckner.net>2018-06-04 09:45:25 +0200
commit7f19dfd1616945c7e8ee9f41bee610d4ef1ffbe5 (patch)
tree5f93ac909dd9ae44752a419740953c33a4095873
parent2944fd6d91d437147521c48b6c9d30ab50755152 (diff)
bin/ii-answer,lib/common-functions: irc now turn-off-able
-rwxr-xr-xbin/ii-answer13
-rwxr-xr-xlib/common-functions14
2 files changed, 25 insertions, 2 deletions
diff --git a/bin/ii-answer b/bin/ii-answer
index 06bc3c0..779e1e9 100755
--- a/bin/ii-answer
+++ b/bin/ii-answer
@@ -115,4 +115,17 @@ find "${irc_dir}" \
printf 'np\n' | \
irc_say "${channel}" 'copy'
fi
+ if [ -z "${channel%%#*}" ]; then
+ # answer "Shut up!"
+ regex='^\S\+ <\S\+> .* [Ss][Hh][Uu][Tt] \?[Uu][Pp]'
+ if grep "${regex}" "${out_file}" | \
+ grep -q "${sloppy_salutation}"; then
+ sed -i "/${regex}/d" "${out_file}"
+ printf '%s\n' "$((
+ $(date '+%s') + 3600
+ ))" > "${work_dir}/irc-shut-up"
+ printf 'Sorry, I will do.\n' | \
+ irc_say "${channel}" 'copy'
+ fi
+ fi
done
diff --git a/lib/common-functions b/lib/common-functions
index 4c852ac..be35144 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -708,16 +708,26 @@ extract_pkgname_epoch_pkgver_pkgrel_sub_pkgrel_arch_from_package_name() {
# shellcheck disable=SC2120
irc_say() {
local channel
+ local channel_in_pipe
if [ -z "$1" ]; then
channel='#archlinux32'
else
channel="$1"
fi
+ if [ -s "${work_dir}/irc-shut-up" ] && \
+ [ "$(date '+%s')" -gt "$(cat "${work_dir}/irc-shut-up")" ]; then
+ rm "${work_dir}/irc-shut-up"
+ fi
+ if [ -s "${work_dir}/irc-shut-up" ]; then
+ channel_in_pipe='/dev/null'
+ else
+ channel_in_pipe="${irc_dir}/${channel}/in"
+ fi
if [ -p "${irc_dir}/${channel}/in" ]; then
if [ "$2" = 'copy' ]; then
- pee cat 'sponge '"${irc_dir}/${channel}/in"
+ pee cat 'sponge '"${channel_in_pipe}"
else
- sponge "${irc_dir}/${channel}/in"
+ sponge "${channel_in_pipe}"
fi
fi
}