From 3b7436c65b8f042b57269124f84e818943d9755b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 17 Oct 2017 10:50:28 +0200 Subject: pimp convert.sh --- convert.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/convert.sh b/convert.sh index 6c54371..175195a 100755 --- a/convert.sh +++ b/convert.sh @@ -4,9 +4,46 @@ dir='/srv/arch-mirror/arch/arch/archlinux32/irc-logs/#archlinux-ports/' declare -A colors -sed ' - s/([^()]*@[^()]*) // -' | \ +if [ "$1" = 'html' ]; then + shift + sed -n ' + /^/{ + s@^(\([^)]\+\)) @\1 @ + /entered the room\.<\/b>$/{ + s@^\(\S\+\) \(.*\S\) \[.*] entered the room\.<\/b>$@\1 --> | \2 has joined #archlinux-ports @ + p + d + } + / left the room /{ + s@^\(\S\+\) \(.*\S\) left the room (quit: \(.*\))\.
$@\1 <-- | \2 has quit (\3)@ + p + d + } + / left the room\./{ + s@^\(\S\+\) \(.*\S\) left the room\.
$@\1 <-- | \2 has quit (Quit: \2)@ + p + d + } + / is now known as /{ + s@^\(\S\+\) \(.*\S\)\s*
$@\1 -- | \2@ + p + d + } + d + } + //{ + s@^(\([^)]\+\)) \(\S\+\): @\1 \2 | @ + s@
$@@ + p + d + } + ' +else + sed ' + s/([^()]*@[^()]*) // + ' + cat +fi | \ sed ' :a $!N @@ -21,7 +58,7 @@ while read -r a b dummy c; do exit 42 fi time=$( - date -d@$(($(date -d"${a}" +%s)+3600*6)) +%T + date -d@$(($(date -d"${a}" +%s)+3600*$2)) +%T ) if [ "${b}" = '-->' ]; then name="${c%% *}" @@ -38,6 +75,13 @@ while read -r a b dummy c; do "${time}" "${time}" "${time}" "${name}" "${reason}" continue fi + if [ "${b}" = '--' ]; then + before="${c%% *}" + after="${c##* }" + printf '[%s] %s is now known as %s\n
\n' \ + "${time}" "${time}" "${time}" "${before}" "${after}" + continue + fi if [ -z "${colors["${b}"]}" ]; then colors["${b}"]=$( find "${dir}" -type f -name '*-*-*.html' -exec \ @@ -47,8 +91,9 @@ while read -r a b dummy c; do ) fi if [ -z "${colors["${b}"]}" ]; then - >&2 printf 'unkown user "%s"\n' "${b}" - exit 42 + colors["${b}"]=$(hexdump -n 4 -e '4/4 "%08X" 1 "\n"' /dev/urandom | head -c 6) +# >&2 printf 'unkown user "%s"\n' "${b}" +# exit 42 fi if [ $(echo "${colors["${b}"]}" | wc -l) -ne 1 ]; then >&2 printf 'user "%s" has multiple colors\n' "${b}" -- cgit v1.2.3-70-g09d2