shithub: patch

ref: 7caa9585434c771bea1aaf6d3317b969df5afa9d
dir: /ircrc-print-log/

View raw version
tweak how this prints messages and append to a log.
assumes jpm's patch applied beforehand.

diff -r ef9b307e9439 rc/bin/ircrc
--- a/rc/bin/ircrc	Sun Feb 26 00:27:50 2017
+++ b/rc/bin/ircrc	Sun Feb 26 00:28:19 2017
@@ -26,7 +26,11 @@
 }
 
 fn etime {
-	date | awk '{print $4}' | awk -F ':' '{print "[" $1 ":" $2 "]"}'
+	date -t | sed 's/-//g;s/^..(.*)T(..):(..).*/\1:\2\3/'
+}
+
+fn fmt2 {	# this fucking sucks
+	sed 's/^(......:....) (J?O?I?N? *)\(?(#?[^ \)]+)\)? «([^»]+)»/\1 \2\3:\4/'
 }
 
 fn work {
@@ -90,7 +94,7 @@
 			if (! ~ $#cmd 0) {
 				to = $cmd(1)
 				cmd = `{mshift $cmd}
-				out =  '('^$to^')	⇐	'^$"cmd
+				out = $to^' ⇐ '^$"cmd
 				msg = 'PRIVMSG '^$to^' :'^$"cmd
 			}
 		case /n
@@ -116,19 +120,19 @@
 			echo unknown command
 		case *
 			msg = 'PRIVMSG '^$target^' :'^$"cmd
-			out = '('^$target^')	⇐	'^$"cmd
+			out = $target^' ⇐ '^$"cmd
 		}
 		if (! ~ $#msg 0)
 			echo $msg >[1=3]
 		if (! ~ $#out 0)
-			echo `{etime}^' '^$out
+			echo `{etime}^' '^$"out | tee -a $home/tmp/irc
 	}
 }
 
 fn misc {
 	sed '
 		s/^://
-		s/!~?[a-zA-Z0-9_@\-|.{=\/:]+ /:/' |
+		s/!~?[a-zA-Z0-9_@\-|.{=\/:`\^]+ /:/' |
 	awk -F ':' '
 	{
 		s =  $2 " «" $1 "»\t" $3;
@@ -189,7 +193,10 @@
 			line = `{echo -n $line | numeric}
 		}
 		if (! ~ $#line 0)
-			echo `{etime} $line
+			echo `{etime} $line | fmt2
+		msg = `{echo $line | sed '/^(:|'$nick'|\([^\)]+\) «)/!d'}
+		if (! ~ $#msg 0)
+			echo `{etime} $msg | fmt2 >>$home/tmp/irc
 	}
 	exit
 }