Skip to content

Commit

Permalink
Update scrollback to support @@msgthreadID and the MM postlist URL
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Oct 13, 2023
1 parent bbe3e54 commit 1394a3c
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") {

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

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
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 1394a3c

Please sign in to comment.