Skip to content

Commit

Permalink
Add option to show scrollback messages in the single/catchall &messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Oct 6, 2023
1 parent bbe3e54 commit c6e86cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions matterircd.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions mm-go-irckit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,26 @@ 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"))

Check failure on line 410 in mm-go-irckit/service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
return
}
u.MsgUser(toUser, fmt.Sprintf("scrollback results shown in %s", search))
}

func formatScrollbackMsg(u *User, channelID string, channel string, user *User, nick string, p *model.Post, msgText string) {
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)
Expand Down

0 comments on commit c6e86cd

Please sign in to comment.