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

24 lines
769 B
Go
Raw Normal View History

2024-03-10 16:38:18 +00:00
package chat
import (
"log/slog"
2024-03-10 16:38:18 +00:00
"git.sr.ht/~ashkeel/strimertul/database"
2024-03-16 00:20:15 +00:00
"git.sr.ht/~ashkeel/strimertul/log"
2024-03-10 16:38:18 +00:00
)
// 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) {
2024-03-10 16:38:18 +00:00
err := db.PutJSON(WriteMessageRPC, m)
if err != nil {
2024-03-16 00:20:15 +00:00
logger.Error("Failed to write chat message", log.Error(err))
2024-03-10 16:38:18 +00:00
}
}