shithub: hell

Download patch

ref: ac46bfd916704894c6f4e961eaaf2775b02d18d9
parent: 5b66b4096e7b1cdb74580da41597d69fb93123a1
author: penny <penny@limitedideas.org>
date: Wed Nov 12 16:00:34 EST 2025

finish up on poll rendering

--- a/renderer.go
+++ b/renderer.go
@@ -5,6 +5,7 @@
 	"fmt"
 	"strings"
 	"math"
+	"slices"
 
 	"github.com/k3a/html2text"
 
@@ -230,11 +231,24 @@
 		var sb strings.Builder
 		sb.WriteString("\n")
 		total := poll.status.Poll.VotesCount
-		countstr := fmt.Sprintf("%v votes.\n", total)
+		countstr := fmt.Sprintf("%v votes.", total)
 		if total == 0 { total = 1 }
 		index := "a"
-		for _, item := range poll.status.Poll.Options {
-			sb.WriteString(fmt.Sprintf("%s) %s\n", index, item.Title))
+		show_choices := true
+		if poll.status.Poll.Voted {
+			show_choices = false
+		}
+		
+		for i, item := range poll.status.Poll.Options {
+			voted := " "
+			if slices.Contains(poll.status.Poll.OwnVotes, i) {
+				voted = " (+)"
+			}
+			if show_choices {
+				sb.WriteString(fmt.Sprintf("%s) %s%s\n", index, item.Title, voted))
+			} else {
+				sb.WriteString(fmt.Sprintf("%s%s\n", item.Title, voted))
+			}
 			index = IncrementString(index)
 			percent := math.Round(float64(item.VotesCount) / float64(total) * 100)
 			percentBar := "░░░░░░░░░░"
@@ -243,6 +257,11 @@
 			sb.WriteString(fmt.Sprintf("%s %v%%\n", percentBar, percent))
 		}
 		sb.WriteString(countstr)
+		if poll.status.Poll.Multiple {
+			sb.WriteString(" multichoice.\n")
+		} else {
+			sb.WriteString("\n")
+		}
 		return sb.String()
 	}
 	return ""
--