Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/convert.sh
diff options
context:
space:
mode:
Diffstat (limited to 'convert.sh')
-rwxr-xr-xconvert.sh57
1 files 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 '
+ /^<font size="2">/{
+ s@^<font size="2">(\([^)]\+\))</font><b> @\1 @
+ /entered the room\.<\/b><br\/>$/{
+ s@^\(\S\+\) \(.*\S\) \[.*] entered the room\.<\/b><br\/>$@\1 --> | \2 has joined #archlinux-ports @
+ p
+ d
+ }
+ / left the room /{
+ s@^\(\S\+\) \(.*\S\) left the room (quit: \(.*\))\.</b><br/>$@\1 <-- | \2 has quit (\3)@
+ p
+ d
+ }
+ / left the room\./{
+ s@^\(\S\+\) \(.*\S\) left the room\.</b><br/>$@\1 <-- | \2 has quit (Quit: \2)@
+ p
+ d
+ }
+ / is now known as /{
+ s@^\(\S\+\) \(.*\S\)\s*</b><br/>$@\1 -- | \2@
+ p
+ d
+ }
+ d
+ }
+ /<font size="2">/{
+ s@^<font color="#[0-9A-F]\{6\}"><font size="2">(\([^)]\+\))</font> <b>\(\S\+\):</b></font> @\1 \2 | @
+ s@<br/>$@@
+ 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 '<a href="#%s" name="%s" class="time">[%s]</a> <span class="nick">%s</span> is now known as <span class="nick">%s</span>\n<br />\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}"