summary refs log tree commit diff
path: root/scoop.c
diff options
context:
space:
mode:
Diffstat (limited to 'scoop.c')
-rw-r--r--scoop.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/scoop.c b/scoop.c
index 55ee857..e33da1c 100644
--- a/scoop.c
+++ b/scoop.c
@@ -41,9 +41,6 @@ typedef void Format(bool group, struct Event event);
 
 static void formatPlain(bool group, struct Event e) {
 	(void)group;
-	if (!e.target) e.target = "";
-	if (!e.message) e.message = "";
-	
 	printf("%s/%s: [%s] ", e.network, e.context, e.time);
 	switch (e.type) {
 		break; case Privmsg: {
@@ -93,9 +90,6 @@ static int color(const char *user) {
 }
 
 static void formatColor(bool group, struct Event e) {
-	if (!e.target) e.target = "";
-	if (!e.message) e.message = "";
-
 	static char network[256];
 	static char context[256];
 	if (group && (strcmp(e.network, network) || strcmp(e.context, context))) {
@@ -146,6 +140,45 @@ static void formatColor(bool group, struct Event e) {
 #undef NICK
 }
 
+static void formatIRC(bool group, struct Event e) {
+	(void)group;
+	if (!strcmp(e.host, e.nick)) {
+		printf("@time=%s :%s ", e.time, e.host);
+	} else {
+		printf("@time=%s :%s!%s@%s ", e.time, e.nick, e.user, e.host);
+	}
+	if (!strcmp(e.context, e.nick)) e.context = "*";
+	switch (e.type) {
+		break; case Privmsg: {
+			printf("PRIVMSG %s :%s\r\n", e.context, e.message);
+		}
+		break; case Notice: {
+			printf("NOTICE %s :%s\r\n", e.context, e.message);
+		}
+		break; case Action: {
+			printf("PRIVMSG %s :\1ACTION %s\1\r\n", e.context, e.message);
+		}
+		break; case Join: {
+			printf("JOIN %s\r\n", e.context);
+		}
+		break; case Part: {
+			printf("PART %s :%s\r\n", e.context, e.message);
+		}
+		break; case Quit: {
+			printf("QUIT :%s\r\n", e.message);
+		}
+		break; case Kick: {
+			printf("KICK %s %s :%s\r\n", e.context, e.target, e.message);
+		}
+		break; case Nick: {
+			printf("NICK %s\r\n", e.target);
+		}
+		break; case Topic: {
+			printf("TOPIC %s :%s\r\n", e.context, e.message);
+		}
+	}
+}
+
 static const char *Inner = SQL(
 	SELECT
 		contexts.network,
@@ -212,6 +245,7 @@ static const struct {
 } Formats[] = {
 	{ "plain", formatPlain },
 	{ "color", formatColor },
+	{ "irc", formatIRC },
 };
 
 static Format *parseFormat(const char *name) {
@@ -359,6 +393,8 @@ int main(int argc, char *argv[]) {
 			.target  = (const char *)sqlite3_column_text(stmt, 7),
 			.message = (const char *)sqlite3_column_text(stmt, 8),
 		};
+		if (!event.target) event.target = "";
+		if (!event.message) event.message = "";
 		format(group, event);
 	}
 	if (result != SQLITE_DONE) warnx("%s", sqlite3_errmsg(db));
an>ui-stats.c: set parent pointer to NULL after freeing itJohn Keeping 2014-07-28git: update to v2.0.3John Keeping 2014-07-28parsing.c: make commit buffer constJohn Keeping 2014-06-30Bump version.Jason A. Donenfeld 2014-06-29remove debug fprinf() calls that sneaked in with commit 79c985Christian Hesse 2014-06-28git: update to 2.0.1Christian Hesse 2014-06-28ui-patch: Flush stdout after outputting dataJohn Keeping 2014-06-28ui-log: ignore unhandled argumentsJohn Keeping 2014-06-28git: update for git 2.0Christian Hesse 2014-04-17remove trailing whitespaces from source filesChristian Hesse 2014-04-12git: update to 1.9.2Christian Hesse 2014-04-05Fix cgit_parse_url when a repo url is contained in another repo urlJulian Maurice 2014-03-20Makefile: use more reliable git tarball mirrorJason A. Donenfeld 2014-03-20git: update to 1.9.1Christian Hesse