Add !post command to force-publish next queued story

Typed in a configured channel room, !post pops the head of that channel's
queue and sends immediately, bypassing min-interval, burst cap, and daily
cap. Canonical-URL dedup still applies. Empty queue gets a threaded reply.
This commit is contained in:
prosolis
2026-05-23 14:47:37 -07:00
parent f29c056171
commit 689dc4ef92
3 changed files with 83 additions and 0 deletions

View File

@@ -90,6 +90,26 @@ func (q *Queue) Wait() {
<-q.done
}
// ForcePost pops the next queued item for the given channel and posts it
// immediately, bypassing min-interval, burst cap, and daily cap. Dedup
// (canonical URL cooldown) still applies. Returns true if an item was sent.
func (q *Queue) ForcePost(channel string) bool {
q.mu.Lock()
items := q.queues[channel]
if len(items) == 0 {
q.mu.Unlock()
return false
}
item := items[0]
q.queues[channel] = items[1:]
q.mu.Unlock()
slog.Info("force-posting story on demand",
"guid", item.GUID, "channel", channel)
q.postItem(item)
return true
}
func (q *Queue) drain() {
q.mu.Lock()
channels := make([]string, 0, len(q.queues))