ref: f27bbb07a94c0d6117d16532024a16abeb9381e1
parent: 70d7fee70967e8276d6c29ca4b1d29797a3213da
author: penny <penny@limitedideas.org>
date: Thu Jul 31 19:05:05 EDT 2025
gofmt pass
--- a/main.go
+++ b/main.go
@@ -35,9 +35,9 @@
debugMap := make(map[string]interface{})postref := "a"
var recentpost *mastodon.Status
-
+
currentUser, err := client.GetAccountCurrentUser(context.Background())
-
+
if err != nil { fmt.Println("Couldn't get our own profile", err)return
@@ -57,38 +57,38 @@
//if we didn't get a slash command then the user is just posting
if command == "" && arguments != "" {recentpost, err = postStatus(fmt.Sprintf(line), account, *client, "public")
- if(err != nil) {+ if err != nil {fmt.Println(err)
}
continue
}
-
+
index, content, _ := strings.Cut(arguments, " ")
postItem, postOK := homeMap[index]
debugItem, debugOK := debugMap[index]
-
+
//Contextual commands that need to handle their own requirements
switch command {case "rm":
- if(!postOK && recentpost != nil) {+ if !postOK && recentpost != nil {err = client.DeleteStatus(context.Background(), recentpost.ID)
- if(err != nil) {+ if err != nil {fmt.Println(err)
}
recentpost = nil
continue
}
- if(!postOK) {+ if !postOK { fmt.Println("No recent status to delete or post index not valid")continue
}
err = client.DeleteStatus(context.Background(), postItem.ID)
- if(err != nil) {- fmt.Println(err)
+ if err != nil {+ fmt.Println(err)
}
continue
}
-
+
if arguments == "" { fmt.Printf("%v requires an argument\n", command)continue
@@ -98,13 +98,13 @@
switch command {case "dm":
recentpost, err = postStatus(arguments, account, *client, "direct")
- if(err != nil) {- fmt.Println(err)
+ if err != nil {+ fmt.Println(err)
}
continue
- if !postOK && !debugOK {- fmt.Printf("\"%v\" not a valid index\n", index)- continue
+ if !postOK && !debugOK {+ fmt.Printf("\"%v\" not a valid index\n", index)+ continue
}
}
@@ -144,19 +144,19 @@
case "reply":
if currentUser.ID == postItem.Account.ID {recentpost, err = postReply(content, account, *client, postItem.Visibility, postItem.ID)
- if (err != nil) {+ if err != nil {fmt.Println(err)
}
continue
}
recentpost, err = postReply("@"+getUserString(postItem)+" "+content, account, *client, postItem.Visibility, postItem.ID)- if (err != nil) {+ if err != nil {fmt.Println(err)
}
continue
case "rt":
rtStatus, err := client.Reblog(context.Background(), postItem.ID)
- if (err != nil) {+ if err != nil {fmt.Println(err)
continue
}
@@ -163,7 +163,7 @@
recentpost = rtStatus
saveWorkRef(homeMap, rtStatus, postref)
printPost("?"+postref, rtStatus)- postref = IncrementString(postref)
+ postref = IncrementString(postref)
case "parent":
if postItem.InReplyToID == nil { fmt.Printf("%v doesn't have a parent\n", index)@@ -175,11 +175,11 @@
postref = IncrementString(postref)
case "children":
context, err := client.GetStatusContext(context.Background(), postItem.ID)
- if (err != nil) {+ if err != nil {fmt.Println(err)
continue
}
- if (len(context.Descendants) == 0) {+ if len(context.Descendants) == 0 { fmt.Printf("\"%v\" has no children")}
for post := range context.Descendants {@@ -189,19 +189,19 @@
}
case "thread":
context, err := client.GetStatusContext(context.Background(), postItem.ID)
- if (err != nil) {+ if err != nil {fmt.Println(err)
continue
}
-
+
for post := range context.Ancestors {saveWorkRef(homeMap, context.Ancestors[post], postref)
printPost("?"+postref, context.Ancestors[post])postref = IncrementString(postref)
}
-
+
printPost(index, postItem)
-
+
for post := range context.Descendants {saveWorkRef(homeMap, context.Descendants[post], postref)
printPost("?"+postref, context.Descendants[post])@@ -208,7 +208,6 @@
postref = IncrementString(postref)
}
-
default:
fmt.Printf("Unimplemented command \"%v\"?\"\n", command)}
--- a/mastodon.go
+++ b/mastodon.go
@@ -106,7 +106,7 @@
return rendered.String()
}
-func postReply(posttext string, account *account, client mastodon.Client, visibility string, replyto mastodon.ID) (status *mastodon.Status, err error){+func postReply(posttext string, account *account, client mastodon.Client, visibility string, replyto mastodon.ID) (status *mastodon.Status, err error) { toot := mastodon.Toot{Status: posttext,
Visibility: visibility,
@@ -126,7 +126,7 @@
return
}
-func postStatusDetailed(posttext string, account *account, client mastodon.Client, visibility string, toot mastodon.Toot) (status *mastodon.Status, err error){+func postStatusDetailed(posttext string, account *account, client mastodon.Client, visibility string, toot mastodon.Toot) (status *mastodon.Status, err error) {status, err = client.PostStatus(context.Background(), &toot)
if err != nil {@@ -240,7 +240,7 @@
case *mastodon.DeleteEvent:
deleted, ok := idmap[post.ID]
//didn't have this in the cache
- if(!ok) {+ if !ok { fmt.Printf("Deleted: ID %v", post.ID)continue
}
--
⑨