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:
20
main.go
20
main.go
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user