shithub: hell

Download patch

ref: cb96e45d2b5094c69a4cb0567ca2391d79533d00
parent: 2df672ac8b4c4a6e9b4ac6ea8bd7e1b461790e06
author: penny <penny@limitedideas.org>
date: Wed Nov 5 15:24:05 EST 2025

FINALLY FINALLY

--- a/commands.go
+++ b/commands.go
@@ -1183,6 +1183,41 @@
 	return cmd
 }
 
+func (hc *Hellclient) blockcmd(name string, block bool) cmder {
+	cmd := &basiccmd{}
+	cmd.hc = hc
+	cmd.bname = name
+	cmd.bflags = account | acc_resolve
+	cmd.doer = func(data *cmddata) string {
+		var err error
+		var result string
+		var blockfunc func()
+		if block {
+			blockfunc = func() {
+					_, err = hc.client.AccountBlock(context.Background(), data.account.ID)
+					if err != nil {
+						result = fmt.Sprintf("Error blocking account: %s.\n", data.account.Acct)
+						return
+					}
+					result = fmt.Sprintf("Account blocked: %s\n", data.account.Acct)
+					return
+			}
+		} else {
+			blockfunc = func() {
+					_, err := hc.client.AccountUnblock(context.Background(), data.account.ID)
+					if err != nil {
+						result = fmt.Sprintf("Error unblocking account: %s.\n", data.account.Acct)
+					}
+					result = fmt.Sprintf("Account unblocked: %s\n", data.account.Acct)
+					return
+			}
+		}
+		hc.dispatchAnon(blockfunc).Wait()
+		return result
+	}
+	return cmd
+}
+
 // Commmands are lazy evaluated in this order
 // Single/two letter matches need to match the most common commands
 func (hc *Hellclient) newCmdArray() []cmder {
@@ -1214,6 +1249,7 @@
 		hc.prevcmd(),
 		hc.nextcmd(),
 		hc.bookmarkscmd(),
+		hc.blockcmd("block", true),
 		hc.readcmd(),
 		hc.noticecmd(),
 		hc.pausecmd(),
@@ -1225,6 +1261,7 @@
 		hc.urlcmd("url", &hc.preferences.Browser),
 		hc.filtercmd("ufpost", false),
 		hc.unfollowcmd(),
+		hc.blockcmd("unblock", false),
 		hc.urlcmd("play", &hc.preferences.MediaPlayer),
 		hc.mediacmd("view", &hc.preferences.ImageViewer),
 		hc.mediacmd("import", &hc.preferences.MediaImport),
--- a/main.go
+++ b/main.go
@@ -1,11 +1,7 @@
 package main
 
 import (
-	"context"
 	"fmt"
-	"strings"
-
-	mastodon "codeberg.org/penny64/hellclient-go-mastodon"
 )
 
 func main() {
@@ -18,12 +14,8 @@
 	rl := hc.rl
 	client := *hc.client
 	enablePipeHack(rl)
+	go StreamHomeTimeline(&client, hc.homeMap, hc)
 
-	homeMap := hc.homeMap
-	lastindex := ""
-
-	go StreamHomeTimeline(&client, homeMap, hc)
-
 	for {
 		func() {
 			line, err := rl.Readline()
@@ -30,7 +22,7 @@
 			hc.lock()
 			defer hc.unlock()
 
-			command, arguments, found := processInput(line, []string{})
+			command, arguments, _ := processInput(line, []string{})
 
 			//empty line
 			if command == "" && arguments == "" && err == nil {
@@ -52,7 +44,7 @@
 			if err != nil {
 				fmt.Print(err)
 			}
-			fmt.Printf(result)
+			fmt.Print(result)
 			return
 
 			if !found {
--