From 45a492584a6ff5e1ba68044958c6739517be689f Mon Sep 17 00:00:00 2001 From: Inze Bielderman Date: Mon, 16 Sep 2019 03:50:40 +0200 Subject: [PATCH 1/3] Add code style for JetBrains IDEAs --- .gitignore | 3 ++ .idea/codeStyles/Project.xml | 57 ++++++++++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 +++ 3 files changed, 65 insertions(+) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.gitignore b/.gitignore index 42a4ee2..4b8475a 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,9 @@ typings/ # DynamoDB Local files .dynamodb/ +# Jetbrains Configuration +.idea/* +!.idea/codeStyles # Specific to the tmi.js project diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..92bfce7 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file From 92715fbcf80c83c62741d304235b26d7b6f77ba9 Mon Sep 17 00:00:00 2001 From: Inze Bielderman Date: Mon, 16 Sep 2019 16:34:59 +0200 Subject: [PATCH 2/3] Add notice event handling --- src/client.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/client.ts b/src/client.ts index d57bdc0..b7a5a9e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -84,6 +84,10 @@ export interface Client { * Received a ROOMSTATE command. */ on(event: 'roomstate', listener: (data: MessageData) => void): this; + /** + * Received a NOTICE command. + */ + on(event: 'notice', listener: (data: string) => void): this; emit(event: string, ...data: any); emit(event: 'error', error: Error); @@ -94,6 +98,7 @@ export interface Client { emit(event: 'part', data: PartEvent); emit(event: 'globaluserstate', data: GlobalUserStateEvent); emit(event: 'roomstate', data: MessageData); + emit(event: 'notice', data: string); } export class Client extends EventEmitter { @@ -295,6 +300,9 @@ export class Client extends EventEmitter { this.user = new ClientUser(this, name, tags); this.emit('globaluserstate', { user: this.user }); } + else if (command === 'NOTICE') { + this.emit('notice', data.trailing); + } else { this.emit('unhandled-command', data); } From a711d90cd9e412d6196ed407022e0e245606c6d6 Mon Sep 17 00:00:00 2001 From: Inze Bielderman Date: Mon, 16 Sep 2019 16:59:51 +0200 Subject: [PATCH 3/3] Add NoticeEvent --- src/client.ts | 13 ++++++++----- src/types.ts | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/client.ts b/src/client.ts index b7a5a9e..77de569 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,7 +11,8 @@ import { GlobalUserStateEvent, JoinEvent, PartEvent, - UserStateEvent + UserStateEvent, + NoticeEvent } from './types'; import { Channel, DummyChannel } from './channel'; import { MessageData, ChatMessage } from './message'; @@ -87,7 +88,7 @@ export interface Client { /** * Received a NOTICE command. */ - on(event: 'notice', listener: (data: string) => void): this; + on(event: 'notice', listener: (data: NoticeEvent) => void): this; emit(event: string, ...data: any); emit(event: 'error', error: Error); @@ -98,7 +99,7 @@ export interface Client { emit(event: 'part', data: PartEvent); emit(event: 'globaluserstate', data: GlobalUserStateEvent); emit(event: 'roomstate', data: MessageData); - emit(event: 'notice', data: string); + emit(event: 'notice', data: NoticeEvent); } export class Client extends EventEmitter { @@ -300,8 +301,10 @@ export class Client extends EventEmitter { this.user = new ClientUser(this, name, tags); this.emit('globaluserstate', { user: this.user }); } - else if (command === 'NOTICE') { - this.emit('notice', data.trailing); + else if(command === 'NOTICE') { + this.emit('notice', { + message: data.trailing + }); } else { this.emit('unhandled-command', data); diff --git a/src/types.ts b/src/types.ts index 9e7b8da..b72eb27 100644 --- a/src/types.ts +++ b/src/types.ts @@ -128,11 +128,11 @@ export interface JoinEvent { */ export interface PartEvent { /** - * The channel that the user joined. + * The channel that the user parted. */ channel: Channel; /** - * A user or the client user that joined the channel. + * A user or the client user that parted the channel. */ user: UserOrClientUser; } @@ -155,4 +155,14 @@ export interface UserStateEvent { * The user state that was created or updated with this event. */ state: UserState; +} + +/** + * Received a NOTICE command. + */ +export interface NoticeEvent { + /** + * The message. + */ + message: string; } \ No newline at end of file