From c6e86cdb523d4e23d1922947f5d49ef38fb9bbe7 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Fri, 6 Oct 2023 18:19:54 +1100 Subject: [PATCH] Add option to show scrollback messages in the single/catchall &messages --- matterircd.toml.example | 4 ++++ mm-go-irckit/service.go | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/matterircd.toml.example b/matterircd.toml.example index a95230c4..36023b8f 100644 --- a/matterircd.toml.example +++ b/matterircd.toml.example @@ -65,6 +65,10 @@ Insecure = false # #JoinOnly = ["#onlythischannel"] +# When set, all scrollback messages are shown in &messages rather than individual channels +# +#CollapseScrollback = false + #an array of channels that won't be joined on IRC. #regexp is supported #Messages that get sent to unjoined channels (but you're joined on mattermost) will diff --git a/mm-go-irckit/service.go b/mm-go-irckit/service.go index e59d5ccd..96a00a1e 100644 --- a/mm-go-irckit/service.go +++ b/mm-go-irckit/service.go @@ -406,6 +406,10 @@ func scrollback(u *User, toUser *User, args []string, service string) { } } + if u.v.GetBool(u.br.Protocol() + ".collapsescrollback") { + u.MsgUser(toUser, fmt.Sprintf("scrollback results shown in &messages")) + return + } u.MsgUser(toUser, fmt.Sprintf("scrollback results shown in %s", search)) } @@ -413,6 +417,15 @@ func formatScrollbackMsg(u *User, channelID string, channel string, user *User, ts := time.Unix(0, p.CreateAt*int64(time.Millisecond)) switch { + case (u.v.GetBool(u.br.Protocol()+".collapsescrollback") && strings.HasPrefix(channel, "#")): + threadMsgID := u.prefixContext(channelID, p.Id, p.RootId, "scrollback") + msg := u.formatContextMessage(ts.Format("2006-01-02 15:04"), threadMsgID, msgText) + nick += "/" + channel + u.Srv.Channel("&messages").SpoofMessage(nick, msg) + case u.v.GetBool(u.br.Protocol() + ".collapsescrollback"): + threadMsgID := u.prefixContext(channelID, p.Id, p.RootId, "scrollback") + msg := u.formatContextMessage(ts.Format("2006-01-02 15:04"), threadMsgID, msgText) + u.Srv.Channel("&messages").SpoofMessage(nick, msg) case (u.v.GetBool(u.br.Protocol()+".prefixcontext") || u.v.GetBool(u.br.Protocol()+".suffixcontext")) && strings.HasPrefix(channel, "#") && nick != systemUser: threadMsgID := u.prefixContext(channelID, p.Id, p.RootId, "scrollback") msg := u.formatContextMessage(ts.Format("2006-01-02 15:04"), threadMsgID, msgText)