Deleting a message on the watched channel now deletes the posts it
produced. Making that possible reshapes how a message reaches an output:
- OutputInterface takes an output.Post and returns an output.Ref, the
identifier the platform gave the new post (tweet ID for X, URI and
CID for bluesky). It also gained Delete(Ref).
- The discord package no longer forwards raw MessageCreate values but
a discord.Event carrying the kind of change, so the MessageDelete
handler can use the same channel. Deleted messages arrive without an
author, so only the channel ID can be filtered on.
- The new store package remembers Discord message ID -> per output Ref.
Set POST_STORE to a path to keep that mapping across restarts;
without it the mapping is memory only and a restart makes older
messages undeletable. It holds the most recent 1000 messages.
main.go grows a distributor type to hold the outputs and the store
rather than threading them through the event loop.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
29 lines
690 B
Go
29 lines
690 B
Go
package output
|
|
|
|
type Image struct {
|
|
Data []byte
|
|
ContentType string
|
|
Filename string
|
|
}
|
|
|
|
// Ref identifies a post an output has already published so it can later be
|
|
// deleted. The fields are output specific; only the ones the publishing
|
|
// output filled in are meaningful to it.
|
|
type Ref struct {
|
|
ID string `json:"id,omitempty"` // twitter: tweet ID
|
|
URI string `json:"uri,omitempty"` // bluesky: at:// URI of the record
|
|
CID string `json:"cid,omitempty"` // bluesky: record CID
|
|
}
|
|
|
|
// Post is a single message to distribute.
|
|
type Post struct {
|
|
Text string
|
|
Images []Image
|
|
}
|
|
|
|
type OutputInterface interface {
|
|
Write(Post) (Ref, error)
|
|
Delete(Ref) error
|
|
GetName() string
|
|
}
|