shithub: hell

Download patch

ref: f4e9104c4dbf329b671e9e5afbb771d141dd9695
parent: cf198b58e2b24938444437dbc7fc6f27f6590b67
author: penny <penny@limitedideas.org>
date: Wed Aug 20 17:18:04 EDT 2025

Working queue with flood control

--- a/dispatch.go
+++ b/dispatch.go
@@ -15,29 +15,45 @@
 	var tootQueue []*mastodon.Toot
 	var lastfire time.Time
 	var lastreceive time.Time
+	var comingfast bool
 	for {
 		select {
 		case statustoot := <-hc.dispatch:
+			//Got multiple lines within a second
+			if time.Since(lastreceive) < time.Second {
+				comingfast = true
+			}
+			lastreceive = time.Now()
 			tootQueue = append(tootQueue, statustoot)
 		default:
-			if len(tootQueue) > 1 {
-				fmt.Printf("Got %v lines fast!\n", len(tootQueue))
-				tootQueue = nil
-			}
 			if 1 > len(tootQueue) {
 				statustoot := <-hc.dispatch
+				if time.Since(lastreceive) < time.Second {
+					comingfast = true
+				}
+				lastreceive = time.Now()
 				tootQueue = append(tootQueue, statustoot)
 				break
 			}
+			if comingfast {
+				if time.Since(lastreceive) < time.Second {
+					//looks like they're still coming
+					break
+				}
+				fmt.Printf("Got %v lines fast!\n", len(tootQueue))
+				tootQueue = nil
+				comingfast = false
+				break
+			}
 			if time.Since(lastfire) < hc.preferences.apidelay {
 				time.Sleep(hc.preferences.apidelay - time.Since(lastfire))
 				break
 			}
-			var status *mastodon.Status
+
 			for _, toot := range tootQueue {
 				lastfire = time.Now()
 				var err error
-				fmt.Printf("%v\n", toot.Status)
+				status, err := postStatusDetailed(*hc.client, *toot)
 				hc.lock()
 				hc.recentpost = status
 				hc.unlock()
--