UNPKG

fair-twitch

Version:

Fair's Twitch API and Chat bot library

86 lines (85 loc) 3.46 kB
import ExpandedEventEmitter from './ExpandedEventEmitter'; import TwitchIRC from './chat'; interface RoomTracker { addListener(event: string, listener: (...args: any[]) => void): this; /** When a channel is joined */ addListener(event: 'join', listener: (channel: string) => void): this; /** When a channel is left */ addListener(event: 'part', listener: (channel: string) => void): this; /** When a channel room state has changed */ addListener(event: 'state', listener: (channel: string, state: RoomState) => void): this; /** When any changes has been made to any room (join, left, room state) */ addListener(event: 'change', listener: (channel: string) => void): this; on(event: string, listener: (...args: any[]) => void): this; /** When a channel is joined */ on(event: 'join', listener: (channel: string) => void): this; /** When a channel is left */ on(event: 'part', listener: (channel: string) => void): this; /** When a channel room state has changed */ on(event: 'state', listener: (channel: string, state: RoomState) => void): this; /** When any changes has been made to any room (join, left, room state) */ on(event: 'change', listener: (channel: string) => void): this; once(event: string, listener: (...args: any[]) => void): this; /** When a channel is joined */ once(event: 'join', listener: (channel: string) => void): this; /** When a channel is left */ once(event: 'part', listener: (channel: string) => void): this; /** When a channel room state has changed */ once(event: 'state', listener: (channel: string, state: RoomState) => void): this; /** When any changes has been made to any room (join, left, room state) */ once(event: 'change', listener: (channel: string) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'join', channel: string): boolean; emit(event: 'part', channel: string): boolean; emit(event: 'state', channel: string, state: RoomState): boolean; emit(event: 'change', channel: string): boolean; } interface RoomState { "room-id"?: string; "emote-only"?: boolean; r9k?: boolean; slow?: number; } interface Room { channel: string; state: RoomState | null; } declare class RoomTracker extends ExpandedEventEmitter { twitchIRC: TwitchIRC; rooms: Room[]; eventID: string; /** * @param twitchIRC The Twitch IRC client */ constructor(twitchIRC: TwitchIRC); /** * Removes all event listeners added from this tracker */ dispose(): void; /** * @param channel The Twitch channel name * @returns If in channel chat room or not */ isInChannel(channel: string): boolean; /** * Get the room state tags * @param channel The Twitch channel name * @returns The room state tags, or null if not in channel or not gotten the state yet */ getChannelState(channel: string): RoomState | null; /** * @returns An array of room objects with channel and state variables */ getChannels(): Room[]; /** * @param channel The Twitch channel name * @returns The internal room object, null if not found */ _getRoomObj(channel: string): Room; /** * @param channel The Twitch channel name * @returns The internal room index, -1 if not found */ _getRoomObjIndex(channel: string): number; } export = RoomTracker;