summaryrefslogtreecommitdiff
path: root/bin/ii-answer
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ii-answer')
-rwxr-xr-xbin/ii-answer66
1 files changed, 42 insertions, 24 deletions
diff --git a/bin/ii-answer b/bin/ii-answer
index ed333cb..16fbb78 100755
--- a/bin/ii-answer
+++ b/bin/ii-answer
@@ -7,25 +7,43 @@
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
-# welcome devs (in #archlinux32 only)
-welcome_user_regex='^\S\+ -!- \(abaumann\|buildmaster\|deep42thought\|girls\|nit-picker\|tyzoid\)(.* has joined \S\+$'
-new_users=$(
- sed -i '
- s/'"${welcome_user_regex}"'/\1/
- T
- w /dev/stdout
- d
- ' "${irc_dir}/#archlinux32/out" | \
- sort -u
-)
-if [ -n "${new_users}" ]; then
- printf '%s\n' "${new_users}" | \
- sed '
- s/^.*$/Hi \0!\n!rq \0/
- s/Hi buildmaster!\n//
- ' | \
- irc_say '' 'copy'
-fi
+# welcome devs (in #archlinux32 and #archlinux32-devops only)
+welcome_user_regex='^\S\+ -!- \(abaumann\|deep42thought\)(.* has joined \S\+$'
+for channel in '#archlinux32:Hi \0!\n!rq \0' '#archlinux32-devops:Hi \0!'; do
+ new_users=$(
+ sed -i '
+ s/'"${welcome_user_regex}"'/\1/
+ T
+ w /dev/stdout
+ d
+ ' "${irc_dir}/${channel%%:*}/out" \
+ | grep -vxF "$(
+ {
+ printf '%s SNIP\n' $(($(date +%s)-5*60))
+ cat "${irc_dir}/out"
+ cat "${irc_dir}/${channel%%:*}/out"
+ } \
+ | sort -k1nr,1 \
+ | sed '
+ /^\S\+ SNIP$/q
+ ' \
+ | sed '
+ s/^\S\+\s\+-!- \([^([:space:]]\+\)\((\S\+\)\? has quit.*$/\1/
+ t
+ d
+ ' \
+ | sort -u
+ )" \
+ | sort -u
+ )
+ if [ -n "${new_users}" ]; then
+ printf '%s\n' "${new_users}" | \
+ sed '
+ s/^.*$/'"${channel#*:}"'/
+ ' | \
+ irc_say "${channel%%:*}" 'copy'
+ fi
+done
find "${irc_dir}" \
-type f \
@@ -42,10 +60,10 @@ 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 \2 /
+ s/'"${regex}"'/\1 \2 \3/
T
w /dev/stdout
d
@@ -148,7 +166,7 @@ find "${irc_dir}" \
irc_say "${channel}" 'copy'
fi
# answer "sanity-check"
- regex='^\S\+ <\S\+> .*\([Gg]et.*straight\|[Pp]ull.*yourself.*together\)'
+ regex='^\S\+ <\S\+> .*\([Gg]et.*straight\|[Pp]ull.*yourself.*together\|[Cc]heck.*again\)'
if grep "${regex}" "${out_file}" | \
grep -q "${sloppy_salutation}"; then
sed -i "/${regex}/d" "${out_file}"
@@ -201,11 +219,11 @@ find "${irc_dir}" \
fi
if [ -z "${channel%%#*}" ]; then
# answer "Shut up!"
- regex='^\S\+ <\S\+> \(.* \)\?[Ss][Hh][Uu][Tt] \?[Uu][Pp]'
+ regex='^\S\+ <\S\+> \(.* \)\?([Ss][Hh][Uu][Tt] \?[Uu][Pp]\|pss\+t\|[Bb]e \(.* \)\?quiet'
if grep "${regex}" "${out_file}" | \
grep -q "${sloppy_salutation}"; then
sed -i "/${regex}/d" "${out_file}"
- printf 'Sorry, I will do.\n' | \
+ printf 'Sorry, I will be quiet.\n' | \
irc_say "${channel}" 'copy'
printf '%s\n' "$((
$(date '+%s') + 3600