shithub: hell

Download patch

ref: 1a285e71a303add704a835eb7b49010b53cdac82
parent: 4ac887f80318dd1be078aa887a12699ad3364f5c
author: penny <penny@limitedideas.org>
date: Tue Sep 23 10:06:03 EDT 2025

More stats, runtime pph

--- a/hellclient.go
+++ b/hellclient.go
@@ -7,6 +7,7 @@
 	"os"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/ergochat/readline"
 	"github.com/mattn/go-mastodon"
@@ -53,6 +54,7 @@
 	slock            sync.Mutex
 	APICalls         int64
 	IncomingStatuses int64
+	StartedTime      time.Time
 }
 
 // Use this to make private versions of runes to stop default behavior
@@ -144,6 +146,8 @@
 		for _, status := range statuses {
 			hc.printAndIncrement(hc.ctxref, status)
 		}
+		//Record start time when everything is set up and connected
+		hc.stats.StartedTime = time.Now()
 	}()
 
 	homeMap := make(map[string]*mastodon.Status)
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@
 	"os/exec"
 	"strconv"
 	"strings"
+	"time"
 
 	"github.com/k3a/html2text"
 	"github.com/mattn/go-mastodon"
@@ -104,7 +105,16 @@
 			switch command {
 			case "stats":
 				hc.stats.slock.Lock()
-				fmt.Printf("API Calls: %v\nStatuses received: %v\n", hc.stats.APICalls, hc.stats.IncomingStatuses)
+				var sb strings.Builder
+				sb.WriteString(fmt.Sprintf("API Calls: %d\n", hc.stats.APICalls))
+				sb.WriteString(fmt.Sprintf("Statuses Received: %d\n", hc.stats.IncomingStatuses))
+				sb.WriteString("Statuses per hour:")
+				sb.WriteString(fmt.Sprintf("%.2f\n", float32(hc.stats.IncomingStatuses) / (float32(time.Since(hc.stats.StartedTime)) / float32(time.Hour))))
+				sb.WriteString(fmt.Sprintf("Started At: %s\n", hc.stats.StartedTime))
+				timeSince := time.Since(hc.stats.StartedTime)
+				timeSince = timeSince.Round(time.Second)
+				sb.WriteString(fmt.Sprintf("Runtime: %s\n", timeSince.String()))
+				fmt.Printf(sb.String())
 				hc.stats.slock.Unlock()
 				return
 			case "notice":
--