Skip to content

Commit

Permalink
Add option to show scrollback messages in the single/catchall &messag…
Browse files Browse the repository at this point in the history
…es (#552)

* Add option to show scrollback messages in the single/catchall &messages

* Make scrollback limit optional

* Update service.go
  • Loading branch information
hloeung authored Feb 12, 2024
1 parent b762e5e commit 0f73df4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ Search

Scrollback
```
/msg mattermost scrollback <channel> <limit>
e.g. /msg mattermost scrollback #bugs 100 shows the last 100 messages of #bugs
/msg mattermost scrollback #<channel>|<user>|<post/thread ID> <limit>
```
e.g. `/msg mattermost scrollback #bugs 100` shows the last 100 messages of *#bugs*
e.g. `/msg mattermost scrollback zdofdf1nctgsj87xgt6oco1a3w 0` shows all messages from the thread with root/parent *zdofdf1nctgsj87xgt6oco1a3w*

Mark messages in a channel/from a user as read (when DisableAutoView is set).
```
Expand Down
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
14 changes: 13 additions & 1 deletion mm-go-irckit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,25 @@ func scrollback(u *User, toUser *User, args []string, service string) {
}
}

u.MsgUser(toUser, fmt.Sprintf("scrollback results shown in %s", search))
if !u.v.GetBool(u.br.Protocol() + ".collapsescrollback") { //nolint:goconst
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)
nick += "/" + channel
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 0f73df4

Please sign in to comment.