diff --git a/src/defs/chat.ts b/src/defs/chat.ts index 6354ce5..e653f1e 100644 --- a/src/defs/chat.ts +++ b/src/defs/chat.ts @@ -75,7 +75,8 @@ export interface IMessageTagComponent { id: number; } -export type MessagePart = IMessageTextComponent +export type MessagePart = + | IMessageTextComponent | IMessageEmoticonComponent | IMessageLinkComponent | IMessageTagComponent; @@ -140,7 +141,6 @@ export interface IUserUpdate { } export interface IPollEvent { - /** * The question being asked. */ @@ -215,6 +215,27 @@ export interface IDeleteMessage { * The message Id. */ id: string; + /** + * The moderator that performed the action. + */ + moderator: { + /** + * The moderator's Id. + */ + user_id: number; + /** + * The moderator's name. + */ + user_name: string; + /** + * The roles the moderator has. + */ + user_roles: string[]; + /** + * The level of the moderator + */ + user_level: number; + }; } export interface IPurgeMessage { @@ -222,6 +243,40 @@ export interface IPurgeMessage { * The user's Id. */ user_id: number; + /** + * The moderator that performed the action. + */ + moderator: { + /** + * The moderator's Id. + */ + user_id: number; + /** + * The moderator's name. + */ + user_name: string; + /** + * The roles the moderator has. + */ + user_roles: string[]; + /** + * The level of the moderator + */ + user_level: number; + }; + /** + * The cause of the purge + */ + cause: { + /** + * The type of action that was performed to cause the purge. + */ + type: 'ban' | 'timeout' | 'globaltimeout'; + /** + * Optional raw length that was passed from the moderator for timeouts. + */ + durationString?: string; + }; } export interface IUserTimeout { @@ -244,3 +299,24 @@ export interface IUserTimeout { */ duration: number; } + +export interface IClearMessage { + clearer: { + /** + * The moderator's Id. + */ + user_id: number; + /** + * The moderator's name. + */ + user_name: string; + /** + * The roles the moderator has. + */ + user_roles: string[]; + /** + * The level of the moderator + */ + user_level: number; + }; +} diff --git a/src/socket/Socket.ts b/src/socket/Socket.ts index b81f48c..9f5be8e 100644 --- a/src/socket/Socket.ts +++ b/src/socket/Socket.ts @@ -3,6 +3,7 @@ import * as NodeWebSocket from 'ws'; import { IChatMessage, + IClearMessage, IDeleteMessage, IPollEvent, IPurgeMessage, @@ -45,9 +46,11 @@ function isNodeWebSocket(socket: any): socket is NodeWebSocket { } function isReactNative() { - return (typeof document === 'undefined' - && typeof navigator !== 'undefined' - && navigator.product === 'ReactNative'); + return ( + typeof document === 'undefined' && + typeof navigator !== 'undefined' && + navigator.product === 'ReactNative' + ); } /** @@ -170,7 +173,7 @@ export class Socket extends EventEmitter { public on(event: 'authresult', cb: (res: IUserAuthenticated) => any): this; public on(event: 'packet', cb: (packet: any) => any): this; public on(event: 'ChatMessage', cb: (message: IChatMessage) => any): this; - public on(event: 'ClearMessages', cb: () => void): this; + public on(event: 'ClearMessages', cb: (clear: IClearMessage) => any): this; public on(event: 'DeleteMessage', cb: (message: IDeleteMessage) => any): this; public on(event: 'PollStart', cb: (poll: IPollEvent) => any): this; public on(event: 'PollEnd', cb: (poll: IPollEvent) => any): this; @@ -618,7 +621,7 @@ export class Socket extends EventEmitter { public call(method: 'whisper', args: [string, string], options?: ICallOptions): Promise; public call(method: 'history', args: [number], options?: ICallOptions): Promise; public call(method: 'timeout', args: [string, string], options?: ICallOptions): Promise; - public call(method: 'optOutEvents', args: (string)[], options?: ICallOptions): Promise; + public call(method: 'optOutEvents', args: string[], options?: ICallOptions): Promise; public call(method: 'ping', args: [any]): Promise; public call(method: 'vote:start', args: [string, string[], number]): Promise; public call(method: string, args: (string | number)[], options?: ICallOptions): Promise;