UNPKG

fair-twitch

Version:

Fair's Twitch API and Chat bot library

146 lines (145 loc) 7.36 kB
import ExpandedEventEmitter from './ExpandedEventEmitter'; import TwitchIRC from './chat'; interface Recepient { /** The login of the recepient */ login: string; /** The display name of the recepient */ displayName: string; } interface NoticeInterface { /** The login of the user */ login: string; /** The display name of the user */ displayName: string; /** The unique ID of the message from Twitch */ id: string; /** The timestamp of when the message was sent from Twitch */ timestamp: number; } interface SubNotice extends NoticeInterface { /** The system message from Twitch */ systemMsg: string; /** The sub tier. */ tier: 'Prime' | '1000' | '2000' | '3000'; } interface ResubNotice extends NoticeInterface { /** The system message from Twitch */ systemMsg: string; /** The sub tier. */ tier: 'Prime' | '1000' | '2000' | '3000'; /** The message attached to the resub */ msg: string | null; /** The total number of months */ months: number; } interface GiftSubNotice extends NoticeInterface { /** The system message from Twitch */ systemMsg: string; /** The sub tier. */ tier: 'Prime' | '1000' | '2000' | '3000'; /** The number of subs user has given to channel */ senderCount: number; /** The recepient of the giftsub */ recepient: Recepient; } interface MassGiftSubNotice extends NoticeInterface { /** The system message from Twitch */ systemMsg: string; /** The sub tier. */ tier: 'Prime' | '1000' | '2000' | '3000'; /** The number of subs user has given to channel */ senderCount: number; /** The number of the subs that's being gifted */ massCount: number; /** The recepients of the mass giftsub */ recepients: Recepient[]; } interface BitsNotice extends NoticeInterface { /** The number of bits in the message */ bits: number; /** The chat message */ msg: string; } interface NotificationsEmitter { addListener(event: string, listener: (...args: any[]) => void): this; /** When a sub happens */ addListener(event: 'sub', listener: (channel: string, data: SubNotice, tags: any) => void): this; /** When someone announces a resub */ addListener(event: 'resub', listener: (channel: string, data: ResubNotice, tags: any) => void): this; /** When someone gifts another person a sub */ addListener(event: 'giftsub', listener: (channel: string, data: GiftSubNotice, tags: any) => void): this; /** When someone mass gift subs to a channel */ addListener(event: 'massgiftsub', listener: (channel: string, data: MassGiftSubNotice, tags: any) => void): this; /** When someone sends bit message to a channel */ addListener(event: 'bits', listener: (channel: string, data: BitsNotice, tags: any) => void): this; /** When a any notice happens */ addListener(event: 'any', listener: (event: 'sub' | 'resub' | 'giftsub' | 'massgiftsub' | 'bits', channel: string, data: SubNotice | ResubNotice | GiftSubNotice | MassGiftSubNotice | BitsNotice, tags: any) => void): this; on(event: string, listener: (...args: any[]) => void): this; /** When a sub happens */ on(event: 'sub', listener: (channel: string, data: SubNotice, tags: any) => void): this; /** When someone announces a resub */ on(event: 'resub', listener: (channel: string, data: ResubNotice, tags: any) => void): this; /** When someone gifts another person a sub */ on(event: 'giftsub', listener: (channel: string, data: GiftSubNotice, tags: any) => void): this; /** When someone mass gift subs to a channel */ on(event: 'massgiftsub', listener: (channel: string, data: MassGiftSubNotice, tags: any) => void): this; /** When someone sends bit message to a channel */ on(event: 'bits', listener: (channel: string, data: BitsNotice, tags: any) => void): this; /** When a any notice happens */ on(event: 'any', listener: (event: 'sub' | 'resub' | 'giftsub' | 'massgiftsub' | 'bits', channel: string, data: SubNotice | ResubNotice | GiftSubNotice | MassGiftSubNotice | BitsNotice, tags: any) => void): this; once(event: string, listener: (...args: any[]) => void): this; /** When a sub happens */ once(event: 'sub', listener: (channel: string, data: SubNotice, tags: any) => void): this; /** When someone announces a resub */ once(event: 'resub', listener: (channel: string, data: ResubNotice, tags: any) => void): this; /** When someone gifts another person a sub */ once(event: 'giftsub', listener: (channel: string, data: GiftSubNotice, tags: any) => void): this; /** When someone mass gift subs to a channel */ once(event: 'massgiftsub', listener: (channel: string, data: MassGiftSubNotice, tags: any) => void): this; /** When someone sends bit message to a channel */ once(event: 'bits', listener: (channel: string, data: BitsNotice, tags: any) => void): this; /** When a any notice happens */ once(event: 'any', listener: (event: 'sub' | 'resub' | 'giftsub' | 'massgiftsub' | 'bits', channel: string, data: SubNotice | ResubNotice | GiftSubNotice | MassGiftSubNotice | BitsNotice, tags: any) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'sub', channel: string, data: SubNotice, tags: any): boolean; emit(event: 'resub', channel: string, data: ResubNotice, tags: any): boolean; emit(event: 'giftsub', channel: string, data: GiftSubNotice, tags: any): boolean; emit(event: 'massgiftsub', channel: string, data: ResubNotice, tags: any): boolean; emit(event: 'bits', channel: string, data: MassGiftSubNotice, tags: any): boolean; emit(event: 'any', eventName: 'sub' | 'resub' | 'giftsub' | 'massgiftsub' | 'bits', channel: string, data: SubNotice | ResubNotice | GiftSubNotice | MassGiftSubNotice | BitsNotice, tags: any): boolean; } declare class NotificationsEmitter extends ExpandedEventEmitter { twitchIRC: TwitchIRC; giftSubs: any[]; massGifters: any[]; eventID: string; /** * @param twitchIRC The Twitch IRC client */ constructor(twitchIRC: TwitchIRC); /** * Removes all event listeners added from this tracker */ dispose(): void; /** * Emit an 'any' event but also a normal event * @param eventName The name of the event * @param args The args/parameters of the event */ _emitNotification(eventName: string, ...args: any[]): void; /** * Get a dummy notification object * @param eventName The event name (sub, resub, giftsub, massgiftsub, bits, any) * @param channel The optional target channel (default DummyChannel) * @param overwriteData Will overwrite the final object these keys and values */ getDummyNotification(eventName: string, channel?: string, overwriteData?: object): SubNotice | ResubNotice | GiftSubNotice | MassGiftSubNotice | BitsNotice; /** * Emit a dummy notification event (tags will not be included) * @param eventName The event name (sub, resub, giftsub, massgiftsub, bits, any) * @param channel The channel name (optional) * @param overwriteData Will overwrite the final object these keys and values (optional) */ sendDummyNotification(eventName: string, channel: string, overwriteData: object): void; } export = NotificationsEmitter;