Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5 from mixer/chore/add-moderator
Browse files Browse the repository at this point in the history
chore: add moderator for purge events
  • Loading branch information
DeekyJay authored Apr 15, 2020
2 parents d0c4980 + f84e89d commit 328477d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
80 changes: 78 additions & 2 deletions src/defs/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export interface IMessageTagComponent {
id: number;
}

export type MessagePart = IMessageTextComponent
export type MessagePart =
| IMessageTextComponent
| IMessageEmoticonComponent
| IMessageLinkComponent
| IMessageTagComponent;
Expand Down Expand Up @@ -140,7 +141,6 @@ export interface IUserUpdate {
}

export interface IPollEvent {

/**
* The question being asked.
*/
Expand Down Expand Up @@ -215,13 +215,68 @@ 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 {
/**
* 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 {
Expand All @@ -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;
};
}
13 changes: 8 additions & 5 deletions src/socket/Socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeWebSocket from 'ws';

import {
IChatMessage,
IClearMessage,
IDeleteMessage,
IPollEvent,
IPurgeMessage,
Expand Down Expand Up @@ -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'
);
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -618,7 +621,7 @@ export class Socket extends EventEmitter {
public call(method: 'whisper', args: [string, string], options?: ICallOptions): Promise<any>;
public call(method: 'history', args: [number], options?: ICallOptions): Promise<IChatMessage[]>;
public call(method: 'timeout', args: [string, string], options?: ICallOptions): Promise<string>;
public call(method: 'optOutEvents', args: (string)[], options?: ICallOptions): Promise<void>;
public call(method: 'optOutEvents', args: string[], options?: ICallOptions): Promise<void>;
public call(method: 'ping', args: [any]): Promise<any>;
public call(method: 'vote:start', args: [string, string[], number]): Promise<void>;
public call(method: string, args: (string | number)[], options?: ICallOptions): Promise<any>;
Expand Down

0 comments on commit 328477d

Please sign in to comment.