Software /
code /
clix
Changeset
148:27a9f28724d3
clix.archive: Add 'irc' output format, useful for MUC export
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 08 Feb 2021 22:59:49 +0100 |
parents | 147:0bc82a318c45 |
children | 149:014e73c329c5 |
files | clix/archive.lua |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/clix/archive.lua Mon Feb 08 22:57:42 2021 +0100 +++ b/clix/archive.lua Mon Feb 08 22:59:49 2021 +0100 @@ -1,3 +1,4 @@ +local jid_split = require"util.jid".split; local bare_jid = require"util.jid".bare; local parse_datetime = require"util.datetime".parse; return function (opts, arg) @@ -39,6 +40,24 @@ :tag("delay", {xmlns="urn:xmpp:delay", stamp=datetime(i.stamp)}):up() :add_child(i.message)); end + elseif opts.format == "irc" then + local date; + local os_date = os.date; + function print_message(i) + local m = i.message; + local body = m:get_child_text("body"); + local a = m.attr; + local _, _, nick = jid_split(a.from); + + local curdate = os_date("%F", i.stamp); + if date ~= curdate then + print("-!- "..curdate); + date = curdate; + end + if nick and body then + print(("%s <%s> %s"):format(os_date("%T", i.stamp), nick, body)); + end + end end local function on_connect(conn)