From 820fee8960b870836e9ad73fc03fdc974929de84 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 9 Apr 2018 18:55:49 +0200 Subject: convert.sh: remove addresses for all formats --- convert.sh | 118 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/convert.sh b/convert.sh index f2f7191..8d341cf 100755 --- a/convert.sh +++ b/convert.sh @@ -24,6 +24,14 @@ create_color() { fi } +# the desired format is: +# "time nick | msg" +# "time --> | nick ... channel" +# "time <-- | nick ... (reason)" +# "time -- | old-nick new-nick" +# "time * | nick action" +# we reformat other formats accordingly + if [ "$1" = 'html' ]; then shift sed -n ' @@ -64,61 +72,61 @@ if [ "$1" = 'html' ]; then } ' else + cat +fi | \ sed ' s/([^()]*@[^()]*) // ' - cat -fi | \ -sed ' - :a - $!N - s/\n\s\+ | / / - ta - P - D -' | \ -sed ' - s@\(\s\)\(https\?://\S\+\)@\1\2@g -' | \ -while read -r a b dummy c; do - if [ "${dummy}" != '|' ]; then - >&2 printf 'wrong dummy "%s"\n' "${dummy}" - exit 42 - fi - time=$( - date -d@$(($(date -d"${a}" +%s)+3600*$2)) +%T - ) - if [ "${b}" = '-->' ]; then - name="${c%% *}" - channel="${c##* }" - printf '[%s] -!- %s has joined %s\n
\n' \ - "${time}" "${time}" "${time}" "${name}" "${channel}" - continue - fi - if [ "${b}" = '<--' ]; then - name="${c%% *}" - reason="${c##* (}" - reason="${reason%)*}" - printf '[%s] -!- %s has quit [%s]\n
\n' \ - "${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 [ "${b}" = '*' ]; then - nick="${c%% *}" - action="${c#* }" - create_color "${nick}" - printf '[%s] * %s %s\n
\n' \ - "${time}" "${time}" "${time}" "${colors["${nick}"]}" "${nick}" "${action}" - continue - fi - create_color "${b}" - printf '[%s] <%s> %s\n
\n' \ - "${time}" "${time}" "${time}" "${colors["${b}"]}" "${b}" "${c}" -done + sed ' + :a + $!N + s/\n\s\+ | / / + ta + P + D + ' | \ + sed ' + s@\(\s\)\(https\?://\S\+\)@\1\2@g + ' | \ + while read -r a b dummy c; do + if [ "${dummy}" != '|' ]; then + >&2 printf 'wrong dummy "%s"\n' "${dummy}" + exit 42 + fi + time=$( + date -d@$(($(date -d"${a}" +%s)+3600*$2)) +%T + ) + if [ "${b}" = '-->' ]; then + name="${c%% *}" + channel="${c##* }" + printf '[%s] -!- %s has joined %s\n
\n' \ + "${time}" "${time}" "${time}" "${name}" "${channel}" + continue + fi + if [ "${b}" = '<--' ]; then + name="${c%% *}" + reason="${c##* (}" + reason="${reason%)*}" + printf '[%s] -!- %s has quit [%s]\n
\n' \ + "${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 [ "${b}" = '*' ]; then + nick="${c%% *}" + action="${c#* }" + create_color "${nick}" + printf '[%s] * %s %s\n
\n' \ + "${time}" "${time}" "${time}" "${colors["${nick}"]}" "${nick}" "${action}" + continue + fi + create_color "${b}" + printf '[%s] <%s> %s\n
\n' \ + "${time}" "${time}" "${time}" "${colors["${b}"]}" "${b}" "${c}" + done -- cgit v1.2.3-70-g09d2