Skip to content

Commit

Permalink
feat: add support for membership gift
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Mar 5, 2022
1 parent bd28373 commit e2d252d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/commands/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function stringifyActions(
text += ": "
}

text += stringify(action.message, { spaces: true })
text += stringify(action.message!, { spaces: true })

simpleChat.push(text)
break
Expand Down
2 changes: 1 addition & 1 deletion src/lib/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ChatHistory {
cid: action.authorChannelId,
oid,
name: action.authorName,
msg: stringify(action.message),
msg: stringify(action.message!),
}
}
insert(action: AddChatItemAction, oid: string) {
Expand Down
40 changes: 38 additions & 2 deletions src/lib/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function printData({
if (chatCount < maxChats) {
log(
chalk.gray(`${action.authorChannelId} ${action.authorName}:`),
stringify(action.message)
stringify(action.message!)
)
chatCount += 1
}
Expand Down Expand Up @@ -110,6 +110,26 @@ export function printData({
)
break
}
case "membershipGiftPurchaseAction": {
log(
chalk.green(
`[membership gift purchase] ${action.authorName} (${
action.membership.status
} ${action.membership.since ?? ""}) gifted ${
action.amount
} memberships for ${action.channelName}`
)
)
break
}
case "membershipGiftRedemptionAction": {
log(
chalk.green(
`[membership gift redemption] ${action.authorName} was gifted a membership by ${action.senderName}`
)
)
break
}
case "addPlaceholderItemAction": {
const id = action.id
const target = history.findOne(id)?.msg
Expand Down Expand Up @@ -197,7 +217,23 @@ ${action.authorName}: ${stringify(action.message)}
break
}
case "addViewerEngagementMessageAction": {
log(chalk.cyan(`[${action.messageType}] ${stringify(action.message)}`))
log(chalk.cyan(`[engagement] ${stringify(action.message)}`))
break
}
case "addPollResultAction": {
log(
chalk.cyan(
`[poll result] Q. ${
action.question ? stringify(action.question) : "<empty>"
}
${action.choices
.map(
(choice, i) =>
`${i + 1}. ${stringify(choice.text)} (${choice.votePercentage})`
)
.join("\n")}`
)
)
break
}
case "modeChangeAction": {
Expand Down

0 comments on commit e2d252d

Please sign in to comment.