shithub: hell

Download patch

ref: b465166bc3093d1a8f998bf78113ccd68ade0019
parent: a1bbf268d91af2fe34cc8e247f0e617ba102c578
author: penny <penny@limitedideas.org>
date: Tue Oct 21 16:31:15 EDT 2025

add /block and /unblock

--- 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", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "view", "bookmarks", "follow", "unfollow", "likes", "help", "reload", "attach", "detach", "pinned", "cat", "play", "translate", "read", "version", "local", "public"}
+var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "view", "bookmarks", "follow", "unfollow", "likes", "help", "reload", "attach", "detach", "pinned", "cat", "play", "translate", "read", "version", "local", "public", "block", "unblock"}
 
 func processInput(input string) (command string, arguments string, found bool) {
 
--- a/hellclient.go
+++ b/hellclient.go
@@ -12,7 +12,6 @@
 
 var EOF = io.EOF
 
-
 type postref struct {
 	prefix  string
 	ref     string
--- a/main.go
+++ b/main.go
@@ -337,7 +337,7 @@
 				}
 				return
 			case "mark":
-				markfunc := func() {_, err = client.Bookmark(context.Background(), postItem.ID)}
+				markfunc := func() { _, err = client.Bookmark(context.Background(), postItem.ID) }
 				hc.dispatchAnon(markfunc).Wait()
 				if err != nil {
 					printMastodonErr(err)
@@ -360,7 +360,7 @@
 					fmt.Printf("Post not bookmarked.\n")
 					return
 				}
-				hc.dispatchAnon(func() {_, err = client.Unbookmark(context.Background(), postItem.ID)}).Wait()
+				hc.dispatchAnon(func() { _, err = client.Unbookmark(context.Background(), postItem.ID) }).Wait()
 				if err != nil {
 					printMastodonErr(err)
 				} else {
@@ -603,19 +603,47 @@
 				fmt.Print(line)
 				return
 			case "block":
+				var account *mastodon.Account
+				if foundindex || index == "" {
+					account = &postItem.Account
+				} else {
+					account = hc.resolveAccount(index)
+					if account == nil {
+						fmt.Printf("Account or index not found.\n")
+						return
+					}
+				}
 				blockfunc := func() {
-						var account *mastodon.Account
-					if foundindex || index == "" {
+					_, err := client.AccountBlock(context.Background(), account.ID)
+					if err != nil {
+						fmt.Printf("Error blocking account: %s.\n")
+						return
+					}
+					fmt.Printf("Account blocked: %s\n", account.Acct)
+				}
+				hc.dispatchAnon(blockfunc).Wait()
+				return
+			case "unblock":
+				var account *mastodon.Account
+				if foundindex || index == "" {
 					account = &postItem.Account
-					} else {
-						account = hc.resolveAccount(index)
-						if account == nil {
+				} else {
+					account = hc.resolveAccount(index)
+					if account == nil {
+						fmt.Printf("Account or index not found.\n")
 						return
 					}
 				}
+				unblockfunc := func() {
+					_, err := client.AccountBlock(context.Background(), account.ID)
+					if err != nil {
+						fmt.Printf("Error blocking account: %s.\n")
+						return
+					}
+					fmt.Printf("Account unblocked: %s\n", account.Acct)
 				}
-			case "unblock:
-			
+				hc.dispatchAnon(unblockfunc).Wait()
+				return
 			}
 
 			//Posts that need an index and an argument
--- a/prompt.go
+++ b/prompt.go
@@ -4,7 +4,6 @@
 	"context"
 	"fmt"
 	"strings"
-
 )
 
 // Returns text to add to the status bar
--- a/readline.go
+++ b/readline.go
@@ -1,10 +1,11 @@
 //go:build !plan9
+
 package main
 
 import (
-	"os"
-	"io"
 	native "github.com/ergochat/readline"
+	"io"
+	"os"
 )
 
 type readline struct {
--- a/readline_plan9.go
+++ b/readline_plan9.go
@@ -8,7 +8,7 @@
 	"strings"
 )
 
-//not relevant
+// not relevant
 const (
 	CharCtrlJ     = 0
 	CharInterrupt = 0
@@ -24,7 +24,7 @@
 
 	//These are unused on Plan 9
 	FuncFilterInputRune func(rune) (rune, bool)
-	Listener          func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool)
+	Listener            func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool)
 }
 
 func (rl *readline) GetConfig() *Config {
--- a/renderer.go
+++ b/renderer.go
@@ -106,7 +106,6 @@
 	return soc.statusContent(soc.status)
 }
 
-
 // Stringer for user who caused a notification
 type notificationUser struct {
 	*StatusFormatter
--