Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading