shithub: hell

Download patch

ref: 7c96692a58c6ed3b57bb824e6a452349e87775ab
parent: f277ed8879dc4e90f93678b781c23e8e0e3c0144
author: penny <penny@limitedideas.org>
date: Tue Aug 12 19:14:41 EDT 2025

Move reply logic to reply function and fix parameters in replies

--- a/main.go
+++ b/main.go
@@ -73,7 +73,7 @@
 
 			//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")
+				recentpost, err = postStatus(fmt.Sprintf(line), *client, "public")
 				if err != nil {
 					fmt.Println(err)
 				}
@@ -123,7 +123,7 @@
 			//Commands that don't take an index
 			switch command {
 			case "dm":
-				recentpost, err = postStatus(arguments, account, *client, "direct")
+				recentpost, err = postStatus(arguments, *client, "direct")
 				if err != nil {
 					fmt.Println(err)
 				}
@@ -207,14 +207,7 @@
 			case "download":
 				savePostImages(postItem, "/Users/penny/Downloads/")
 			case "reply":
-				if currentUser.ID == postItem.Account.ID {
-					recentpost, err = postReply(content, account, *client, postItem.Visibility, postItem.ID)
-					if err != nil {
-						fmt.Println(err)
-					}
-					return
-				}
-				recentpost, err = postReply("@"+getUserString(postItem)+" "+content, account, *client, postItem.Visibility, postItem.ID)
+				recentpost, err = postReply(content, *client, postItem.ID, currentUser.ID, postItem)
 				if err != nil {
 					fmt.Println(err)
 				}
--- a/mastodon.go
+++ b/mastodon.go
@@ -125,29 +125,8 @@
 	return rendered.String()
 }
 
-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,
-		InReplyToID: replyto,
-	}
-	status, err = postStatusDetailed(posttext, account, client, toot)
-	return
-}
-
-func postStatus(posttext string, account *account, client mastodon.Client, visibility string) (status *mastodon.Status, err error) {
-	// Post a toot
-	toot := mastodon.Toot{
-		Status:     posttext,
-		Visibility: visibility,
-	}
-	
-	
-	status, err = postStatusDetailed(posttext, account, client, toot)
-	return
-}
-
-func postStatusDetailed(posttext string, account *account, client mastodon.Client, toot mastodon.Toot) (status *mastodon.Status, err error) {
+func processStatusHints (toot *mastodon.Toot, postpointer *string) {
+	posttext := *postpointer
 	posttext, hints := extractInputParameters(posttext)
 	toot.Status = posttext
 	
@@ -164,6 +143,47 @@
 						
 		}
 	}
+	*postpointer = posttext
+}
+
+func postReply(posttext string, client mastodon.Client, replyto mastodon.ID, currentuser mastodon.ID, postItem *mastodon.Status) (status *mastodon.Status, err error) {
+	toot := mastodon.Toot{
+		Status:      posttext,
+		InReplyToID: replyto,
+	}
+	
+	if currentuser == postItem.Account.ID {
+		status, err = postStatusDetailed(client, toot)
+		if err != nil {
+			fmt.Println(err)
+		}
+		return
+	}
+	
+	processStatusHints(&toot, &posttext)
+	
+	toot.Status = "@"+getUserString(postItem)+" "+posttext
+	status, err = postStatusDetailed(client, toot)
+	if err != nil {
+		fmt.Println(err)
+	}
+	return
+}
+
+func postStatus(posttext string, client mastodon.Client, visibility string) (status *mastodon.Status, err error) {
+	// Post a toot
+	toot := mastodon.Toot{
+		Status:     posttext,
+		Visibility: visibility,
+	}
+	
+	processStatusHints(&toot, &posttext)
+
+	status, err = postStatusDetailed(client, toot)
+	return
+}
+
+func postStatusDetailed(client mastodon.Client, toot mastodon.Toot) (status *mastodon.Status, err error) {
 	
 	status, err = client.PostStatus(context.Background(), &toot)
 
--