1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-30 02:40:33 +00:00
strimertul/twitch/chat/write.go

22 lines
730 B
Go

package chat
import (
"log/slog"
"git.sr.ht/~ashkeel/strimertul/database"
)
// WriteMessageRequest is an RPC to send a chat message with extra options
type WriteMessageRequest struct {
Message string `json:"message" desc:"Chat message to send"`
ReplyTo string `json:"reply_to,omitempty" desc:"If specified, send as reply to a message ID"`
WhisperTo string `json:"whisper_to,omitempty" desc:"If specified, send as whisper to user ID"`
Announce bool `json:"announce" desc:"If true, send as announcement"`
}
func WriteMessage(db database.Database, logger *slog.Logger, m WriteMessageRequest) {
err := db.PutJSON(WriteMessageRPC, m)
if err != nil {
logger.Error("Failed to write chat message", "error", err)
}
}