diff options
author | June McEnroe <june@causal.agency> | 2021-05-18 16:14:12 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-05-18 16:14:12 -0400 |
commit | b194fa23e0f74e609b5aade2967374f390503005 (patch) | |
tree | decf1f10e448bc757eedede8763a5642f56abd82 | |
parent | Mention unscoop, Liberapay in README (diff) | |
download | litterbox-b194fa23e0f74e609b5aade2967374f390503005.tar.gz litterbox-b194fa23e0f74e609b5aade2967374f390503005.zip |
Add weechat format to unscoop
-rw-r--r-- | unscoop.1 | 19 | ||||
-rw-r--r-- | unscoop.c | 47 |
2 files changed, 63 insertions, 3 deletions
diff --git a/unscoop.1 b/unscoop.1 index 2a87fc9..41a3772 100644 --- a/unscoop.1 +++ b/unscoop.1 @@ -1,4 +1,4 @@ -.Dd May 17, 2021 +.Dd May 18, 2021 .Dt UNSCOOP 1 .Os . @@ -104,6 +104,23 @@ find Textual -type f -name '*.txt' \e xargs -0 unscoop -f textual .Ed . +.It Fl f Cm weechat +Import logs from the WeeChat IRC client. +.Bd -literal -offset indent +find ~/.weechat/logs -type f -name 'irc.*.weechatlog' \e + -not -name 'irc.server.*.weechatlog' -print0 | +xargs -0 unscoop -f weechat +.Ed +.Pp +.Nm +is not able to correctly infer +network and context names +for channel names containing dots. +Import these logs explicitly with +.Fl N +and +.Fl c . +. .It Fl f Cm znc Import logs from the .Xr znc 1 diff --git a/unscoop.c b/unscoop.c index 598979b..ac61b88 100644 --- a/unscoop.c +++ b/unscoop.c @@ -50,6 +50,7 @@ struct Matcher { #define P0_MODE "[!~&@%+ ]?" #define P1_TIME "^[[]([^]]+)[]][ \t]" #define P2_USERHOST "[(]([^@]+)@([^)]+)[)]" +#define P2_MESSAGE "( [(]([^)]+)[)])?" static const struct Matcher Catgirl[] = { { @@ -148,7 +149,6 @@ static const struct Matcher IRC[] = { #undef P2_TAGS #undef P3_ORIGIN -#define P2_MESSAGE "( [(]([^)]+)[)])?" static const struct Matcher Textual[] = { { P1_TIME "<" P0_MODE "([^>]+)> (.+)", @@ -185,7 +185,46 @@ static const struct Matcher Textual[] = { Unban, { ":time", ":nick", ":target" }, } }; -#undef P2_MESSAGE + +static const struct Matcher WeeChat[] = { + { + "([^\t]+)\t-->\t([^ ]+) " P2_USERHOST " has joined", + Join, { ":time", ":nick", ":user", ":host" }, + }, { + "([^\t]+)\t<--\t([^ ]+) " P2_USERHOST " has left [^ ]+" P2_MESSAGE, + Part, { ":time", ":nick", ":user", ":host", NULL, ":message" }, + }, { + "([^\t]+)\t<--\t([^ ]+) has kicked ([^ ]+)" P2_MESSAGE, + Kick, { ":time", ":nick", ":target", NULL, ":message" }, + }, { + "([^\t]+)\t<--\t([^ ]+) " P2_USERHOST " has quit" P2_MESSAGE, + Quit, { ":time", ":nick", ":user", ":host", NULL, ":message" }, + }, { + "([^\t]+)\t--\t([^ ]+) is now known as ([^ ]+)", + Nick, { ":time", ":nick", ":target" }, + }, { + "([^\t]+)\t--\t([^ ]+) has changed topic for [^ ]+ to \"(.+)\"", + Topic, { ":time", ":nick", ":message" }, + }, { + "([^\t]+)\t--\t([^ ]+) has unset topic", + Topic, { ":time", ":nick" }, + }, { + "([^\t]+)\t--\tMode [^ ]+ [[][+]b+ ([^]]+)[]] by ([^ ]+)", + Ban, { ":time", ":target", ":nick" }, + }, { + "([^\t]+)\t--\tMode [^ ]+ [[][-]b+ ([^]]+)[]] by ([^ ]+)", + Unban, { ":time", ":target", ":nick" }, + }, { + "([^\t]+)\t--\tNotice[(]([^)]+)[)]: (.+)", + Notice, { ":time", ":nick", ":message" }, + }, { + "([^\t]+)\t [*]\t([^ ]+) (.+)", + Action, { ":time", ":nick", ":message" }, + }, { + "([^\t]+)\t" P0_MODE "([^-][^\t]*)\t(.+)", + Privmsg, { ":time", ":nick", ":message" }, + } +}; static const struct Matcher ZNC[] = { { @@ -256,6 +295,10 @@ static const struct Format { 1, 4, 0, }, { + "weechat", WeeChat, ARRAY_LEN(WeeChat), + "irc[.](.+)[.]([^.]+)[.]weechatlog$", 1, 2, 0, + }, + { "znc", ZNC, ARRAY_LEN(ZNC), "([^/]+)/(moddata/log/)?([^/]+)/([0-9-]+)[.]log$", 1, 3, 4, }, |