shithub: hell

Download patch

ref: 7d674e742a31262b0366192c761ade0cd79d59dc
parent: 4e0a9538097ee5d40275d4962735fb2a4a98199c
author: penny <penny@limitedideas.org>
date: Thu Nov 13 05:48:08 EST 2025

add poll creation

--- a/commands.go
+++ b/commands.go
@@ -504,6 +504,7 @@
 	timeSince = timeSince.Round(time.Second)
 	sb.WriteString(fmt.Sprintf("Runtime: %s\n", timeSince.String()))
 	hc.stats.slock.Unlock()
+	sb.WriteString(fmt.Sprintf("%v\n", extractPollOptions(data.content)))
 	return sb.String()
 }
 
--- a/help.go
+++ b/help.go
@@ -91,6 +91,8 @@
   ?sensitive                   Mark status material as sensitive.
   ?markdown                    Sets post content_type. Only for supported servers.
   ?html                        Sets post content_type. Only for supported servers.
+  ?poll="dogs, cats"           Creates a poll with options, comma separated.
+                               Double comma escapes.
 `
 	return fmt.Sprintf(helpstring, configpath)
 }
--- a/mastodon.go
+++ b/mastodon.go
@@ -74,11 +74,42 @@
 	return c
 }
 
+func extractPollOptions(line string) []string {
+	optraw := strings.Split(line, ",")
+	var opts []string
+	for i :=0 ; i < len(optraw) ; i++ {
+		//if the field was empty (double ,,)
+		if(len(optraw[i]) == 0) {
+			//nothing to add this to yet
+			if len(opts) == 0 {
+				i++
+				if i > len(optraw) {
+					opts = append(opts, ",")
+				} else {
+					opts = append(opts, "," + optraw[i])
+				}
+			}
+			i++
+			if i > len(optraw) {
+				opts[i] = opts[i] + ","
+			} else {
+				opts[i-2] = opts[i-2] + "," + optraw[i]
+			}
+		} else {
+			opts = append(opts, optraw[i])
+		}
+	}
+	return opts
+}
+
 func processStatusHints(toot *mastodon.Toot, postpointer *string) {
 	posttext := *postpointer
 	posttext, hints := extractInputParameters(posttext)
 	toot.Status = posttext
-
+	poll := &mastodon.TootPoll{}
+	
+	duration := int64((24 * time.Hour).Seconds())
+	poll.ExpiresInSeconds = duration
 	for _, arg := range hints {
 		if len(arg) == 0 {
 			continue
@@ -104,6 +135,10 @@
 			toot.ContentType = "text/markdown"
 		case "html":
 			toot.ContentType = "text/html"
+		case "poll":
+			options := extractPollOptions(val)
+			poll.Options = options
+			toot.Poll = poll
 		}
 	}
 	*postpointer = posttext
--- a/web/readme.md
+++ b/web/readme.md
@@ -34,6 +34,7 @@
 * Posting
 * Rebloging
 * Status editing
+* Polls, viewing voting, creation
 * Account info page
 * Account RT filtering
 * Timeline pausing
--