about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-06 08:34:48 -0500
committerJune McEnroe <june@causal.agency>2019-12-06 08:35:37 -0500
commite62693657f0ada6b8c403752aaaafd2cdb91907e (patch)
tree95a2c0a8e8c385a3f4a3eced389a1255a84bbd86
parentHandle optional regex groups (diff)
downloadlitterbox-e62693657f0ada6b8c403752aaaafd2cdb91907e.tar.gz
litterbox-e62693657f0ada6b8c403752aaaafd2cdb91907e.zip
Add catgirl format
Diffstat (limited to '')
-rw-r--r--unscoop.15
-rw-r--r--unscoop.c75
2 files changed, 61 insertions, 19 deletions
diff --git a/unscoop.1 b/unscoop.1
index 0a9f0db..e9e8dbe 100644
--- a/unscoop.1
+++ b/unscoop.1
@@ -1,4 +1,4 @@
-.Dd December 5, 2019
+.Dd December 6, 2019
 .Dt UNSCOOP 1
 .Os
 .
@@ -41,7 +41,8 @@ for the default database path.
 Set the input log format.
 The following formats are supported:
 .Sy generic ,
-.Sy textual .
+.Sy textual ,
+.Sy catgirl .
 .Pp
 The
 .Sy generic
diff --git a/unscoop.c b/unscoop.c
index 9d5141c..09a0e97 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -43,62 +43,102 @@ struct Matcher {
 };
 
 #define WS "[[:blank:]]"
-#define PAT_TIME "[[]([^]]+)[]]"
-#define PAT_MODE "[!~&@%+ ]?"
+#define P1_TIME "[[]([^]]+)[]]"
+#define P0_MODE "[!~&@%+ ]?"
 
 static struct Matcher Generic[] = {
 	{
-		"^" PAT_TIME WS "<" PAT_MODE "([^>]+)" ">" WS "(.+)",
+		"^" P1_TIME WS "<" P0_MODE "([^>]+)" ">" WS "(.+)",
 		.type = Privmsg, .time = 1, .nick = 2, .message = 3,
 	},
 	{
-		"^" PAT_TIME WS "-" PAT_MODE "([^-]+)" "-" WS "(.+)",
+		"^" P1_TIME WS "-" P0_MODE "([^-]+)" "-" WS "(.+)",
 		.type = Notice, .time = 1, .nick = 2, .message = 3,
 	},
 	{
-		"^" PAT_TIME WS "[*]" WS PAT_MODE "([^[:blank:]]+)" WS "(.+)",
+		"^" P1_TIME WS "[*]" WS P0_MODE "([^[:blank:]]+)" WS "(.+)",
 		.type = Action, .time = 1, .nick = 2, .message = 3,
 	},
 };
 
-#define PAT_USERHOST "[(]([^@]+)@([^)]+)[)]"
-#define PAT_MESSAGE "( [(]([^)]+)[)])?"
-
+#define P2_USERHOST "[(]([^@]+)@([^)]+)[)]"
+#define P2_MESSAGE "( [(]([^)]+)[)])?"
 static struct Matcher Textual[] = {
 	{
-		"^" PAT_TIME " <" PAT_MODE "([^>]+)> (.+)",
+		"^" P1_TIME " <" P0_MODE "([^>]+)> (.+)",
 		.type = Privmsg, .time = 1, .nick = 2, .message = 3,
 	},
 	{
-		"^" PAT_TIME " -" PAT_MODE "([^-]+)- (.+)",
+		"^" P1_TIME " -" P0_MODE "([^-]+)- (.+)",
 		.type = Notice, .time = 1, .nick = 2, .message = 3,
 	},
 	{
-		"^" PAT_TIME " • ([^:]+): (.+)",
+		"^" P1_TIME " • ([^:]+): (.+)",
 		.type = Action, .time = 1, .nick = 2, .message = 3,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " joined the channel",
+		"^" P1_TIME " ([^ ]+) " P2_USERHOST " joined the channel",
 		.type = Join, .time = 1, .nick = 2, .user = 3, .host = 4,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " left the channel" PAT_MESSAGE,
+		"^" P1_TIME " ([^ ]+) " P2_USERHOST " left the channel" P2_MESSAGE,
 		.type = Part, .time = 1, .nick = 2, .user = 3, .host = 4, .message = 6,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) kicked ([^ ]+) from the channel" PAT_MESSAGE,
+		"^" P1_TIME " ([^ ]+) kicked ([^ ]+) from the channel" P2_MESSAGE,
 		.type = Kick, .time = 1, .nick = 2, .target = 3, .message = 5,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " left IRC" PAT_MESSAGE,
+		"^" P1_TIME " ([^ ]+) " P2_USERHOST " left IRC" P2_MESSAGE,
 		.type = Quit, .time = 1, .nick = 2, .user = 3, .host = 4, .message = 6,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) is now known as ([^ ]+)",
+		"^" P1_TIME " ([^ ]+) is now known as ([^ ]+)",
+		.type = Nick, .time = 1, .nick = 2, .target = 3,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) changed the topic to (.+)",
+		.type = Topic, .time = 1, .nick = 2, .message = 3,
+	},
+};
+
+#undef P2_MESSAGE
+#define P2_MESSAGE "(, \"([^\"]+)\")?"
+static struct Matcher Catgirl[] = {
+	{
+		"^" P1_TIME " <([^>]+)> (.+)",
+		.type = Privmsg, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" P1_TIME " -([^-]+)- (.+)",
+		.type = Notice, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" P1_TIME " [*] ([^ ]+) (.+)",
+		.type = Action, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) arrives",
+		.type = Join, .time = 1, .nick = 2,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) leaves [^,]+" P2_MESSAGE,
+		.type = Part, .time = 1, .nick = 2, .message = 4,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) kicks ([^ ]+) out of [^,]+" P2_MESSAGE,
+		.type = Kick, .time = 1, .nick = 2, .target = 3, .message = 5,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) leaves" P2_MESSAGE,
+		.type = Quit, .time = 1, .nick = 2, .message = 4,
+	},
+	{
+		"^" P1_TIME " ([^ ]+) is now known as ([^ ]+)",
 		.type = Nick, .time = 1, .nick = 2, .target = 3,
 	},
 	{
-		"^" PAT_TIME " ([^ ]+) changed the topic to (.+)",
+		"^" P1_TIME " ([^ ]+) places a new sign in [^,]+" P2_MESSAGE,
 		.type = Topic, .time = 1, .nick = 2, .message = 3,
 	},
 };
@@ -110,6 +150,7 @@ static const struct Format {
 } Formats[] = {
 	{ "generic", Generic, ARRAY_LEN(Generic) },
 	{ "textual", Textual, ARRAY_LEN(Textual) },
+	{ "catgirl", Catgirl, ARRAY_LEN(Catgirl) },
 };
 
 static const struct Format *formatParse(const char *name) {