]> Sergey Matveev's repositories - mmc.git/commitdiff
cmd/scrollback -direct
authorSergey Matveev <stargrave@stargrave.org>
Sun, 12 Mar 2023 10:15:58 +0000 (13:15 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 12 Mar 2023 12:42:11 +0000 (15:42 +0300)
cmd/scrollback/main.go

index 2f48d109cda30459928b93e32c11992fd76e660f..aab3312497ce02f8a2bff465933bbb6c2367c8b0 100644 (file)
@@ -31,6 +31,7 @@ const PerPage = 100
 func main() {
        entrypoint := flag.String("entrypoint", "mm.rnd.stcnet.ru", "Entrypoint")
        pageNum := flag.Int("page", 0, "Page number")
+       direct := flag.Bool("direct", false, "Direct channel")
        flag.Parse()
        log.SetFlags(log.Lshortfile)
        log.SetOutput(os.Stdout)
@@ -43,10 +44,21 @@ func main() {
        }
        c := model.NewAPIv4Client("https://" + *entrypoint)
        c.Login(login, password)
+       me, _, err := c.GetMe("")
+       if err != nil {
+               log.Fatalln(err)
+       }
        users, err := mmc.GetUsers(c, nil)
        if err != nil {
                log.Fatalln(err)
        }
+       if *direct {
+               dc, _, err := c.CreateDirectChannel(me.Id, chId)
+               if err != nil {
+                       log.Fatalln(err)
+               }
+               chId = dc.Id
+       }
        list, _, err := c.GetPostsBefore(chId, postId, *pageNum, PerPage, "", false)
        if err != nil {
                log.Fatalln(err)