ref: 9e3692b4f14d93bd48e458ec2541140a7e2b4de7
parent: eb3032356451487c56c5a2982d3c6eecba336f17
author: penny <penny@limitedideas.org>
date: Sat Sep 27 08:57:04 EDT 2025
implement /follow
--- a/commands.go
+++ b/commands.go
@@ -4,7 +4,7 @@
"strings"
)
-var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "preview", "bookmarks"}+var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "preview", "bookmarks", "follow"} func processInput(input string) (command string, arguments string, found bool) {--- a/main.go
+++ b/main.go
@@ -201,7 +201,7 @@
//Commands that accept debug indexes
switch command {case "examine":
- if postOK {+ if foundindex {hc.PrintObjectProperties(postItem)
return
}
@@ -329,7 +329,6 @@
fmt.Println(err)
return
}
-
case "thread":
hc.pause(true)
hc.page = &Page{}@@ -364,6 +363,37 @@
(*hc.page.itembuffer)[0].lines = -1
fmt.Print(hc.page.String())
return
+ case "follow":
+ var account *mastodon.Account
+ var accounts []*mastodon.Account
+ if foundindex {+ account = &postItem.Account
+ } else {+ accounts, err = hc.client.AccountsSearchResolve(context.Background(), index, 1, true)
+ if err != nil {+ fmt.Printf("Error resolving account %s: %v\n", index, err)+ return
+ }
+ if len(accounts) < 1 {+ fmt.Printf("No account matched %s\n", index)+ return
+ }
+ account = accounts[0]
+ }
+ relationship, err := hc.client.AccountFollow(context.Background(), account.ID)
+ if err != nil {+ fmt.Printf("Error requesting follow: %s\n", err)+ return
+ }
+ if relationship.Following {+ fmt.Printf("Successfully followed %s\n", account.Acct)+ return
+ }
+ if relationship.Requested {+ fmt.Printf("Follow request sent to %s\n", account.Acct)+ return
+ }
+
case "fpost":
_, err := hc.filterStatus(postItem)
if err != nil {--
⑨