UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

95 lines (94 loc) 7.66 kB
import { __decorate } from "tslib"; import { rtfm } from '@twurple/common'; import { EventSubChannelChatAnnouncementNotificationEvent } from "../events/chatNotifications/EventSubChannelChatAnnouncementNotificationEvent.mjs"; import { EventSubChannelChatBitsBadgeTierNotificationEvent } from "../events/chatNotifications/EventSubChannelChatBitsBadgeTierNotificationEvent.mjs"; import { EventSubChannelChatCharityDonationNotificationEvent } from "../events/chatNotifications/EventSubChannelChatCharityDonationNotificationEvent.mjs"; import { EventSubChannelChatCommunitySubGiftNotificationEvent } from "../events/chatNotifications/EventSubChannelChatCommunitySubGiftNotificationEvent.mjs"; import { EventSubChannelChatGiftPaidUpgradeNotificationEvent } from "../events/chatNotifications/EventSubChannelChatGiftPaidUpgradeNotificationEvent.mjs"; import { EventSubChannelChatPayItForwardNotificationEvent } from "../events/chatNotifications/EventSubChannelChatPayItForwardNotificationEvent.mjs"; import { EventSubChannelChatPrimePaidUpgradeNotificationEvent } from "../events/chatNotifications/EventSubChannelChatPrimePaidUpgradeNotificationEvent.mjs"; import { EventSubChannelChatRaidNotificationEvent } from "../events/chatNotifications/EventSubChannelChatRaidNotificationEvent.mjs"; import { EventSubChannelChatResubNotificationEvent } from "../events/chatNotifications/EventSubChannelChatResubNotificationEvent.mjs"; import { EventSubChannelChatSubGiftNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSubGiftNotificationEvent.mjs"; import { EventSubChannelChatSubNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSubNotificationEvent.mjs"; import { EventSubChannelChatUnraidNotificationEvent } from "../events/chatNotifications/EventSubChannelChatUnraidNotificationEvent.mjs"; import { EventSubSubscription } from "./EventSubSubscription.mjs"; import { EventSubChannelChatSharedChatSubNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatSubNotificationEvent.mjs"; import { EventSubChannelChatSharedChatResubNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatResubNotificationEvent.mjs"; import { EventSubChannelChatSharedChatSubGiftNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatSubGiftNotificationEvent.mjs"; import { EventSubChannelChatSharedChatCommunitySubGiftNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatCommunitySubGiftNotificationEvent.mjs"; import { EventSubChannelChatSharedChatGiftPaidUpgradeNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatGiftPaidUpgradeNotificationEvent.mjs"; import { EventSubChannelChatSharedChatPrimePaidUpgradeNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatPrimePaidUpgradeNotificationEvent.mjs"; import { EventSubChannelChatSharedChatPayItForwardNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatPayItForwardNotificationEvent.mjs"; import { EventSubChannelChatSharedChatAnnouncementNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatAnnouncementNotificationEvent.mjs"; import { EventSubChannelChatSharedChatRaidNotificationEvent } from "../events/chatNotifications/EventSubChannelChatSharedChatRaidNotificationEvent.mjs"; /** @internal */ let EventSubChannelChatNotificationSubscription = class EventSubChannelChatNotificationSubscription extends EventSubSubscription { constructor(handler, client, _broadcasterId, _userId) { super(handler, client); this._broadcasterId = _broadcasterId; this._userId = _userId; /** @protected */ this._cliName = 'chat-notification'; } get id() { return `channel.chat.notification.${this._broadcasterId}.${this._userId}`; } get authUserId() { return this._userId; } transformData(data) { switch (data.notice_type) { case 'sub': return new EventSubChannelChatSubNotificationEvent(data, this._client._apiClient); case 'resub': return new EventSubChannelChatResubNotificationEvent(data, this._client._apiClient); case 'sub_gift': return new EventSubChannelChatSubGiftNotificationEvent(data, this._client._apiClient); case 'community_sub_gift': return new EventSubChannelChatCommunitySubGiftNotificationEvent(data, this._client._apiClient); case 'gift_paid_upgrade': return new EventSubChannelChatGiftPaidUpgradeNotificationEvent(data, this._client._apiClient); case 'prime_paid_upgrade': return new EventSubChannelChatPrimePaidUpgradeNotificationEvent(data, this._client._apiClient); case 'raid': return new EventSubChannelChatRaidNotificationEvent(data, this._client._apiClient); case 'unraid': return new EventSubChannelChatUnraidNotificationEvent(data, this._client._apiClient); case 'pay_it_forward': return new EventSubChannelChatPayItForwardNotificationEvent(data, this._client._apiClient); case 'announcement': return new EventSubChannelChatAnnouncementNotificationEvent(data, this._client._apiClient); case 'charity_donation': return new EventSubChannelChatCharityDonationNotificationEvent(data, this._client._apiClient); case 'bits_badge_tier': return new EventSubChannelChatBitsBadgeTierNotificationEvent(data, this._client._apiClient); case 'shared_chat_sub': return new EventSubChannelChatSharedChatSubNotificationEvent(data, this._client._apiClient); case 'shared_chat_resub': return new EventSubChannelChatSharedChatResubNotificationEvent(data, this._client._apiClient); case 'shared_chat_sub_gift': return new EventSubChannelChatSharedChatSubGiftNotificationEvent(data, this._client._apiClient); case 'shared_chat_community_sub_gift': return new EventSubChannelChatSharedChatCommunitySubGiftNotificationEvent(data, this._client._apiClient); case 'shared_chat_gift_paid_upgrade': return new EventSubChannelChatSharedChatGiftPaidUpgradeNotificationEvent(data, this._client._apiClient); case 'shared_chat_prime_paid_upgrade': return new EventSubChannelChatSharedChatPrimePaidUpgradeNotificationEvent(data, this._client._apiClient); case 'shared_chat_pay_it_forward': return new EventSubChannelChatSharedChatPayItForwardNotificationEvent(data, this._client._apiClient); case 'shared_chat_raid': return new EventSubChannelChatSharedChatRaidNotificationEvent(data, this._client._apiClient); case 'shared_chat_announcement': return new EventSubChannelChatSharedChatAnnouncementNotificationEvent(data, this._client._apiClient); default: throw new Error(`Unknown chat notification type: ${data.notice_type}`); } } async _subscribe() { return await this._client._apiClient.asUser(this._userId, async (ctx) => await ctx.eventSub.subscribeToChannelChatNotificationEvents(this._broadcasterId, await this._getTransportOptions())); } }; EventSubChannelChatNotificationSubscription = __decorate([ rtfm('eventsub-base', 'EventSubSubscription') ], EventSubChannelChatNotificationSubscription); export { EventSubChannelChatNotificationSubscription };