ref: 11e7b3f7e234f4a8dc18be318200d311b28e0304
parent: bf8f7853b47eb7ed0119491d516b661bb0263c53
author: penny <penny@limitedideas.org>
date: Tue Nov 4 14:24:50 EST 2025
port four more commands
--- a/commands.go
+++ b/commands.go
@@ -868,7 +868,7 @@
return cmd
}
-func (hc *Hellclient) urlcmd(name string, command *string,) cmder {+func (hc *Hellclient) urlcmd(name string, command *string) cmder { cmd := &basiccmd{}cmd.hc = hc
cmd.bname = name
@@ -880,6 +880,71 @@
return cmd
}
+func (hc *Hellclient) mediacmd(name string, command *string) cmder {+ cmd := &basiccmd{}+ cmd.hc = hc
+ cmd.bname = name
+ cmd.bflags = status
+ cmd.doer = func(data *cmddata) string {+ err := hc.previewPostImages(data.status, *command)
+ if err != nil {+ return fmt.Sprintf("err: %s\n", err)+ }
+ return ""
+ }
+ return cmd
+}
+
+//this is using printf fixme
+func (hc *Hellclient) downloadcmd() cmder {+ cmd := &basiccmd{}+ cmd.hc = hc
+ cmd.bname = "download"
+ cmd.bflags = status
+ cmd.doer = func(data *cmddata) string {+ savePostImages(data.status, hc.preferences.Save_Location)
+ return ""
+ }
+ return cmd
+}
+
+func (hc *Hellclient) hrtcmd() cmder {+ cmd := &basiccmd{}+ cmd.hc = hc
+ cmd.bname = "hrt"
+ cmd.bflags = account | acc_resolve
+ cmd.doer = func(data *cmddata) string {+ var account *mastodon.Account
+ if data.reblogger != nil {+ account = &data.reblogger.Account
+ } else {+ account = data.account
+ }
+ relationships, err := hc.client.GetAccountRelationships(context.Background(), []string{string(account.ID)})+ if err != nil {+ return fmt.Sprintf("err loading relationships: %s\n", err)+ }
+ relationship := relationships[0]
+ if !relationship.Following {+ return fmt.Sprintf("can't filter rts from user you don't follow!\n")+ }
+ if relationship.ShowingReblogs {+ _, err := hc.client.AccountFollowDetailed(context.Background(), account.ID, true, relationship.Notifying)
+ if err != nil {+ return "Error updating settings\n"
+ }
+ return fmt.Sprintf("No longer showing RTs from <%s>\n", account.Acct)+ }
+ _, err = hc.client.AccountFollowDetailed(context.Background(), account.ID, false, relationship.Notifying)
+ if err != nil {+ return "Error updating settings\n"
+ }
+ return fmt.Sprintf("Now showing RTs from <%s>\n", account.Acct)+ }
+ 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 {@@ -894,6 +959,7 @@
hc.rmcmd(),
&profilecmd{hc, hc.cmdload}, &dmcmd{hc},+ hc.downloadcmd(),
&helpcmd{hc}, &reloadcmd{hc}, &detachcmd{hc},@@ -909,11 +975,14 @@
hc.pausecmd(),
hc.resumecmd(),
hc.homecmd(),
+ hc.hrtcmd(),
hc.localcmd(),
hc.publiccmd(),
hc.statusurlcmd("open", &hc.preferences.Browser), hc.urlcmd("url", &hc.preferences.Browser), hc.urlcmd("play", &hc.preferences.MediaPlayer),+ hc.mediacmd("view", &hc.preferences.ImageViewer),+ hc.mediacmd("import", &hc.preferences.MediaImport),}
return cmdarray
}
--- a/main.go
+++ b/main.go
@@ -31,6 +31,8 @@
for { func() {line, err := rl.Readline()
+ hc.lock()
+ defer hc.unlock()
command, arguments, found := processInput(line, []string{})@@ -61,9 +63,6 @@
fmt.Printf("Command not found: \"%s\"\n", command)return
}
-
- hc.lock()
- defer hc.unlock()
index, content, _ := strings.Cut(arguments, " ")
--
⑨