Skip to content

Commit

Permalink
message: create messages to send to TMI
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrtronium committed Feb 14, 2024
1 parent d2d5e03 commit d97d795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions message/irc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ func elevated(m *tmi.Message) bool {
// not to mention subject to change.
return vip == "1"
}

// ToTMI creates a message to send to TMI. If reply is not empty, then the
// result is a reply to the message with that ID.
func ToTMI(reply, to, text string) *tmi.Message {
r := tmi.Privmsg(to, text)
if reply != "" {
r.Tags = "reply-parent-msg-id=" + reply
}
return r
}
7 changes: 4 additions & 3 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"
)

// Received is a message received from a service.
type Received struct {
// ID is the unique ID of the message.
ID string
Expand All @@ -12,11 +13,11 @@ type Received struct {
To string
// Sender is a unique identifier for the message sender.
Sender string
// Name is the display name of a message sender.
// Name is the display name of the message sender.
Name string
// Text is the text of a message.
// Text is the text of the message.
Text string
// Timestamp is the timestamp of a message as milliseconds since the
// Timestamp is the timestamp of the message as milliseconds since the
// Unix epoch.
Timestamp int64
// IsModerator indicates whether the sender can moderate the room to which
Expand Down

0 comments on commit d97d795

Please sign in to comment.