mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-04 06:42:36 +02:00
ab678f1ef5
It is now possible to receive, send and process client tags in general using the IRC framework. This is useful for many client-oriented IRCv3 features: typing, reacts, replies, channel contexts, etc.
37 lines
989 B
TypeScript
37 lines
989 B
TypeScript
import _ from "lodash";
|
|
|
|
export enum ClientTagKey {
|
|
// https://ircv3.net/specs/client-tags/reply
|
|
DRAFT_REPLY = "draft/reply",
|
|
// https://ircv3.net/specs/client-tags/react
|
|
DRAFT_REACT = "draft/react",
|
|
// https://ircv3.net/specs/client-tags/channel-context
|
|
DRAFT_CHANNEL_CONTEXT = "draft/channel-context",
|
|
|
|
// https://ircv3.net/specs/client-tags/typing.html
|
|
TYPING = "typing",
|
|
}
|
|
|
|
export class ClientTags {
|
|
reaction?: string;
|
|
repliedTo?: string;
|
|
channelContext?: string;
|
|
rawTags: Record<string, string>;
|
|
|
|
public constructor(rawClientTags: Record<string, string>) {
|
|
this.rawTags = rawClientTags;
|
|
|
|
this.reaction = this.get(ClientTagKey.DRAFT_REACT);
|
|
this.repliedTo = this.get(ClientTagKey.DRAFT_REPLY);
|
|
this.channelContext = this.get(ClientTagKey.DRAFT_CHANNEL_CONTEXT);
|
|
}
|
|
|
|
public get(key: string): string | undefined {
|
|
return this.rawTags[`+${key}`];
|
|
}
|
|
|
|
public has(key: string): boolean {
|
|
return Object.prototype.hasOwnProperty.call(this.rawTags, `+${key}`);
|
|
}
|
|
}
|