Skip to content

Commit

Permalink
Update scrollback to support @@msgthreadID and the MM postlist URL (#555
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hloeung authored Oct 13, 2023
1 parent bbe3e54 commit 04675fb
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions mm-go-irckit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,29 @@ func scrollback(u *User, toUser *User, args []string, service string) {
return
}

if len(args) != 2 {
var err error
limit := 0
err = nil
if len(args) == 2 {
limit, err = strconv.Atoi(args[1])
}
if len(args) == 0 || len(args) > 2 || err != nil {
u.MsgUser(toUser, "need SCROLLBACK (#<channel>|<user>|<post/thread ID>) <lines>")
u.MsgUser(toUser, "e.g. SCROLLBACK #bugs 10 (show last 10 lines from #bugs)")
return
}

search := args[0]
limit, err := strconv.Atoi(args[1])
if err != nil {
u.MsgUser(toUser, "need SCROLLBACK (#<channel>|<user>|<post/thread ID>) <lines>")
u.MsgUser(toUser, "e.g. SCROLLBACK #bugs 10 (show last 10 lines from #bugs)")
return
}

var channelID, searchPostID string
scrollbackUser, exists := u.Srv.HasUser(search)

proto := "https"
if u.v.GetBool(u.br.Protocol() + ".insecure") {
proto = "http"
}
postlistURL := proto + "://" + u.Credentials.Server + "/" + u.Credentials.Team + "/pl/"

switch {
case strings.HasPrefix(search, "#"):
channelName := strings.ReplaceAll(search, "#", "")
Expand All @@ -323,6 +329,10 @@ func scrollback(u *User, toUser *User, args []string, service string) {
channelID = u.br.GetChannelID(channelName, u.br.GetMe().TeamID)
case len(search) == 26:
searchPostID = search
case strings.HasPrefix(search, "@@"):
searchPostID = strings.TrimPrefix(search, "@@")
case strings.HasPrefix(strings.ToLower(search), postlistURL):
searchPostID = strings.TrimPrefix(search, postlistURL)
default:
u.MsgUser(toUser, "need SCROLLBACK (#<channel>|<user>|<post/thread ID>) <lines>")
u.MsgUser(toUser, "e.g. SCROLLBACK #bugs 10 (show last 10 lines from #bugs)")
Expand Down

0 comments on commit 04675fb

Please sign in to comment.