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

20
main.go
View File

@@ -6,6 +6,7 @@ import (
"log/slog"
"os"
"os/signal"
"strings"
"syscall"
"time"
@@ -17,6 +18,8 @@ import (
"pete/internal/poster"
"pete/internal/scheduler"
"pete/internal/storage"
"maunium.net/go/mautrix/id"
)
func main() {
@@ -80,6 +83,23 @@ func main() {
exp := explainer.New(mx, ollamaClient)
poster.SetReactionCallback(exp.Handle)
// Wire !post command: force-publish next queued story for the room's channel.
mx.SetMessageHandler(func(channel string, roomID id.RoomID, eventID id.EventID, sender id.UserID, body string) {
if strings.TrimSpace(body) != "!post" {
return
}
slog.Info("!post requested", "channel", channel, "sender", sender)
if queue.ForcePost(channel) {
return
}
if err := mx.PostThreadedReply(channel, eventID,
"nothing queued for "+channel,
"nothing queued for <code>"+channel+"</code>",
); err != nil {
slog.Warn("!post: failed to send empty-queue reply", "err", err)
}
})
// Set up graceful shutdown
ctx, cancel := context.WithCancel(context.Background())
defer cancel()