Skip to content

Commit

Permalink
Merge pull request #191 from eloonstra/master
Browse files Browse the repository at this point in the history
Add custom-reward-id to PrivateMessage struct
  • Loading branch information
gempir authored Jan 19, 2023
2 parents 002ba5c + b86e603 commit 2d96376
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
29 changes: 15 additions & 14 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,21 @@ func (msg *WhisperMessage) GetType() MessageType {
type PrivateMessage struct {
User User

Raw string
Type MessageType
RawType string
Tags map[string]string
Message string
Channel string
RoomID string
ID string
Time time.Time
Emotes []*Emote
Bits int
Action bool
FirstMessage bool
Reply *Reply
Raw string
Type MessageType
RawType string
Tags map[string]string
Message string
Channel string
RoomID string
ID string
Time time.Time
Emotes []*Emote
Bits int
Action bool
FirstMessage bool
Reply *Reply
CustomRewardID string
}

type Reply struct {
Expand Down
17 changes: 9 additions & 8 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,15 @@ func parsePrivateMessage(message *ircMessage) Message {
privateMessage := PrivateMessage{
User: parseUser(message),

Raw: message.Raw,
Type: parseMessageType(message.Command),
RawType: message.Command,
Tags: message.Tags,
RoomID: message.Tags["room-id"],
ID: message.Tags["id"],
Time: parseTime(message.Tags["tmi-sent-ts"]),
Reply: reply,
Raw: message.Raw,
Type: parseMessageType(message.Command),
RawType: message.Command,
Tags: message.Tags,
RoomID: message.Tags["room-id"],
ID: message.Tags["id"],
Time: parseTime(message.Tags["tmi-sent-ts"]),
Reply: reply,
CustomRewardID: message.Tags["custom-reward-id"],
}

if len(message.Params) == 2 {
Expand Down
24 changes: 24 additions & 0 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,30 @@ func TestCanParsePRIVMSGMessage(t *testing.T) {
},
},
},
{
"Message With Custom Reward ID",
"@badge-info=;badges=vip/1,bits/100;color=#FF69B4;custom-reward-id=ea98be77-c54e-49cd-bc52-d8290cf12ad8;display-name=eloonstra;emotes=;first-msg=0;flags=0-2:S.5;id=c46f5ea8-bbba-499d-a10f-96463d2955c1;mod=0;returning-chatter=0;room-id=75704631;subscriber=0;tmi-sent-ts=1674085692645;turbo=0;user-id=465396358;user-type=;vip=1 :[email protected] PRIVMSG #eloonstra :boing",
PrivateMessage{
User: User{
ID: "465396358",
Name: "eloonstra",
DisplayName: "eloonstra",
Color: "#FF69B4",
Badges: map[string]int{
"vip": 1,
"bits": 100,
},
},
Type: PRIVMSG,
RawType: "PRIVMSG",
Message: "boing",
Channel: "eloonstra",
RoomID: "75704631",
ID: "c46f5ea8-bbba-499d-a10f-96463d2955c1",
FirstMessage: false,
CustomRewardID: "ea98be77-c54e-49cd-bc52-d8290cf12ad8",
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 2d96376

Please sign in to comment.