diff options
author | RaindropsSys <contact@minteck.org> | 2023-07-13 18:33:38 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-07-13 18:33:38 +0200 |
commit | e89e57713dacb77a16ae0f8cef3fb5cbee5927c9 (patch) | |
tree | fdd05cc9e22d6559d6f86be2e7eba1649e28732d | |
parent | 219c1f032c96907d839d0fc1d1343e598b914506 (diff) | |
download | signal.js-e89e57713dacb77a16ae0f8cef3fb5cbee5927c9.tar.gz signal.js-e89e57713dacb77a16ae0f8cef3fb5cbee5927c9.tar.bz2 signal.js-e89e57713dacb77a16ae0f8cef3fb5cbee5927c9.zip |
Updated 66 files, added 138 files, deleted 2 files and renamed classes/ReactionEmoji.ts (automated)
207 files changed, 1945 insertions, 185 deletions
@@ -1 +1,2 @@ -demo
\ No newline at end of file +demo +test.js
\ No newline at end of file @@ -1,47 +1,50 @@ # signal.js 1.0 roadmap -* [ ] Receiving messages +* [x] <s>Receiving messages</s> * [x] <s>Typing messages</s> * [x] <s>Text messages</s> - * [x] <s>Attachments</s> - * [x] <s>Replies</s> - * [ ] Formatting - * [ ] Stickers - * [ ] Voice messages + * [x] <s>Attachments</s> + * [x] <s>Replies</s> + * [x] <s>Formatting</s> + * [x] <s>Stickers</s> + * [x] <s>Voice messages</s> * [x] <s>Marking as read</s> * [x] <s>Reactions</s> -* [ ] Sending messages - * [x] <s>Text</s> - * [ ] Attachments - * [ ] Replies - * [ ] Formatting (Markdown?) - * [ ] Typing status -* [ ] Registration - * [ ] Captchas - * [ ] SMS registration - * [ ] Voice registration - * [ ] Linking to another device - * [ ] Adding/changing/removing PIN + * [x] <s>Edits</s> + * [x] <s>Deletions</s> + * [x] <s>URL preview</s> + * [x] <s>Mentions</s> +* [x] <s>Sending messages</s> + * [x] <s>Text</s> + * [x] <s>Attachments</s> + * [x] <s>Replies</s> + * [x] <s>Formatting</s> + * [x] <s>Typing status</s> + * [x] <s>Stickers</s> + * [x] <s>Edits</s> + * [x] <s>Deletions</s> + * [x] <s>URL preview</s> + * [x] <s>Mentions</s> * [ ] Users - * [ ] (Un)Blocking - * [ ] Trusting - * [ ] Adding + * [ ] (Un)Blocking + * [ ] Trusting + * [ ] Adding * [ ] Groups - * [ ] Creating - * [ ] Updating - * [ ] Leave - * [ ] Join (from an invite link) + * [ ] Creating + * [ ] Updating + * [ ] Leave + * [ ] Join (from an invite link) * [ ] Profile - * [ ] Avatar - * [ ] Name - * [ ] Status (emoji + text) - * [ ] Sticker packs - * [ ] Configuration - * [ ] Adding/removing linked devices + * [ ] Avatar + * [ ] Name + * [ ] Status (emoji + text) + * [ ] Sticker packs + * [ ] Configuration + * [ ] Adding/removing linked devices * [ ] Listings - * [ ] Known contacts - * [ ] Linked devices - * [ ] Groups - * [ ] Known identities - * [ ] Check if a phone number is on Signal - * [ ] Sticker packs
\ No newline at end of file + * [ ] Known contacts + * [ ] Linked devices + * [ ] Groups + * [ ] Known identities + * [ ] Check if a phone number is on Signal + * [ ] Sticker packs
\ No newline at end of file diff --git a/classes/AttachmentBuilder.ts b/classes/AttachmentBuilder.ts new file mode 100644 index 0000000..a7d4b18 --- /dev/null +++ b/classes/AttachmentBuilder.ts @@ -0,0 +1,26 @@ +import {IFilePath} from "../types/IFilePath"; +import {IDataURI} from "../types/IDataURI"; +import {IAttachmentBuilderData} from "../types/IAttachmentBuilderData"; +import {lstatSync} from "fs"; + +export class AttachmentBuilder { + public uri: IFilePath|IDataURI; + + constructor(data: IFilePath|IDataURI|IAttachmentBuilderData) { + if (typeof data === "string") { + if (!data.startsWith("data:")) { + lstatSync(data); + } + + this.uri = data; + } else { + let type = data.type ?? "application/octet-stream"; + + if (data.fileName) { + this.uri = `data:${type};filename=${data.fileName.replaceAll(";", "\\;")};base64,${data.data.toString("base64")}`; + } else { + this.uri = `data:${type};base64,${data.data.toString("base64")}`; + } + } + } +}
\ No newline at end of file diff --git a/classes/AttachmentSize.ts b/classes/AttachmentSize.ts index 474e2b7..20572a5 100644 --- a/classes/AttachmentSize.ts +++ b/classes/AttachmentSize.ts @@ -2,4 +2,8 @@ export class AttachmentSize extends Number { constructor(props) { super(props); } + + public toBits(): number { + return parseInt(this.toString()) * 8; + } }
\ No newline at end of file diff --git a/classes/CLIDispatcher.ts b/classes/CLIDispatcher.ts index 4363423..965b989 100644 --- a/classes/CLIDispatcher.ts +++ b/classes/CLIDispatcher.ts @@ -18,7 +18,6 @@ export class CLIDispatcher { let data = JSON.parse(raw.toString()); if (data.id === id) { - console.log(data); res(data); proc.stdout.removeListener("data", callback); } diff --git a/classes/CLIEvent.ts b/classes/CLIEvent.ts index 0e35263..e605641 100644 --- a/classes/CLIEvent.ts +++ b/classes/CLIEvent.ts @@ -9,6 +9,13 @@ import {DMDataMessage} from "./DMDataMessage"; import {UserDataType} from "../enums/UserDataType"; import {DMReactionMessage} from "./DMReactionMessage"; import {GroupReactionMessage} from "./GroupReactionMessage"; +import {CLIDispatcher} from "./CLIDispatcher"; +import {DMStickerMessage} from "./DMStickerMessage"; +import {GroupStickerMessage} from "./GroupStickerMessage"; +import {DMEditMessage} from "./DMEditMessage"; +import {GroupEditMessage} from "./GroupEditMessage"; +import {GroupDeleteMessage} from "./GroupDeleteMessage"; +import {DMDeleteMessage} from "./DMDeleteMessage"; /** * A signal-cli event @@ -19,7 +26,7 @@ export class CLIEvent { if (data.method === "receive") { if (data.params.envelope.typingMessage) { - console.log(data.params.envelope.typingMessage); + if (client.verbose) console.log(data.params.envelope.typingMessage); if (data.params.envelope.typingMessage.groupId) { let message: GroupTypingMessage = new GroupTypingMessage( @@ -41,10 +48,58 @@ export class CLIEvent { client.emit("typingMessage", message); } + } else if (data.params.envelope.editMessage) { + if (client.verbose) console.log(data.params.envelope.editMessage); + + if (data.params.envelope.editMessage.dataMessage.groupInfo) { + let message: GroupEditMessage = new GroupEditMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.editMessage.dataMessage, + data.params.envelope.editMessage.dataMessage.timestamp, + data.params.envelope.editMessage.dataMessage.groupInfo.groupId, + data.params.envelope.editMessage.targetSentTimestamp, + client + ); + + client.emit("editMessage", message); + } else { + let message: DMEditMessage = new DMEditMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.editMessage.dataMessage, + data.params.envelope.editMessage.dataMessage.timestamp, + data.params.envelope.editMessage.targetSentTimestamp, + client + ); + + client.emit("editMessage", message); + } } else if (data.params.envelope.dataMessage) { - console.log(data.params.envelope.dataMessage); + if (client.verbose) console.log(data.params.envelope.dataMessage); + + if (data.params.envelope.dataMessage.remoteDelete) { + if (data.params.envelope.dataMessage.groupInfo) { + let message: GroupDeleteMessage = new GroupDeleteMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.dataMessage, + data.params.envelope.dataMessage.timestamp, + data.params.envelope.dataMessage.groupInfo.groupId, + client, + data.params.envelope.dataMessage.remoteDelete.timestamp + ); + + client.emit("deleteMessage", message); + } else { + let message: DMDeleteMessage = new DMDeleteMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.dataMessage, + data.params.envelope.dataMessage.timestamp, + client, + data.params.envelope.dataMessage.remoteDelete.timestamp + ); - if (data.params.envelope.dataMessage.reaction) { + client.emit("deleteMessage", message); + } + } else if (data.params.envelope.dataMessage.reaction) { if (data.params.envelope.dataMessage.groupInfo) { let message: GroupReactionMessage = new GroupReactionMessage( new User(data.params.envelope, UserDataType.Envelope), @@ -77,6 +132,31 @@ export class CLIEvent { client.emit("reactionAdd", message); } } + } else if (data.params.envelope.dataMessage.sticker) { + CLIDispatcher.dispatch("listStickerPacks", {}, client.process).then((cliData) => { + client.stickerPacks['list'] = cliData.result; + + if (data.params.envelope.dataMessage.groupInfo) { + let message: GroupStickerMessage = new GroupStickerMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.dataMessage, + data.params.envelope.dataMessage.timestamp, + data.params.envelope.dataMessage.groupInfo.groupId, + client + ); + + client.emit("sticker", message); + } else { + let message: DMStickerMessage = new DMStickerMessage( + new User(data.params.envelope, UserDataType.Envelope), + data.params.envelope.dataMessage, + data.params.envelope.dataMessage.timestamp, + client + ); + + client.emit("sticker", message); + } + }) } else { if (data.params.envelope.dataMessage.groupInfo) { let message: GroupDataMessage = new GroupDataMessage( @@ -102,8 +182,4 @@ export class CLIEvent { } } } - - static fromResponse(client: Client, data: ICLIResponse) { - console.log(data); - } }
\ No newline at end of file diff --git a/classes/Channel.ts b/classes/Channel.ts new file mode 100644 index 0000000..8ad70eb --- /dev/null +++ b/classes/Channel.ts @@ -0,0 +1,13 @@ +import {IChatMessageOptions} from "../types/IChatMessageOptions"; +import {SentDataMessage} from "./SentDataMessage"; + +export class Channel { + public group: boolean; + public id: string; + + constructor() {} + // @ts-ignore + public async send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage> {} + + public async setTyping(typing: boolean): Promise<void> {} +}
\ No newline at end of file diff --git a/classes/Chat.ts b/classes/Chat.ts deleted file mode 100644 index d876782..0000000 --- a/classes/Chat.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {ChatMessageOptions} from "./ChatMessageOptions"; - -export class Chat { - public group: boolean; - public id: string; - - constructor() {} - async send(text: string, options?: ChatMessageOptions) {} -}
\ No newline at end of file diff --git a/classes/ChatMessageOptions.ts b/classes/ChatMessageOptions.ts deleted file mode 100644 index 7227184..0000000 --- a/classes/ChatMessageOptions.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class ChatMessageOptions { - constructor() {} -}
\ No newline at end of file diff --git a/classes/Client.ts b/classes/Client.ts index ca5d794..548d57f 100644 --- a/classes/Client.ts +++ b/classes/Client.ts @@ -10,22 +10,33 @@ import {DMDataMessage} from "./DMDataMessage"; import {GroupDataMessage} from "./GroupDataMessage"; import {GroupReactionMessage} from "./GroupReactionMessage"; import {DMReactionMessage} from "./DMReactionMessage"; +import {ObjectCache} from "./ObjectCache"; +import {GroupStickerMessage} from "./GroupStickerMessage"; +import {DMStickerMessage} from "./DMStickerMessage"; +import {DMEditMessage} from "./DMEditMessage"; +import {GroupEditMessage} from "./GroupEditMessage"; +import {GroupDeleteMessage} from "./GroupDeleteMessage"; +import {DMDeleteMessage} from "./DMDeleteMessage"; export declare interface Client { on(event: "cliEvent", listener: (event: ICLIEvent) => void): this; on(event: "typingMessage", listener: (message: GroupTypingMessage|DMTypingMessage) => void): this; on(event: "message", listener: (message: GroupDataMessage|DMDataMessage) => void): this; + on(event: "editMessage", listener: (message: GroupEditMessage|DMEditMessage) => void): this; on(event: "reaction", listener: (message: GroupReactionMessage|DMReactionMessage) => void): this; on(event: "reactionAdd", listener: (message: GroupReactionMessage|DMReactionMessage) => void): this; on(event: "reactionRemove", listener: (message: GroupReactionMessage|DMReactionMessage) => void): this; + on(event: "sticker", listener: (message: GroupStickerMessage|DMStickerMessage) => void): this; + on(event: "deleteMessage", listener: (message: GroupDeleteMessage|DMDeleteMessage) => void): this; } /** * The base signal.js client */ export class Client extends EventEmitter { - private process: ChildProcess; - public _process: ChildProcess; + public process: ChildProcess; + public stickerPacks: ObjectCache = {}; + public verbose: boolean = false; constructor(config: IConfig) { super(); @@ -41,11 +52,12 @@ export class Client extends EventEmitter { if (typeof config.verbose === "number") parameters.push(...Array(config.verbose).fill("--verbose")); if (config.environment) parameters.push("--service-environment", config.environment); if (config.trustLevel) parameters.push("--trust-new-identities", config.trustLevel); + if (config.logEvents) this.verbose = true; parameters.push("--account", config.account); parameters.push("jsonRpc"); - this.process = this._process = spawn(command, parameters, config.system?.spawn ?? { + this.process = spawn(command, parameters, config.system?.spawn ?? { stdio: "pipe", windowsHide: true }); diff --git a/classes/DM.ts b/classes/DM.ts index f1fb0e9..e327b35 100644 --- a/classes/DM.ts +++ b/classes/DM.ts @@ -1,12 +1,15 @@ -import {Chat} from "./Chat"; -import {ChatMessageOptions} from "./ChatMessageOptions"; +import {Channel} from "./Channel"; import {CLIDispatcher} from "./CLIDispatcher"; import {Client} from "./Client"; +import {IChatMessageOptions} from "../types/IChatMessageOptions"; +import {SentDataMessage} from "./SentDataMessage"; +import {channel} from "diagnostics_channel"; +import {Sticker} from "./Sticker"; -export class DM extends Chat { +export class DM extends Channel { public group: boolean = false; public id: string; - private number: string; + public number: string; private client: Client; constructor(userId: string, number: string, client: Client) { @@ -16,14 +19,50 @@ export class DM extends Chat { this.client = client; } - public async send(text: string, options?: ChatMessageOptions): Promise<void> { + public async send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage> { + let data = await CLIDispatcher.dispatch( + "send", + { + recipient: [this.number], + message: text, + attachment: options?.attachments?.map(i => i.uri) ?? [], + quoteTimestamp: options?.quote?.build().createdTimestamp, + quoteAuthor: options?.quote?.build().author.number, + quoteMessage: options?.quote?.build().content, + editTimestamp: options?.original, + previewUrl: options?.preview?.url, + previewTitle: options?.preview?.title, + previewDescription: options?.preview?.description, + previewImage: options?.preview?.image, + textStyle: options?.formatting?.rules.map(rule => rule.toCLIFormat()), + mention: options?.mentions?.map(rule => rule.toCLIFormat()) + }, + this.client.process + ); + + let timestamp = data.result?.timestamp; + return new SentDataMessage(timestamp, this, this.client, text, options); + } + + public async setTyping(typing: boolean): Promise<void> { + await CLIDispatcher.dispatch( + "sendTyping", + { + recipient: [this.number], + stop: !typing + }, + this.client.process + ); + } + + public async sendSticker(sticker: Sticker): Promise<void> { await CLIDispatcher.dispatch( "send", { recipient: [this.number], - message: text + sticker: sticker.pack.id + ":" + sticker.id }, - this.client._process - ) + this.client.process + ); } }
\ No newline at end of file diff --git a/classes/DMDataMessage.ts b/classes/DMDataMessage.ts index 288162d..b09d458 100644 --- a/classes/DMDataMessage.ts +++ b/classes/DMDataMessage.ts @@ -1,7 +1,4 @@ import {User} from "./User"; -import {ReceivedMessage} from "./ReceivedMessage"; -import {GroupMessage} from "./GroupMessage"; -import {Group} from "./Group"; import {DMMessage} from "./DMMessage"; import {DM} from "./DM"; import {Client} from "./Client"; @@ -10,6 +7,14 @@ import {Attachment} from "./Attachment"; import {QuoteMessage} from "./QuoteMessage"; import {CLIDispatcher} from "./CLIDispatcher"; import {MessageReceipt} from "../enums/MessageReceipt"; +import {MessageFormatting} from "./MessageFormatting"; +import {MessageFormattingFormat} from "../enums/MessageFormattingFormat"; +import {UserMention} from "./UserMention"; +import {UserDataType} from "../enums/UserDataType"; +import {ReceivedURLPreview} from "./ReceivedURLPreview"; +import {IChatMessageURLPreview} from "../types/IChatMessageURLPreview"; +import {ISentMessageURLPreview} from "../types/ISentMessageURLPreview"; +import {IReceivedMessageURLPreview} from "../types/IReceivedMessageURLPreview"; /** * A data message as sent by Signal @@ -17,6 +22,9 @@ import {MessageReceipt} from "../enums/MessageReceipt"; export class DMDataMessage extends DMMessage implements DataMessage { public content?: string; public attachments: Attachment[] = []; + public mentions: UserMention[] = []; + public previews: IReceivedMessageURLPreview[] = []; + public formatting: MessageFormatting; public quote?: QuoteMessage; constructor(user: User, data: any, time: number, client: Client) { @@ -24,6 +32,9 @@ export class DMDataMessage extends DMMessage implements DataMessage { this.content = data.message && data.message.trim().length > 0 ? data.message : null; if (data.quote) this.quote = new QuoteMessage(data.quote); this.attachments = data.attachments?.map(i => new Attachment(i)); + this.formatting = new MessageFormatting(data.message && data.message.trim().length > 0 ? data.message : "", data.textStyles); + this.mentions = data.mentions?.map(mention => new UserMention(new User(UserDataType.Mention, mention), mention.start, mention.length)); + this.previews = data.previews?.map(preview => (new ReceivedURLPreview(preview)).build()); } public async markAsRead() { @@ -34,7 +45,7 @@ export class DMDataMessage extends DMMessage implements DataMessage { targetTimestamp: this.createdTimestamp, type: MessageReceipt.Read }, - this.client._process + this.client.process ) } @@ -46,7 +57,7 @@ export class DMDataMessage extends DMMessage implements DataMessage { targetTimestamp: this.createdTimestamp, type: MessageReceipt.Viewed }, - this.client._process + this.client.process ) } } diff --git a/classes/DMDeleteMessage.ts b/classes/DMDeleteMessage.ts new file mode 100644 index 0000000..85b1826 --- /dev/null +++ b/classes/DMDeleteMessage.ts @@ -0,0 +1,22 @@ +import {User} from "./User"; +import {DMMessage} from "./DMMessage"; +import {DM} from "./DM"; +import {Client} from "./Client"; +import {Sticker} from "./Sticker"; +import {StickerMessage} from "./StickerMessage"; +import {StickerSource} from "../enums/StickerSource"; +import {DeleteMessage} from "./DeleteMessage"; + +/** + * A deletion message as sent by Signal + */ +export class DMDeleteMessage extends DMMessage implements DeleteMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; + + constructor(user: User, data: any, time: number, client: Client, originalTime: number) { + super(user, time, new DM(user.uuid, user.number, client), client, data.expiresInSeconds); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +}
\ No newline at end of file diff --git a/classes/DMEditMessage.ts b/classes/DMEditMessage.ts new file mode 100644 index 0000000..5581799 --- /dev/null +++ b/classes/DMEditMessage.ts @@ -0,0 +1,27 @@ +import {User} from "./User"; +import {DMMessage} from "./DMMessage"; +import {DM} from "./DM"; +import {Client} from "./Client"; +import {DataMessage} from "./DataMessage"; +import {Attachment} from "./Attachment"; +import {QuoteMessage} from "./QuoteMessage"; +import {CLIDispatcher} from "./CLIDispatcher"; +import {MessageReceipt} from "../enums/MessageReceipt"; +import {MessageFormatting} from "./MessageFormatting"; +import {MessageFormattingFormat} from "../enums/MessageFormattingFormat"; +import {DMDataMessage} from "./DMDataMessage"; +import {EditMessage} from "./EditMessage"; + +/** + * An edit message as sent by Signal + */ +export class DMEditMessage extends DMDataMessage implements EditMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; + + constructor(user: User, data: any, time: number, originalTime: number, client: Client) { + super(user, data, time, client); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} diff --git a/classes/DMReactionMessage.ts b/classes/DMReactionMessage.ts index e890338..8f9a60a 100644 --- a/classes/DMReactionMessage.ts +++ b/classes/DMReactionMessage.ts @@ -5,7 +5,7 @@ import {Group} from "./Group"; import {DMMessage} from "./DMMessage"; import {DM} from "./DM"; import {Client} from "./Client"; -import {ReactionEmoji} from "./ReactionEmoji"; +import {Emoji} from "./Emoji"; import {ReactionTarget} from "./ReactionTarget"; import {ReactionMessage} from "./ReactionMessage"; @@ -13,14 +13,14 @@ import {ReactionMessage} from "./ReactionMessage"; * A reaction message as sent by Signal */ export class DMReactionMessage extends DMMessage implements ReactionMessage { - public emoji: ReactionEmoji; + public emoji: Emoji; public removed: boolean; public target: ReactionTarget; constructor(user: User, data: any, time: number, client: Client) { super(user, time, new DM(user.uuid, user.number, client), client, data.expiresInSeconds); this.removed = data.reaction.isRemove; - this.emoji = new ReactionEmoji(data.reaction.emoji); + this.emoji = new Emoji(data.reaction.emoji); this.target = new ReactionTarget(data, this.channel, client); } }
\ No newline at end of file diff --git a/classes/DMStickerMessage.ts b/classes/DMStickerMessage.ts new file mode 100644 index 0000000..b15eb39 --- /dev/null +++ b/classes/DMStickerMessage.ts @@ -0,0 +1,19 @@ +import {User} from "./User"; +import {DMMessage} from "./DMMessage"; +import {DM} from "./DM"; +import {Client} from "./Client"; +import {Sticker} from "./Sticker"; +import {StickerMessage} from "./StickerMessage"; +import {StickerSource} from "../enums/StickerSource"; + +/** + * A sticker message as sent by Signal + */ +export class DMStickerMessage extends DMMessage implements StickerMessage { + public sticker: Sticker; + + constructor(user: User, data: any, time: number, client: Client) { + super(user, time, new DM(user.uuid, user.number, client), client, data.expiresInSeconds); + this.sticker = new Sticker(StickerSource.Received, data.sticker, client); + } +}
\ No newline at end of file diff --git a/classes/DataMessage.ts b/classes/DataMessage.ts index d699507..5f80b0a 100644 --- a/classes/DataMessage.ts +++ b/classes/DataMessage.ts @@ -1,8 +1,15 @@ import {Attachment} from "./Attachment"; import {QuoteMessage} from "./QuoteMessage"; +import {MessageFormatting} from "./MessageFormatting"; +import {UserMention} from "./UserMention"; +import {IChatMessageURLPreview} from "../types/IChatMessageURLPreview"; +import {IReceivedMessageURLPreview} from "../types/IReceivedMessageURLPreview"; export class DataMessage { public content?: string; public attachments: Attachment[] = []; + public mentions: UserMention[] = []; + public previews: IReceivedMessageURLPreview[] = []; + public formatting: MessageFormatting; public quote?: QuoteMessage; }
\ No newline at end of file diff --git a/classes/DeleteMessage.ts b/classes/DeleteMessage.ts new file mode 100644 index 0000000..c231ec5 --- /dev/null +++ b/classes/DeleteMessage.ts @@ -0,0 +1,10 @@ +import {Attachment} from "./Attachment"; +import {QuoteMessage} from "./QuoteMessage"; +import {Emoji} from "./Emoji"; +import {ReactionTarget} from "./ReactionTarget"; +import {Sticker} from "./Sticker"; + +export class DeleteMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; +}
\ No newline at end of file diff --git a/classes/EditMessage.ts b/classes/EditMessage.ts new file mode 100644 index 0000000..b5fed51 --- /dev/null +++ b/classes/EditMessage.ts @@ -0,0 +1,9 @@ +import {Attachment} from "./Attachment"; +import {QuoteMessage} from "./QuoteMessage"; +import {MessageFormatting} from "./MessageFormatting"; +import {DataMessage} from "./DataMessage"; + +export class EditMessage extends DataMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; +}
\ No newline at end of file diff --git a/classes/ReactionEmoji.ts b/classes/Emoji.ts index 6b755d6..47425d0 100644 --- a/classes/ReactionEmoji.ts +++ b/classes/Emoji.ts @@ -1,4 +1,4 @@ -export class ReactionEmoji extends String { +export class Emoji extends String { constructor(props) { super(props); } diff --git a/classes/Group.ts b/classes/Group.ts index 33be799..cdbf41f 100644 --- a/classes/Group.ts +++ b/classes/Group.ts @@ -1,9 +1,11 @@ -import {Chat} from "./Chat"; +import {Channel} from "./Channel"; import {Client} from "./Client"; -import {ChatMessageOptions} from "./ChatMessageOptions"; import {CLIDispatcher} from "./CLIDispatcher"; +import {IChatMessageOptions} from "../types/IChatMessageOptions"; +import {SentDataMessage} from "./SentDataMessage"; +import {Sticker} from "./Sticker"; -export class Group extends Chat { +export class Group extends Channel { public group: boolean = true; public id: string; private client: Client; @@ -14,15 +16,61 @@ export class Group extends Chat { this.client = client; } - public async send(text: string, options?: ChatMessageOptions): Promise<void> { + public async send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage> { let groupData = await CLIDispatcher.dispatch( "listGroups", + {}, + this.client.process + ); + + let data = await CLIDispatcher.dispatch( + "send", { - group: [this.id], - recipient: [], - message: text + groupId: this.id, + recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), + message: text, + attachment: options?.attachments?.map(i => i.uri) ?? [], + quoteTimestamp: options?.quote?.build().createdTimestamp, + quoteAuthor: options?.quote?.build().author.number, + quoteMessage: options?.quote?.build().content, + editTimestamp: options?.original, + previewUrl: options?.preview?.url, + previewTitle: options?.preview?.title, + previewDescription: options?.preview?.description, + previewImage: options?.preview?.image, + textStyle: options?.formatting?.rules.map(rule => rule.toCLIFormat()), + mention: options?.mentions?.map(rule => rule.toCLIFormat()) }, - this.client._process + this.client.process + ); + + let timestamp = data.result?.timestamp; + return new SentDataMessage(timestamp, this, this.client, text, options); + } + + public async setTyping(typing: boolean): Promise<void> { + let groupData = await CLIDispatcher.dispatch( + "listGroups", + {}, + this.client.process + ); + + await CLIDispatcher.dispatch( + "sendTyping", + { + groupId: this.id, + recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), + stop: !typing + }, + this.client.process + ); + } + + public async sendSticker(sticker: Sticker): Promise<void> { + let groupData = await CLIDispatcher.dispatch( + "listGroups", + {}, + this.client.process ); await CLIDispatcher.dispatch( @@ -30,9 +78,9 @@ export class Group extends Chat { { groupId: this.id, recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), - message: text + sticker: sticker.pack.id + ":" + sticker.id }, - this.client._process + this.client.process ); } }
\ No newline at end of file diff --git a/classes/GroupDataMessage.ts b/classes/GroupDataMessage.ts index f692044..ee046b9 100644 --- a/classes/GroupDataMessage.ts +++ b/classes/GroupDataMessage.ts @@ -8,6 +8,13 @@ import {Attachment} from "./Attachment"; import {QuoteMessage} from "./QuoteMessage"; import {CLIDispatcher} from "./CLIDispatcher"; import {MessageReceipt} from "../enums/MessageReceipt"; +import {MessageFormatting} from "./MessageFormatting"; +import {MessageFormattingFormat} from "../enums/MessageFormattingFormat"; +import {UserMention} from "./UserMention"; +import {UserDataType} from "../enums/UserDataType"; +import {IChatMessageURLPreview} from "../types/IChatMessageURLPreview"; +import {ReceivedURLPreview} from "./ReceivedURLPreview"; +import {IReceivedMessageURLPreview} from "../types/IReceivedMessageURLPreview"; /** * A data message as sent by Signal @@ -15,6 +22,9 @@ import {MessageReceipt} from "../enums/MessageReceipt"; export class GroupDataMessage extends GroupMessage implements DataMessage { public content?: string; public attachments: Attachment[] = []; + public mentions: UserMention[] = []; + public previews: IReceivedMessageURLPreview[] = []; + public formatting: MessageFormatting; public quote?: QuoteMessage; constructor(user: User, data: any, time: number, groupId: string, client) { @@ -23,6 +33,9 @@ export class GroupDataMessage extends GroupMessage implements DataMessage { this.content = data.message && data.message.trim().length > 0 ? data.message : null; if (data.quote) this.quote = new QuoteMessage(data.quote); this.attachments = data.attachments?.map(i => new Attachment(i)); + this.formatting = new MessageFormatting(data.message && data.message.trim().length > 0 ? data.message : "", data.textStyles); + this.mentions = data.mentions?.map(mention => new UserMention(new User(mention, UserDataType.Mention), mention.start, mention.length)); + this.previews = data.previews?.map(preview => (new ReceivedURLPreview(preview)).build()); } public async markAsRead() { @@ -33,7 +46,7 @@ export class GroupDataMessage extends GroupMessage implements DataMessage { targetTimestamp: this.createdTimestamp, type: MessageReceipt.Read }, - this.client._process + this.client.process ) } @@ -45,7 +58,7 @@ export class GroupDataMessage extends GroupMessage implements DataMessage { targetTimestamp: this.createdTimestamp, type: MessageReceipt.Viewed }, - this.client._process + this.client.process ) } }
\ No newline at end of file diff --git a/classes/GroupDeleteMessage.ts b/classes/GroupDeleteMessage.ts new file mode 100644 index 0000000..b1e19ff --- /dev/null +++ b/classes/GroupDeleteMessage.ts @@ -0,0 +1,24 @@ +import {User} from "./User"; +import {DMMessage} from "./DMMessage"; +import {DM} from "./DM"; +import {Client} from "./Client"; +import {Sticker} from "./Sticker"; +import {StickerMessage} from "./StickerMessage"; +import {StickerSource} from "../enums/StickerSource"; +import {DeleteMessage} from "./DeleteMessage"; +import {GroupMessage} from "./GroupMessage"; +import {Group} from "./Group"; + +/** + * A deletion message as sent by Signal + */ +export class GroupDeleteMessage extends GroupMessage implements DeleteMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; + + constructor(user: User, data: any, time: number, groupId: string, client: Client, originalTime: number) { + super(user, time, new Group(groupId, client), client, data.expiresInSeconds); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +}
\ No newline at end of file diff --git a/classes/GroupEditMessage.ts b/classes/GroupEditMessage.ts new file mode 100644 index 0000000..9e1993f --- /dev/null +++ b/classes/GroupEditMessage.ts @@ -0,0 +1,28 @@ +import {User} from "./User"; +import {DMMessage} from "./DMMessage"; +import {DM} from "./DM"; +import {Client} from "./Client"; +import {DataMessage} from "./DataMessage"; +import {Attachment} from "./Attachment"; +import {QuoteMessage} from "./QuoteMessage"; +import {CLIDispatcher} from "./CLIDispatcher"; +import {MessageReceipt} from "../enums/MessageReceipt"; +import {MessageFormatting} from "./MessageFormatting"; +import {MessageFormattingFormat} from "../enums/MessageFormattingFormat"; +import {DMDataMessage} from "./DMDataMessage"; +import {EditMessage} from "./EditMessage"; +import {GroupDataMessage} from "./GroupDataMessage"; + +/** + * An edit message as sent by Signal + */ +export class GroupEditMessage extends GroupDataMessage implements EditMessage { + public originalCreatedAt: Date; + public originalCreatedTimestamp: number; + + constructor(user: User, data: any, time: number, groupId: string, originalTime: number, client: Client) { + super(user, data, time, groupId, client); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} diff --git a/classes/GroupReactionMessage.ts b/classes/GroupReactionMessage.ts index 5bba099..afc6dd0 100644 --- a/classes/GroupReactionMessage.ts +++ b/classes/GroupReactionMessage.ts @@ -3,7 +3,7 @@ import {ReceivedMessage} from "./ReceivedMessage"; import {GroupMessage} from "./GroupMessage"; import {Group} from "./Group"; import {Client} from "./Client"; -import {ReactionEmoji} from "./ReactionEmoji"; +import {Emoji} from "./Emoji"; import {ReactionTarget} from "./ReactionTarget"; import {ReactionMessage} from "./ReactionMessage"; @@ -11,14 +11,14 @@ import {ReactionMessage} from "./ReactionMessage"; * A reaction message as sent by Signal */ export class GroupReactionMessage extends GroupMessage implements ReactionMessage { - public emoji: ReactionEmoji; + public emoji: Emoji; public removed: boolean; public target: ReactionTarget; constructor(user: User, data: any, time: number, groupId: string, client: Client) { super(user, time, new Group(groupId, client), client, data.expiresInSeconds); this.removed = data.reaction.isRemove; - this.emoji = new ReactionEmoji(data.reaction.emoji); + this.emoji = new Emoji(data.reaction.emoji); this.target = new ReactionTarget(data, this.channel, client); } }
\ No newline at end of file diff --git a/classes/GroupStickerMessage.ts b/classes/GroupStickerMessage.ts new file mode 100644 index 0000000..6b08f65 --- /dev/null +++ b/classes/GroupStickerMessage.ts @@ -0,0 +1,19 @@ +import {User} from "./User"; +import {GroupMessage} from "./GroupMessage"; +import {Group} from "./Group"; +import {Client} from "./Client"; +import {StickerMessage} from "./StickerMessage"; +import {Sticker} from "./Sticker"; +import {StickerSource} from "../enums/StickerSource"; + +/** + * A sticker message as sent by Signal + */ +export class GroupStickerMessage extends GroupMessage implements StickerMessage { + public sticker: Sticker; + + constructor(user: User, data: any, time: number, groupId: string, client: Client) { + super(user, time, new Group(groupId, client), client, data.expiresInSeconds); + this.sticker = new Sticker(StickerSource.Received, data.sticker, client); + } +}
\ No newline at end of file diff --git a/classes/MessageFormatting.ts b/classes/MessageFormatting.ts new file mode 100644 index 0000000..d46867a --- /dev/null +++ b/classes/MessageFormatting.ts @@ -0,0 +1,28 @@ +import {MessageFormattingRule} from "./MessageFormattingRule"; +import {MessageFormattingFormat} from "../enums/MessageFormattingFormat"; + +export class MessageFormatting { + public rules: MessageFormattingRule[]; + + constructor(plain?: string, data?: any) { + if (data && plain) { + this.rules = data.map(i => { + return new MessageFormattingRule(i, plain); + }); + } else { + this.rules = []; + } + } + + public static fromRules(rules: MessageFormattingRule[]): MessageFormatting { + let mf = new MessageFormatting(); + + for (let rule of rules) { + mf.rules.push(rule); + } + + return mf; + } + + //public static fromMarkdown() {} +}
\ No newline at end of file diff --git a/classes/MessageFormattingRule.ts b/classes/MessageFormattingRule.ts new file mode 100644 index 0000000..7ec061d --- /dev/null +++ b/classes/MessageFormattingRule.ts @@ -0,0 +1,29 @@ +import {MessageFormattingStyle} from "../enums/MessageFormattingStyle"; + +export class MessageFormattingRule { + public start: number; + public end: number; + public length: number; + public extract?: string; + public styling: MessageFormattingStyle; + + constructor(data: any, text?: string) { + this.styling = data.style; + this.start = data.start; + this.length = data.length; + this.end = data.start + data.length; + this.extract = text?.substring(this.start, this.end); + } + + public static build(style: MessageFormattingStyle, start: number, length: number) { + return new MessageFormattingRule({ + style, + start, + length + }); + } + + public toCLIFormat(): string { + return this.start + ":" + this.length + ":" + this.styling; + } +}
\ No newline at end of file diff --git a/classes/ObjectCache.ts b/classes/ObjectCache.ts new file mode 100644 index 0000000..2940e4a --- /dev/null +++ b/classes/ObjectCache.ts @@ -0,0 +1,5 @@ +export class ObjectCache extends Object { + constructor(props) { + super(props); + } +}
\ No newline at end of file diff --git a/classes/QuoteBuilder.ts b/classes/QuoteBuilder.ts new file mode 100644 index 0000000..e259ac7 --- /dev/null +++ b/classes/QuoteBuilder.ts @@ -0,0 +1,21 @@ +import {QuoteMessage} from "./QuoteMessage"; + +export class QuoteBuilder { + public timestamp: number; + public author: string; + public content?: string; + + constructor(timestamp: number, number: string, text?: string) { + this.timestamp = timestamp; + this.author = number; + this.content = text; + } + + public build(): QuoteMessage { + return new QuoteMessage({ + authorNumber: this.author, + id: this.timestamp, + text: this.content + }); + } +}
\ No newline at end of file diff --git a/classes/QuoteMessage.ts b/classes/QuoteMessage.ts index bfbea32..7363dd5 100644 --- a/classes/QuoteMessage.ts +++ b/classes/QuoteMessage.ts @@ -3,6 +3,8 @@ import {Attachment} from "./Attachment"; import {UserDataType} from "../enums/UserDataType"; export class QuoteMessage { + public createdAt: Date; + public createdTimestamp: number; public author: User; public content?: string; public attachments?: Attachment[]; @@ -10,6 +12,8 @@ export class QuoteMessage { constructor(quoteData: any) { this.author = new User(quoteData, UserDataType.Quote); this.content = quoteData.text && quoteData.text.trim().length > 0 ? quoteData.text : null; - this.attachments = quoteData?.attachments.map(i => new Attachment(i)); + this.attachments = quoteData.attachments?.map(i => new Attachment(i)); + this.createdTimestamp = quoteData.id; + this.createdAt = new Date(quoteData.id); } }
\ No newline at end of file diff --git a/classes/ReactionMessage.ts b/classes/ReactionMessage.ts index 95e5994..22b8fd6 100644 --- a/classes/ReactionMessage.ts +++ b/classes/ReactionMessage.ts @@ -1,10 +1,10 @@ import {Attachment} from "./Attachment"; import {QuoteMessage} from "./QuoteMessage"; -import {ReactionEmoji} from "./ReactionEmoji"; +import {Emoji} from "./Emoji"; import {ReactionTarget} from "./ReactionTarget"; export class ReactionMessage { - public emoji: ReactionEmoji; + public emoji: Emoji; public removed: boolean; public target: ReactionTarget; }
\ No newline at end of file diff --git a/classes/ReceivedURLPreview.ts b/classes/ReceivedURLPreview.ts new file mode 100644 index 0000000..e686984 --- /dev/null +++ b/classes/ReceivedURLPreview.ts @@ -0,0 +1,26 @@ +import {IChatMessageURLPreview} from "../types/IChatMessageURLPreview"; +import {IReceivedMessageURLPreview} from "../types/IReceivedMessageURLPreview"; +import {Attachment} from "./Attachment"; + +export class ReceivedURLPreview { + public url: string; + public title: string; + public description?: string; + public image?: Attachment; + + constructor(data: any) { + this.url = data.url; + this.title = data.title; + if (data.description) this.description = data.description; + if (data.image) this.image = new Attachment(data.image); + } + + public build(): IReceivedMessageURLPreview { + return { + url: this.url, + title: this.title, + description: this.description, + image: this.image + } + } +}
\ No newline at end of file diff --git a/classes/SentDataMessage.ts b/classes/SentDataMessage.ts new file mode 100644 index 0000000..0f7ec37 --- /dev/null +++ b/classes/SentDataMessage.ts @@ -0,0 +1,60 @@ +import {Client} from "./Client"; +import {User} from "./User"; +import {DM} from "./DM"; +import {Group} from "./Group"; +import {IChatMessageOptions} from "../types/IChatMessageOptions"; +import {SentMessage} from "./SentMessage"; +import {CLIDispatcher} from "./CLIDispatcher"; +import {MessageReceipt} from "../enums/MessageReceipt"; + +export class SentDataMessage extends SentMessage { + public content: string; + public options?: IChatMessageOptions; + + constructor(time: number, channel: DM|Group, client: Client, content: string, options?: IChatMessageOptions) { + super(time, channel, client); + this.content = content; + this.options = options; + } + + public async edit(text: string, options?: IChatMessageOptions): Promise<SentDataMessage> { + if (options) { + options.original = this.createdTimestamp; + } else { + options = { + original: this.createdTimestamp + } + } + + return await this.channel.send(text, options); + } + + public async delete(): Promise<void> { + if (this.channel instanceof Group) { + let groupData = await CLIDispatcher.dispatch( + "listGroups", + {}, + this.client.process + ); + + await CLIDispatcher.dispatch( + "remoteDelete", + { + groupId: this.channel.id, + recipient: groupData['result'].filter(i => i.id === this.channel.id)[0].members.map(i => i.number), + targetTimestamp: this.createdTimestamp + }, + this.client.process + ); + } else { + await CLIDispatcher.dispatch( + "remoteDelete", + { + recipient: [this.channel.number], + targetTimestamp: this.createdTimestamp + }, + this.client.process + ); + } + } +}
\ No newline at end of file diff --git a/classes/SentMessage.ts b/classes/SentMessage.ts new file mode 100644 index 0000000..91c3568 --- /dev/null +++ b/classes/SentMessage.ts @@ -0,0 +1,18 @@ +import {Client} from "./Client"; +import {User} from "./User"; +import {DM} from "./DM"; +import {Group} from "./Group"; + +export class SentMessage { + public client: Client; + public createdAt: Date; + public createdTimestamp: number; + public channel: DM|Group; + + constructor(time: number, channel: DM|Group, client: Client) { + this.client = client; + this.channel = channel; + this.createdAt = new Date(time); + this.createdTimestamp = time; + } +}
\ No newline at end of file diff --git a/classes/SentStickerMessage.ts b/classes/SentStickerMessage.ts new file mode 100644 index 0000000..2b46dca --- /dev/null +++ b/classes/SentStickerMessage.ts @@ -0,0 +1,47 @@ +import {Client} from "./Client"; +import {User} from "./User"; +import {DM} from "./DM"; +import {Group} from "./Group"; +import {IChatMessageOptions} from "../types/IChatMessageOptions"; +import {SentMessage} from "./SentMessage"; +import {CLIDispatcher} from "./CLIDispatcher"; +import {MessageReceipt} from "../enums/MessageReceipt"; +import {Sticker} from "./Sticker"; + +export class SentStickerMessage extends SentMessage { + public sticker: Sticker; + + constructor(time: number, channel: DM|Group, client: Client, sticker: Sticker) { + super(time, channel, client); + this.sticker = sticker; + } + + public async delete(): Promise<void> { + if (this.channel instanceof Group) { + let groupData = await CLIDispatcher.dispatch( + "listGroups", + {}, + this.client.process + ); + + await CLIDispatcher.dispatch( + "remoteDelete", + { + groupId: this.channel.id, + recipient: groupData['result'].filter(i => i.id === this.channel.id)[0].members.map(i => i.number), + targetTimestamp: this.createdTimestamp + }, + this.client.process + ); + } else { + await CLIDispatcher.dispatch( + "remoteDelete", + { + recipient: [this.channel.number], + targetTimestamp: this.createdTimestamp + }, + this.client.process + ); + } + } +}
\ No newline at end of file diff --git a/classes/Sticker.ts b/classes/Sticker.ts new file mode 100644 index 0000000..0e319f1 --- /dev/null +++ b/classes/Sticker.ts @@ -0,0 +1,21 @@ +import {StickerPack} from "./StickerPack"; +import {Client} from "./Client"; +import {Emoji} from "./Emoji"; +import {StickerSource} from "../enums/StickerSource"; + +export class Sticker { + public pack: StickerPack; + public id: number; + public emoji?: Emoji; + + constructor(source: StickerSource, data: any, client: Client, pack?: StickerPack) { + if (source === StickerSource.Received) { + this.pack = new StickerPack(data.packId, client); + this.id = data.stickerId; + } else if (source === StickerSource.Pack) { + this.pack = pack; + this.id = data.id; + this.emoji = new Emoji(data.emoji); + } + } +}
\ No newline at end of file diff --git a/classes/StickerMessage.ts b/classes/StickerMessage.ts new file mode 100644 index 0000000..435b2b2 --- /dev/null +++ b/classes/StickerMessage.ts @@ -0,0 +1,9 @@ +import {Attachment} from "./Attachment"; +import {QuoteMessage} from "./QuoteMessage"; +import {Emoji} from "./Emoji"; +import {ReactionTarget} from "./ReactionTarget"; +import {Sticker} from "./Sticker"; + +export class StickerMessage { + public sticker: Sticker; +}
\ No newline at end of file diff --git a/classes/StickerPack.ts b/classes/StickerPack.ts new file mode 100644 index 0000000..31a2a1d --- /dev/null +++ b/classes/StickerPack.ts @@ -0,0 +1,25 @@ +import {Client} from "./Client"; +import {Sticker} from "./Sticker"; +import {StickerSource} from "../enums/StickerSource"; + +export class StickerPack { + public id: string; + public title: string; + public author: string; + public url: string; + public cover: Sticker; + public items: Sticker[]; + + constructor(id: string, client: Client) { + let cacheData = client.stickerPacks['list'].filter(i => i.packId === id)[0]; + + this.id = cacheData.packId; + this.title = cacheData.title; + this.author = cacheData.author; + this.url = cacheData.url; + this.cover = new Sticker(StickerSource.Pack, cacheData.cover, client, this); + this.items = cacheData.stickers.map(i => { + return new Sticker(StickerSource.Pack, i, client, this); + }); + } +}
\ No newline at end of file diff --git a/classes/User.ts b/classes/User.ts index f69eed2..9d30a8e 100644 --- a/classes/User.ts +++ b/classes/User.ts @@ -1,23 +1,26 @@ import {UserDataType} from "../enums/UserDataType"; export class User { - public number: string|null = null; - public nickName: string|null = null; - public uuid: string|null = null; - public device: number|null = null; + public number?: string = null; + public nickName?: string = null; + public uuid?: string = null; + public device?: number = null; constructor(data: any, dataType: UserDataType) { if (dataType === UserDataType.Envelope) { if (data.sourceNumber && typeof data.sourceNumber === "string") this.number = data.sourceNumber; if (data.sourceName && typeof data.sourceName === "string") this.nickName = data.sourceName; if (data.sourceUuid && typeof data.sourceUuid === "string") this.uuid = data.sourceUuid; - if (data.sourceDevice && typeof data.sourceDevice === "string") this.device = data.sourceDevice; + if (data.sourceDevice && typeof data.sourceDevice === "number") this.device = data.sourceDevice; } else if (dataType === UserDataType.Quote) { if (data.authorNumber && typeof data.authorNumber === "string") this.number = data.authorNumber; if (data.authorUuid && typeof data.authorUuid === "string") this.uuid = data.authorUuid; } else if (dataType === UserDataType.Reaction) { if (data.targetAuthorNumber && typeof data.targetAuthorNumber === "string") this.number = data.targetAuthorNumber; if (data.targetAuthorUuid && typeof data.targetAuthorUuid === "string") this.uuid = data.targetAuthorUuid; + } else if (dataType === UserDataType.Mention) { + if (data.number && typeof data.number === "string") this.number = data.number; + if (data.uuid && typeof data.uuid === "string") this.uuid = data.uuid; } } }
\ No newline at end of file diff --git a/classes/UserMention.ts b/classes/UserMention.ts new file mode 100644 index 0000000..0bcbfd6 --- /dev/null +++ b/classes/UserMention.ts @@ -0,0 +1,19 @@ +import {User} from "./User"; +import {IUserResolvable} from "../types/IUserResolvable"; + +export class UserMention { + public number: string; + public uuid?: string; + public start: number; + public length?: number = 1; + + constructor(user: User|IUserResolvable, start?: number, length?: number) { + this.number = user instanceof User ? user.number : user; + this.start = start ?? 0; + this.length = length ?? 1; + } + + public toCLIFormat(): string { + return this.start + ":" + this.length + ":" + this.number; + } +}
\ No newline at end of file diff --git a/dist/classes/AttachmentBuilder.d.ts b/dist/classes/AttachmentBuilder.d.ts new file mode 100644 index 0000000..de106ff --- /dev/null +++ b/dist/classes/AttachmentBuilder.d.ts @@ -0,0 +1,7 @@ +import { IFilePath } from "../types/IFilePath"; +import { IDataURI } from "../types/IDataURI"; +import { IAttachmentBuilderData } from "../types/IAttachmentBuilderData"; +export declare class AttachmentBuilder { + uri: IFilePath | IDataURI; + constructor(data: IFilePath | IDataURI | IAttachmentBuilderData); +} diff --git a/dist/classes/AttachmentBuilder.js b/dist/classes/AttachmentBuilder.js new file mode 100644 index 0000000..169b01f --- /dev/null +++ b/dist/classes/AttachmentBuilder.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttachmentBuilder = void 0; +const fs_1 = require("fs"); +class AttachmentBuilder { + constructor(data) { + if (typeof data === "string") { + if (!data.startsWith("data:")) { + (0, fs_1.lstatSync)(data); + } + this.uri = data; + } + else { + let type = data.type ?? "application/octet-stream"; + if (data.fileName) { + this.uri = `data:${type};filename=${data.fileName.replaceAll(";", "\\;")};base64,${data.data.toString("base64")}`; + } + else { + this.uri = `data:${type};base64,${data.data.toString("base64")}`; + } + } + } +} +exports.AttachmentBuilder = AttachmentBuilder; +//# sourceMappingURL=AttachmentBuilder.js.map
\ No newline at end of file diff --git a/dist/classes/AttachmentBuilder.js.map b/dist/classes/AttachmentBuilder.js.map new file mode 100644 index 0000000..4d17fb0 --- /dev/null +++ b/dist/classes/AttachmentBuilder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AttachmentBuilder.js","sourceRoot":"","sources":["../../classes/AttachmentBuilder.ts"],"names":[],"mappings":";;;AAGA,2BAA6B;AAE7B,MAAa,iBAAiB;IAG1B,YAAY,IAA+C;QACvD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBAC3B,IAAA,cAAS,EAAC,IAAI,CAAC,CAAC;aACnB;YAED,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;SACnB;aAAM;YACH,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC;YAEnD,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,IAAI,CAAC,GAAG,GAAG,QAAQ,IAAI,aAAa,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;aACrH;iBAAM;gBACH,IAAI,CAAC,GAAG,GAAG,QAAQ,IAAI,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;aACpE;SACJ;IACL,CAAC;CACJ;AApBD,8CAoBC"}
\ No newline at end of file diff --git a/dist/classes/AttachmentSize.d.ts b/dist/classes/AttachmentSize.d.ts index 0560e10..cb01288 100644 --- a/dist/classes/AttachmentSize.d.ts +++ b/dist/classes/AttachmentSize.d.ts @@ -1,3 +1,4 @@ export declare class AttachmentSize extends Number { constructor(props: any); + toBits(): number; } diff --git a/dist/classes/AttachmentSize.js b/dist/classes/AttachmentSize.js index 740f3bb..f531248 100644 --- a/dist/classes/AttachmentSize.js +++ b/dist/classes/AttachmentSize.js @@ -5,6 +5,9 @@ class AttachmentSize extends Number { constructor(props) { super(props); } + toBits() { + return parseInt(this.toString()) * 8; + } } exports.AttachmentSize = AttachmentSize; //# sourceMappingURL=AttachmentSize.js.map
\ No newline at end of file diff --git a/dist/classes/AttachmentSize.js.map b/dist/classes/AttachmentSize.js.map index faf9b7b..d79782a 100644 --- a/dist/classes/AttachmentSize.js.map +++ b/dist/classes/AttachmentSize.js.map @@ -1 +1 @@ -{"version":3,"file":"AttachmentSize.js","sourceRoot":"","sources":["../../classes/AttachmentSize.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,MAAM;IACtC,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACJ;AAJD,wCAIC"}
\ No newline at end of file +{"version":3,"file":"AttachmentSize.js","sourceRoot":"","sources":["../../classes/AttachmentSize.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,MAAM;IACtC,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM;QACT,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ;AARD,wCAQC"}
\ No newline at end of file diff --git a/dist/classes/CLIDispatcher.js b/dist/classes/CLIDispatcher.js index 4d39e2b..e7a669d 100644 --- a/dist/classes/CLIDispatcher.js +++ b/dist/classes/CLIDispatcher.js @@ -17,7 +17,6 @@ class CLIDispatcher { return; let data = JSON.parse(raw.toString()); if (data.id === id) { - console.log(data); res(data); proc.stdout.removeListener("data", callback); } diff --git a/dist/classes/CLIDispatcher.js.map b/dist/classes/CLIDispatcher.js.map index c72e4d7..d0e562b 100644 --- a/dist/classes/CLIDispatcher.js.map +++ b/dist/classes/CLIDispatcher.js.map @@ -1 +1 @@ -{"version":3,"file":"CLIDispatcher.js","sourceRoot":"","sources":["../../classes/CLIDispatcher.ts"],"names":[],"mappings":";;;AACA,mCAAwC;AAGxC,MAAa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mBAAU,GAAE,CAAC;YAC5B,IAAI,OAAO,GAAgB;gBACvB,OAAO,EAAE,KAAK;gBACd,MAAM;gBACN,MAAM;gBACN,EAAE;aACL,CAAA;YAED,IAAI,QAAQ,GAAkB,CAAC,GAAG,EAAQ,EAAE;gBACxC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE;oBAAE,OAAO;gBACzC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAEtC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;oBAChB,GAAG,CAAC,IAAI,CAAC,CAAC;oBACV,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;iBAChD;YACL,CAAC,CAAA;YAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAzBD,sCAyBC"}
\ No newline at end of file diff --git a/dist/classes/CLIEvent.d.ts b/dist/classes/CLIEvent.d.ts index dd70135..b08a161 100644 --- a/dist/classes/CLIEvent.d.ts +++ b/dist/classes/CLIEvent.d.ts @@ -1,10 +1,8 @@ import { Client } from "./Client"; import { ICLIEvent } from "../types/ICLIEvent"; -import { ICLIResponse } from "../types/ICLIResponse"; /** * A signal-cli event */ export declare class CLIEvent { static fromEvent(client: Client, data: ICLIEvent): void; - static fromResponse(client: Client, data: ICLIResponse): void; } diff --git a/dist/classes/CLIEvent.js b/dist/classes/CLIEvent.js index 888410a..d2992b7 100644 --- a/dist/classes/CLIEvent.js +++ b/dist/classes/CLIEvent.js @@ -9,6 +9,13 @@ const DMDataMessage_1 = require("./DMDataMessage"); const UserDataType_1 = require("../enums/UserDataType"); const DMReactionMessage_1 = require("./DMReactionMessage"); const GroupReactionMessage_1 = require("./GroupReactionMessage"); +const CLIDispatcher_1 = require("./CLIDispatcher"); +const DMStickerMessage_1 = require("./DMStickerMessage"); +const GroupStickerMessage_1 = require("./GroupStickerMessage"); +const DMEditMessage_1 = require("./DMEditMessage"); +const GroupEditMessage_1 = require("./GroupEditMessage"); +const GroupDeleteMessage_1 = require("./GroupDeleteMessage"); +const DMDeleteMessage_1 = require("./DMDeleteMessage"); /** * A signal-cli event */ @@ -17,7 +24,8 @@ class CLIEvent { client.emit("cliEvent", data); if (data.method === "receive") { if (data.params.envelope.typingMessage) { - console.log(data.params.envelope.typingMessage); + if (client.verbose) + console.log(data.params.envelope.typingMessage); if (data.params.envelope.typingMessage.groupId) { let message = new GroupTypingMessage_1.GroupTypingMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.typingMessage.action, data.params.envelope.typingMessage.timestamp, data.params.envelope.typingMessage.groupId, client); client.emit("typingMessage", message); @@ -27,9 +35,32 @@ class CLIEvent { client.emit("typingMessage", message); } } + else if (data.params.envelope.editMessage) { + if (client.verbose) + console.log(data.params.envelope.editMessage); + if (data.params.envelope.editMessage.dataMessage.groupInfo) { + let message = new GroupEditMessage_1.GroupEditMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.editMessage.dataMessage, data.params.envelope.editMessage.dataMessage.timestamp, data.params.envelope.editMessage.dataMessage.groupInfo.groupId, data.params.envelope.editMessage.targetSentTimestamp, client); + client.emit("editMessage", message); + } + else { + let message = new DMEditMessage_1.DMEditMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.editMessage.dataMessage, data.params.envelope.editMessage.dataMessage.timestamp, data.params.envelope.editMessage.targetSentTimestamp, client); + client.emit("editMessage", message); + } + } else if (data.params.envelope.dataMessage) { - console.log(data.params.envelope.dataMessage); - if (data.params.envelope.dataMessage.reaction) { + if (client.verbose) + console.log(data.params.envelope.dataMessage); + if (data.params.envelope.dataMessage.remoteDelete) { + if (data.params.envelope.dataMessage.groupInfo) { + let message = new GroupDeleteMessage_1.GroupDeleteMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, data.params.envelope.dataMessage.groupInfo.groupId, client, data.params.envelope.dataMessage.remoteDelete.timestamp); + client.emit("deleteMessage", message); + } + else { + let message = new DMDeleteMessage_1.DMDeleteMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, client, data.params.envelope.dataMessage.remoteDelete.timestamp); + client.emit("deleteMessage", message); + } + } + else if (data.params.envelope.dataMessage.reaction) { if (data.params.envelope.dataMessage.groupInfo) { let message = new GroupReactionMessage_1.GroupReactionMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, data.params.envelope.dataMessage.groupInfo.groupId, client); client.emit("reaction", message); @@ -51,6 +82,19 @@ class CLIEvent { } } } + else if (data.params.envelope.dataMessage.sticker) { + CLIDispatcher_1.CLIDispatcher.dispatch("listStickerPacks", {}, client.process).then((cliData) => { + client.stickerPacks['list'] = cliData.result; + if (data.params.envelope.dataMessage.groupInfo) { + let message = new GroupStickerMessage_1.GroupStickerMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, data.params.envelope.dataMessage.groupInfo.groupId, client); + client.emit("sticker", message); + } + else { + let message = new DMStickerMessage_1.DMStickerMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, client); + client.emit("sticker", message); + } + }); + } else { if (data.params.envelope.dataMessage.groupInfo) { let message = new GroupDataMessage_1.GroupDataMessage(new User_1.User(data.params.envelope, UserDataType_1.UserDataType.Envelope), data.params.envelope.dataMessage, data.params.envelope.dataMessage.timestamp, data.params.envelope.dataMessage.groupInfo.groupId, client); @@ -64,9 +108,6 @@ class CLIEvent { } } } - static fromResponse(client, data) { - console.log(data); - } } exports.CLIEvent = CLIEvent; //# sourceMappingURL=CLIEvent.js.map
\ No newline at end of file diff --git a/dist/classes/CLIEvent.js.map b/dist/classes/CLIEvent.js.map index 049e718..4b9d2e7 100644 --- a/dist/classes/CLIEvent.js.map +++ b/dist/classes/CLIEvent.js.map @@ -1 +1 @@ -{"version":3,"file":"CLIEvent.js","sourceRoot":"","sources":["../../classes/CLIEvent.ts"],"names":[],"mappings":";;;AAGA,6DAAwD;AACxD,iCAA4B;AAC5B,uDAAkD;AAClD,yDAAoD;AACpD,mDAA8C;AAC9C,wDAAmD;AACnD,2DAAsD;AACtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,QAAQ;IACjB,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,IAAe;QAC5C,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE;gBACpC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAEhD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE;oBAC5C,IAAI,OAAO,GAAuB,IAAI,uCAAkB,CACpD,IAAI,WAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,2BAAY,CAAC,QAAQ,CAAC,EACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,EACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAC5C,IAAI,CAAC,MAAM,CAAC,Q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QAAQ,CAAC,EACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAC1C,MAAM,CACT,CAAC;wBAEF,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;qBACnC;iBACJ;aACJ;SACJ;IACL,CAAC;CACJ;AAlKD,4BAkKC"}
\ No newline at end of file diff --git a/dist/classes/Channel.d.ts b/dist/classes/Channel.d.ts new file mode 100644 index 0000000..50335f4 --- /dev/null +++ b/dist/classes/Channel.d.ts @@ -0,0 +1,9 @@ +import { IChatMessageOptions } from "../types/IChatMessageOptions"; +import { SentDataMessage } from "./SentDataMessage"; +export declare class Channel { + group: boolean; + id: string; + constructor(); + send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage>; + setTyping(typing: boolean): Promise<void>; +} diff --git a/dist/classes/Channel.js b/dist/classes/Channel.js new file mode 100644 index 0000000..385102f --- /dev/null +++ b/dist/classes/Channel.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Channel = void 0; +class Channel { + constructor() { } + // @ts-ignore + async send(text, options) { } + async setTyping(typing) { } +} +exports.Channel = Channel; +//# sourceMappingURL=Channel.js.map
\ No newline at end of file diff --git a/dist/classes/Channel.js.map b/dist/classes/Channel.js.map new file mode 100644 index 0000000..00f828b --- /dev/null +++ b/dist/classes/Channel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../classes/Channel.ts"],"names":[],"mappings":";;;AAGA,MAAa,OAAO;IAIhB,gBAAe,CAAC;IAChB,aAAa;IACN,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA6B,IAA6B,CAAC;IAEpF,KAAK,CAAC,SAAS,CAAC,MAAe,IAAkB,CAAC;CAC5D;AATD,0BASC"}
\ No newline at end of file diff --git a/dist/classes/Chat.d.ts b/dist/classes/Chat.d.ts index ffeb7ef..0c0ca30 100644 --- a/dist/classes/Chat.d.ts +++ b/dist/classes/Chat.d.ts @@ -1,7 +1,7 @@ -import { ChatMessageOptions } from "./ChatMessageOptions"; +import { IChatMessageOptions } from "../types/IChatMessageOptions"; export declare class Chat { group: boolean; id: string; constructor(); - send(text: string, options?: ChatMessageOptions): Promise<void>; + send(text: string, options?: IChatMessageOptions): Promise<void>; } diff --git a/dist/classes/Chat.js.map b/dist/classes/Chat.js.map index a1d56ea..21cdfed 100644 --- a/dist/classes/Chat.js.map +++ b/dist/classes/Chat.js.map @@ -1 +1 @@ -{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../classes/Chat.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IAIb,gBAAe,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA4B,IAAG,CAAC;CAC5D;AAND,oBAMC"}
\ No newline at end of file +{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../classes/Chat.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IAIb,gBAAe,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA6B,IAAG,CAAC;CAC7D;AAND,oBAMC"}
\ No newline at end of file diff --git a/dist/classes/Client.d.ts b/dist/classes/Client.d.ts index b22d01e..5e830ad 100644 --- a/dist/classes/Client.d.ts +++ b/dist/classes/Client.d.ts @@ -10,19 +10,30 @@ import { DMDataMessage } from "./DMDataMessage"; import { GroupDataMessage } from "./GroupDataMessage"; import { GroupReactionMessage } from "./GroupReactionMessage"; import { DMReactionMessage } from "./DMReactionMessage"; +import { ObjectCache } from "./ObjectCache"; +import { GroupStickerMessage } from "./GroupStickerMessage"; +import { DMStickerMessage } from "./DMStickerMessage"; +import { DMEditMessage } from "./DMEditMessage"; +import { GroupEditMessage } from "./GroupEditMessage"; +import { GroupDeleteMessage } from "./GroupDeleteMessage"; +import { DMDeleteMessage } from "./DMDeleteMessage"; export declare interface Client { on(event: "cliEvent", listener: (event: ICLIEvent) => void): this; on(event: "typingMessage", listener: (message: GroupTypingMessage | DMTypingMessage) => void): this; on(event: "message", listener: (message: GroupDataMessage | DMDataMessage) => void): this; + on(event: "editMessage", listener: (message: GroupEditMessage | DMEditMessage) => void): this; on(event: "reaction", listener: (message: GroupReactionMessage | DMReactionMessage) => void): this; on(event: "reactionAdd", listener: (message: GroupReactionMessage | DMReactionMessage) => void): this; on(event: "reactionRemove", listener: (message: GroupReactionMessage | DMReactionMessage) => void): this; + on(event: "sticker", listener: (message: GroupStickerMessage | DMStickerMessage) => void): this; + on(event: "deleteMessage", listener: (message: GroupDeleteMessage | DMDeleteMessage) => void): this; } /** * The base signal.js client */ export declare class Client extends EventEmitter { - private process; - _process: ChildProcess; + process: ChildProcess; + stickerPacks: ObjectCache; + verbose: boolean; constructor(config: IConfig); } diff --git a/dist/classes/Client.js b/dist/classes/Client.js index 2395ed7..77ee09c 100644 --- a/dist/classes/Client.js +++ b/dist/classes/Client.js @@ -11,6 +11,8 @@ const events_1 = require("events"); class Client extends events_1.EventEmitter { constructor(config) { super(); + this.stickerPacks = {}; + this.verbose = false; let command = config.signalCli ?? "signal-cli"; let parameters = []; if (config.system?.args) @@ -27,9 +29,11 @@ class Client extends events_1.EventEmitter { parameters.push("--service-environment", config.environment); if (config.trustLevel) parameters.push("--trust-new-identities", config.trustLevel); + if (config.logEvents) + this.verbose = true; parameters.push("--account", config.account); parameters.push("jsonRpc"); - this.process = this._process = (0, child_process_1.spawn)(command, parameters, config.system?.spawn ?? { + this.process = (0, child_process_1.spawn)(command, parameters, config.system?.spawn ?? { stdio: "pipe", windowsHide: true }); diff --git a/dist/classes/Client.js.map b/dist/classes/Client.js.map index a92a1b9..2ae393b 100644 --- a/dist/classes/Client.js.map +++ b/dist/classes/Client.js.map @@ -1 +1 @@ -{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../classes/Client.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAElD,yCAAoC;AACpC,+CA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at } from "./Chat"; -import { ChatMessageOptions } from "./ChatMessageOptions"; +import { Channel } from "./Channel"; import { Client } from "./Client"; -export declare class DM extends Chat { +import { IChatMessageOptions } from "../types/IChatMessageOptions"; +import { SentDataMessage } from "./SentDataMessage"; +import { Sticker } from "./Sticker"; +export declare class DM extends Channel { group: boolean; id: string; - private number; + number: string; private client; constructor(userId: string, number: string, client: Client); - send(text: string, options?: ChatMessageOptions): Promise<void>; + send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage>; + setTyping(typing: boolean): Promise<void>; + sendSticker(sticker: Sticker): Promise<void>; } diff --git a/dist/classes/DM.js b/dist/classes/DM.js index c60095c..e6839b8 100644 --- a/dist/classes/DM.js +++ b/dist/classes/DM.js @@ -1,9 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DM = void 0; -const Chat_1 = require("./Chat"); +const Channel_1 = require("./Channel"); const CLIDispatcher_1 = require("./CLIDispatcher"); -class DM extends Chat_1.Chat { +const SentDataMessage_1 = require("./SentDataMessage"); +class DM extends Channel_1.Channel { constructor(userId, number, client) { super(); this.group = false; @@ -12,10 +13,35 @@ class DM extends Chat_1.Chat { this.client = client; } async send(text, options) { + let data = await CLIDispatcher_1.CLIDispatcher.dispatch("send", { + recipient: [this.number], + message: text, + attachment: options?.attachments?.map(i => i.uri) ?? [], + quoteTimestamp: options?.quote?.build().createdTimestamp, + quoteAuthor: options?.quote?.build().author.number, + quoteMessage: options?.quote?.build().content, + editTimestamp: options?.original, + previewUrl: options?.preview?.url, + previewTitle: options?.preview?.title, + previewDescription: options?.preview?.description, + previewImage: options?.preview?.image, + textStyle: options?.formatting?.rules.map(rule => rule.toCLIFormat()), + mention: options?.mentions?.map(rule => rule.toCLIFormat()) + }, this.client.process); + let timestamp = data.result?.timestamp; + return new SentDataMessage_1.SentDataMessage(timestamp, this, this.client, text, options); + } + async setTyping(typing) { + await CLIDispatcher_1.CLIDispatcher.dispatch("sendTyping", { + recipient: [this.number], + stop: !typing + }, this.client.process); + } + async sendSticker(sticker) { await CLIDispatcher_1.CLIDispatcher.dispatch("send", { recipient: [this.number], - message: text - }, this.client._process); + sticker: sticker.pack.id + ":" + sticker.id + }, this.client.process); } } exports.DM = DM; diff --git a/dist/classes/DM.js.map b/dist/classes/DM.js.map index ed63007..a3989db 100644 --- a/dist/classes/DM.js.map +++ b/dist/classes/DM.js.map @@ -1 +1 @@ -{"version":3,"file":"DM.js","sourceRoot":"","sources":["../../classes/DM.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAE5B,mDAA8C;AAG9C,MAAa,EAAG,SAAQ,WAAI;IAMxB,YAAY,MAAc,EAAE,MAAc,EAAE,MAAc;QACtD,KAAK,EAAE,CAAC;QANL,UAAK,GAAY,KAAK,CAAC;QAO1B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA4B;QACxD,MAAM,6BAAa,CAAC,QAAQ,CACxB,MAAM,EACN;YACI,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE,IAAI;SAChB,EACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CACvB,CAAA;IACL,CAAC;CACJ;AAvBD,gBAuBC"}
\ No newline at end of file +{"version":3,"file":"DM.js","sourceRoot":"","sources":["../../classes/DM.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,mDAA8C;AAG9C,uDAAkD;AAIlD,MAAa,EAAG,SAAQ,iBAAO;IAM3B,YAAY,MAAc,EAAE,MAAc,EAAE,MAAc;QACtD,KAAK,EAAE,CAAC;QANL,UAAK,GAAY,KAAK,CAAC;QAO1B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,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AC5E,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAe;QAClC,MAAM,6BAAa,CAAC,QAAQ,CACxB,YAAY,EACZ;YACI,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,IAAI,EAAE,CAAC,MAAM;SAChB,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAgB;QACrC,MAAM,6BAAa,CAAC,QAAQ,CACxB,MAAM,EACN;YACI,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE;SAC9C,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;IACN,CAAC;CACJ;AA3DD,gBA2DC"}
\ No newline at end of file diff --git a/dist/classes/DMDataMessage.d.ts b/dist/classes/DMDataMessage.d.ts index 61640c4..59752fe 100644 --- a/dist/classes/DMDataMessage.d.ts +++ b/dist/classes/DMDataMessage.d.ts @@ -4,12 +4,18 @@ import { Client } from "./Client"; import { DataMessage } from "./DataMessage"; import { Attachment } from "./Attachment"; import { QuoteMessage } from "./QuoteMessage"; +import { MessageFormatting } from "./MessageFormatting"; +import { UserMention } from "./UserMention"; +import { IReceivedMessageURLPreview } from "../types/IReceivedMessageURLPreview"; /** * A data message as sent by Signal */ export declare class DMDataMessage extends DMMessage implements DataMessage { content?: string; attachments: Attachment[]; + mentions: UserMention[]; + previews: IReceivedMessageURLPreview[]; + formatting: MessageFormatting; quote?: QuoteMessage; constructor(user: User, data: any, time: number, client: Client); markAsRead(): Promise<void>; diff --git a/dist/classes/DMDataMessage.js b/dist/classes/DMDataMessage.js index deda9c9..dd8aecf 100644 --- a/dist/classes/DMDataMessage.js +++ b/dist/classes/DMDataMessage.js @@ -1,12 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DMDataMessage = void 0; +const User_1 = require("./User"); const DMMessage_1 = require("./DMMessage"); const DM_1 = require("./DM"); const Attachment_1 = require("./Attachment"); const QuoteMessage_1 = require("./QuoteMessage"); const CLIDispatcher_1 = require("./CLIDispatcher"); const MessageReceipt_1 = require("../enums/MessageReceipt"); +const MessageFormatting_1 = require("./MessageFormatting"); +const UserMention_1 = require("./UserMention"); +const UserDataType_1 = require("../enums/UserDataType"); +const ReceivedURLPreview_1 = require("./ReceivedURLPreview"); /** * A data message as sent by Signal */ @@ -14,24 +19,29 @@ class DMDataMessage extends DMMessage_1.DMMessage { constructor(user, data, time, client) { super(user, time, new DM_1.DM(user.uuid, user.number, client), client, data.expiresInSeconds); this.attachments = []; + this.mentions = []; + this.previews = []; this.content = data.message && data.message.trim().length > 0 ? data.message : null; if (data.quote) this.quote = new QuoteMessage_1.QuoteMessage(data.quote); this.attachments = data.attachments?.map(i => new Attachment_1.Attachment(i)); + this.formatting = new MessageFormatting_1.MessageFormatting(data.message && data.message.trim().length > 0 ? data.message : "", data.textStyles); + this.mentions = data.mentions?.map(mention => new UserMention_1.UserMention(new User_1.User(UserDataType_1.UserDataType.Mention, mention), mention.start, mention.length)); + this.previews = data.previews?.map(preview => (new ReceivedURLPreview_1.ReceivedURLPreview(preview)).build()); } async markAsRead() { await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", { recipient: this.author.number, targetTimestamp: this.createdTimestamp, type: MessageReceipt_1.MessageReceipt.Read - }, this.client._process); + }, this.client.process); } async markAsViewed() { await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", { recipient: this.author.number, targetTimestamp: this.createdTimestamp, type: MessageReceipt_1.MessageReceipt.Viewed - }, this.client._process); + }, this.client.process); } } exports.DMDataMessage = DMDataMessage; diff --git a/dist/classes/DMDataMessage.js.map b/dist/classes/DMDataMessage.js.map index b36467f..dba3e47 100644 --- a/dist/classes/DMDataMessage.js.map +++ b/dist/classes/DMDataMessage.js.map @@ -1 +1 @@ -{"version":3,"file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C"}
\ No newline at end of file diff --git a/dist/classes/DMDeleteMessage.d.ts b/dist/classes/DMDeleteMessage.d.ts new file mode 100644 index 0000000..640e201 --- /dev/null +++ b/dist/classes/DMDeleteMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { DMMessage } from "./DMMessage"; +import { Client } from "./Client"; +import { DeleteMessage } from "./DeleteMessage"; +/** + * A deletion message as sent by Signal + */ +export declare class DMDeleteMessage extends DMMessage implements DeleteMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; + constructor(user: User, data: any, time: number, client: Client, originalTime: number); +} diff --git a/dist/classes/DMDeleteMessage.js b/dist/classes/DMDeleteMessage.js new file mode 100644 index 0000000..3295193 --- /dev/null +++ b/dist/classes/DMDeleteMessage.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DMDeleteMessage = void 0; +const DMMessage_1 = require("./DMMessage"); +const DM_1 = require("./DM"); +/** + * A deletion message as sent by Signal + */ +class DMDeleteMessage extends DMMessage_1.DMMessage { + constructor(user, data, time, client, originalTime) { + super(user, time, new DM_1.DM(user.uuid, user.number, client), client, data.expiresInSeconds); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} +exports.DMDeleteMessage = DMDeleteMessage; +//# sourceMappingURL=DMDeleteMessage.js.map
\ No newline at end of file diff --git a/dist/classes/DMDeleteMessage.js.map b/dist/classes/DMDeleteMessage.js.map new file mode 100644 index 0000000..6c14c3d --- /dev/null +++ b/dist/classes/DMDeleteMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DMDeleteMessage.js","sourceRoot":"","sources":["../../classes/DMDeleteMessage.ts"],"names":[],"mappings":";;;AACA,2CAAsC;AACtC,6BAAwB;AAOxB;;GAEG;AACH,MAAa,eAAgB,SAAQ,qBAAS;IAI1C,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,MAAc,EAAE,YAAoB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,iBAAiB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,wBAAwB,GAAG,YAAY,CAAC;IACjD,CAAC;CACJ;AATD,0CASC"}
\ No newline at end of file diff --git a/dist/classes/DMEditMessage.d.ts b/dist/classes/DMEditMessage.d.ts new file mode 100644 index 0000000..fc2f85d --- /dev/null +++ b/dist/classes/DMEditMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { Client } from "./Client"; +import { DMDataMessage } from "./DMDataMessage"; +import { EditMessage } from "./EditMessage"; +/** + * An edit message as sent by Signal + */ +export declare class DMEditMessage extends DMDataMessage implements EditMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; + constructor(user: User, data: any, time: number, originalTime: number, client: Client); +} diff --git a/dist/classes/DMEditMessage.js b/dist/classes/DMEditMessage.js new file mode 100644 index 0000000..ef69b98 --- /dev/null +++ b/dist/classes/DMEditMessage.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DMEditMessage = void 0; +const DMDataMessage_1 = require("./DMDataMessage"); +/** + * An edit message as sent by Signal + */ +class DMEditMessage extends DMDataMessage_1.DMDataMessage { + constructor(user, data, time, originalTime, client) { + super(user, data, time, client); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} +exports.DMEditMessage = DMEditMessage; +//# sourceMappingURL=DMEditMessage.js.map
\ No newline at end of file diff --git a/dist/classes/DMEditMessage.js.map b/dist/classes/DMEditMessage.js.map new file mode 100644 index 0000000..2cafc17 --- /dev/null +++ b/dist/classes/DMEditMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DMEditMessage.js","sourceRoot":"","sources":["../../classes/DMEditMessage.ts"],"names":[],"mappings":";;;AAWA,mDAA8C;AAG9C;;GAEG;AACH,MAAa,aAAc,SAAQ,6BAAa;IAI5C,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,YAAoB,EAAE,MAAc;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,wBAAwB,GAAG,YAAY,CAAC;IACjD,CAAC;CACJ;AATD,sCASC"}
\ No newline at end of file diff --git a/dist/classes/DMReactionMessage.d.ts b/dist/classes/DMReactionMessage.d.ts index f87ca59..e53bdbc 100644 --- a/dist/classes/DMReactionMessage.d.ts +++ b/dist/classes/DMReactionMessage.d.ts @@ -1,14 +1,14 @@ import { User } from "./User"; import { DMMessage } from "./DMMessage"; import { Client } from "./Client"; -import { ReactionEmoji } from "./ReactionEmoji"; +import { Emoji } from "./Emoji"; import { ReactionTarget } from "./ReactionTarget"; import { ReactionMessage } from "./ReactionMessage"; /** * A reaction message as sent by Signal */ export declare class DMReactionMessage extends DMMessage implements ReactionMessage { - emoji: ReactionEmoji; + emoji: Emoji; removed: boolean; target: ReactionTarget; constructor(user: User, data: any, time: number, client: Client); diff --git a/dist/classes/DMReactionMessage.js b/dist/classes/DMReactionMessage.js index 3c4f6ef..fe24252 100644 --- a/dist/classes/DMReactionMessage.js +++ b/dist/classes/DMReactionMessage.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.DMReactionMessage = void 0; const DMMessage_1 = require("./DMMessage"); const DM_1 = require("./DM"); -const ReactionEmoji_1 = require("./ReactionEmoji"); +const Emoji_1 = require("./Emoji"); const ReactionTarget_1 = require("./ReactionTarget"); /** * A reaction message as sent by Signal @@ -12,7 +12,7 @@ class DMReactionMessage extends DMMessage_1.DMMessage { constructor(user, data, time, client) { super(user, time, new DM_1.DM(user.uuid, user.number, client), client, data.expiresInSeconds); this.removed = data.reaction.isRemove; - this.emoji = new ReactionEmoji_1.ReactionEmoji(data.reaction.emoji); + this.emoji = new Emoji_1.Emoji(data.reaction.emoji); this.target = new ReactionTarget_1.ReactionTarget(data, this.channel, client); } } diff --git a/dist/classes/DMReactionMessage.js.map b/dist/classes/DMReactionMessage.js.map index df7ef33..773b688 100644 --- a/dist/classes/DMReactionMessage.js.map +++ b/dist/classes/DMReactionMessage.js.map @@ -1 +1 @@ -{"version":3,"file":"DMReactionMessage.js","sourceRoot":"","sources":["../../classes/DMReactionMessage.ts"],"names":[],"mappings":";;;AAIA,2CAAsC;AACtC,6BAAwB;AAExB,mDAA8C;AAC9C,qDAAgD;AAGhD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,qBAAS;IAK5C,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,MAAc;QAC3D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ;AAXD,8CAWC"}
\ No newline at end of file +{"version":3,"file":"DMReactionMessage.js","sourceRoot":"","sources":["../../classes/DMReactionMessage.ts"],"names":[],"mappings":";;;AAIA,2CAAsC;AACtC,6BAAwB;AAExB,mCAA8B;AAC9B,qDAAgD;AAGhD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,qBAAS;IAK5C,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,MAAc;QAC3D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ;AAXD,8CAWC"}
\ No newline at end of file diff --git a/dist/classes/DMStickerMessage.d.ts b/dist/classes/DMStickerMessage.d.ts new file mode 100644 index 0000000..8d26455 --- /dev/null +++ b/dist/classes/DMStickerMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { DMMessage } from "./DMMessage"; +import { Client } from "./Client"; +import { Sticker } from "./Sticker"; +import { StickerMessage } from "./StickerMessage"; +/** + * A sticker message as sent by Signal + */ +export declare class DMStickerMessage extends DMMessage implements StickerMessage { + sticker: Sticker; + constructor(user: User, data: any, time: number, client: Client); +} diff --git a/dist/classes/DMStickerMessage.js b/dist/classes/DMStickerMessage.js new file mode 100644 index 0000000..d1bf083 --- /dev/null +++ b/dist/classes/DMStickerMessage.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DMStickerMessage = void 0; +const DMMessage_1 = require("./DMMessage"); +const DM_1 = require("./DM"); +const Sticker_1 = require("./Sticker"); +const StickerSource_1 = require("../enums/StickerSource"); +/** + * A sticker message as sent by Signal + */ +class DMStickerMessage extends DMMessage_1.DMMessage { + constructor(user, data, time, client) { + super(user, time, new DM_1.DM(user.uuid, user.number, client), client, data.expiresInSeconds); + this.sticker = new Sticker_1.Sticker(StickerSource_1.StickerSource.Received, data.sticker, client); + } +} +exports.DMStickerMessage = DMStickerMessage; +//# sourceMappingURL=DMStickerMessage.js.map
\ No newline at end of file diff --git a/dist/classes/DMStickerMessage.js.map b/dist/classes/DMStickerMessage.js.map new file mode 100644 index 0000000..9bfd8a1 --- /dev/null +++ b/dist/classes/DMStickerMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DMStickerMessage.js","sourceRoot":"","sources":["../../classes/DMStickerMessage.ts"],"names":[],"mappings":";;;AACA,2CAAsC;AACtC,6BAAwB;AAExB,uCAAkC;AAElC,0DAAqD;AAErD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,qBAAS;IAG3C,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,MAAc;QAC3D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,6BAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;CACJ;AAPD,4CAOC"}
\ No newline at end of file diff --git a/dist/classes/DataMessage.d.ts b/dist/classes/DataMessage.d.ts index 7f42e21..8851714 100644 --- a/dist/classes/DataMessage.d.ts +++ b/dist/classes/DataMessage.d.ts @@ -1,7 +1,13 @@ import { Attachment } from "./Attachment"; import { QuoteMessage } from "./QuoteMessage"; +import { MessageFormatting } from "./MessageFormatting"; +import { UserMention } from "./UserMention"; +import { IReceivedMessageURLPreview } from "../types/IReceivedMessageURLPreview"; export declare class DataMessage { content?: string; attachments: Attachment[]; + mentions: UserMention[]; + previews: IReceivedMessageURLPreview[]; + formatting: MessageFormatting; quote?: QuoteMessage; } diff --git a/dist/classes/DataMessage.js b/dist/classes/DataMessage.js index 7d2a789..4977839 100644 --- a/dist/classes/DataMessage.js +++ b/dist/classes/DataMessage.js @@ -4,6 +4,8 @@ exports.DataMessage = void 0; class DataMessage { constructor() { this.attachments = []; + this.mentions = []; + this.previews = []; } } exports.DataMessage = DataMessage; diff --git a/dist/classes/DataMessage.js.map b/dist/classes/DataMessage.js.map index 7275389..c4583ae 100644 --- a/dist/classes/DataMessage.js.map +++ b/dist/classes/DataMessage.js.map @@ -1 +1 @@ -{"version":3,"file":"DataMessage.js","sourceRoot":"","sources":["../../classes/DataMessage.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAW;IAAxB;QAEW,gBAAW,GAAiB,EAAE,CAAC;IAE1C,CAAC;CAAA;AAJD,kCAIC"}
\ No newline at end of file +{"version":3,"file":"DataMessage.js","sourceRoot":"","sources":["../../classes/DataMessage.ts"],"names":[],"mappings":";;;AAOA,MAAa,WAAW;IAAxB;QAEW,gBAAW,GAAiB,EAAE,CAAC;QAC/B,aAAQ,GAAkB,EAAE,CAAC;QAC7B,aAAQ,GAAiC,EAAE,CAAC;IAGvD,CAAC;CAAA;AAPD,kCAOC"}
\ No newline at end of file diff --git a/dist/classes/DeleteMessage.d.ts b/dist/classes/DeleteMessage.d.ts new file mode 100644 index 0000000..8ae14fa --- /dev/null +++ b/dist/classes/DeleteMessage.d.ts @@ -0,0 +1,4 @@ +export declare class DeleteMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; +} diff --git a/dist/classes/DeleteMessage.js b/dist/classes/DeleteMessage.js new file mode 100644 index 0000000..9c22a98 --- /dev/null +++ b/dist/classes/DeleteMessage.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeleteMessage = void 0; +class DeleteMessage { +} +exports.DeleteMessage = DeleteMessage; +//# sourceMappingURL=DeleteMessage.js.map
\ No newline at end of file diff --git a/dist/classes/DeleteMessage.js.map b/dist/classes/DeleteMessage.js.map new file mode 100644 index 0000000..f859e24 --- /dev/null +++ b/dist/classes/DeleteMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeleteMessage.js","sourceRoot":"","sources":["../../classes/DeleteMessage.ts"],"names":[],"mappings":";;;AAMA,MAAa,aAAa;CAGzB;AAHD,sCAGC"}
\ No newline at end of file diff --git a/dist/classes/EditMessage.d.ts b/dist/classes/EditMessage.d.ts new file mode 100644 index 0000000..bf2bd9a --- /dev/null +++ b/dist/classes/EditMessage.d.ts @@ -0,0 +1,5 @@ +import { DataMessage } from "./DataMessage"; +export declare class EditMessage extends DataMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; +} diff --git a/dist/classes/EditMessage.js b/dist/classes/EditMessage.js new file mode 100644 index 0000000..54bc389 --- /dev/null +++ b/dist/classes/EditMessage.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EditMessage = void 0; +const DataMessage_1 = require("./DataMessage"); +class EditMessage extends DataMessage_1.DataMessage { +} +exports.EditMessage = EditMessage; +//# sourceMappingURL=EditMessage.js.map
\ No newline at end of file diff --git a/dist/classes/EditMessage.js.map b/dist/classes/EditMessage.js.map new file mode 100644 index 0000000..66c122d --- /dev/null +++ b/dist/classes/EditMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"EditMessage.js","sourceRoot":"","sources":["../../classes/EditMessage.ts"],"names":[],"mappings":";;;AAGA,+CAA0C;AAE1C,MAAa,WAAY,SAAQ,yBAAW;CAG3C;AAHD,kCAGC"}
\ No newline at end of file diff --git a/dist/classes/Emoji.d.ts b/dist/classes/Emoji.d.ts new file mode 100644 index 0000000..a09baf3 --- /dev/null +++ b/dist/classes/Emoji.d.ts @@ -0,0 +1,3 @@ +export declare class Emoji extends String { + constructor(props: any); +} diff --git a/dist/classes/Emoji.js b/dist/classes/Emoji.js new file mode 100644 index 0000000..9f4aad6 --- /dev/null +++ b/dist/classes/Emoji.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Emoji = void 0; +class Emoji extends String { + constructor(props) { + super(props); + } +} +exports.Emoji = Emoji; +//# sourceMappingURL=Emoji.js.map
\ No newline at end of file diff --git a/dist/classes/Emoji.js.map b/dist/classes/Emoji.js.map new file mode 100644 index 0000000..34062d4 --- /dev/null +++ b/dist/classes/Emoji.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Emoji.js","sourceRoot":"","sources":["../../classes/Emoji.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAM,SAAQ,MAAM;IAC7B,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACJ;AAJD,sBAIC"}
\ No newline at end of file diff --git a/dist/classes/Group.d.ts b/dist/classes/Group.d.ts index 23110d5..75d1e55 100644 --- a/dist/classes/Group.d.ts +++ b/dist/classes/Group.d.ts @@ -1,10 +1,14 @@ -import { Chat } from "./Chat"; +import { Channel } from "./Channel"; import { Client } from "./Client"; -import { ChatMessageOptions } from "./ChatMessageOptions"; -export declare class Group extends Chat { +import { IChatMessageOptions } from "../types/IChatMessageOptions"; +import { SentDataMessage } from "./SentDataMessage"; +import { Sticker } from "./Sticker"; +export declare class Group extends Channel { group: boolean; id: string; private client; constructor(groupId: string, client: Client); - send(text: string, options?: ChatMessageOptions): Promise<void>; + send(text: string, options?: IChatMessageOptions): Promise<SentDataMessage>; + setTyping(typing: boolean): Promise<void>; + sendSticker(sticker: Sticker): Promise<void>; } diff --git a/dist/classes/Group.js b/dist/classes/Group.js index aa0c95e..77aa2c6 100644 --- a/dist/classes/Group.js +++ b/dist/classes/Group.js @@ -1,9 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Group = void 0; -const Chat_1 = require("./Chat"); +const Channel_1 = require("./Channel"); const CLIDispatcher_1 = require("./CLIDispatcher"); -class Group extends Chat_1.Chat { +const SentDataMessage_1 = require("./SentDataMessage"); +class Group extends Channel_1.Channel { constructor(groupId, client) { super(); this.group = true; @@ -11,16 +12,41 @@ class Group extends Chat_1.Chat { this.client = client; } async send(text, options) { - let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", { - group: [this.id], - recipient: [], - message: text - }, this.client._process); + let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", {}, this.client.process); + let data = await CLIDispatcher_1.CLIDispatcher.dispatch("send", { + groupId: this.id, + recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), + message: text, + attachment: options?.attachments?.map(i => i.uri) ?? [], + quoteTimestamp: options?.quote?.build().createdTimestamp, + quoteAuthor: options?.quote?.build().author.number, + quoteMessage: options?.quote?.build().content, + editTimestamp: options?.original, + previewUrl: options?.preview?.url, + previewTitle: options?.preview?.title, + previewDescription: options?.preview?.description, + previewImage: options?.preview?.image, + textStyle: options?.formatting?.rules.map(rule => rule.toCLIFormat()), + mention: options?.mentions?.map(rule => rule.toCLIFormat()) + }, this.client.process); + let timestamp = data.result?.timestamp; + return new SentDataMessage_1.SentDataMessage(timestamp, this, this.client, text, options); + } + async setTyping(typing) { + let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", {}, this.client.process); + await CLIDispatcher_1.CLIDispatcher.dispatch("sendTyping", { + groupId: this.id, + recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), + stop: !typing + }, this.client.process); + } + async sendSticker(sticker) { + let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", {}, this.client.process); await CLIDispatcher_1.CLIDispatcher.dispatch("send", { groupId: this.id, recipient: groupData['result'].filter(i => i.id === this.id)[0].members.map(i => i.number), - message: text - }, this.client._process); + sticker: sticker.pack.id + ":" + sticker.id + }, this.client.process); } } exports.Group = Group; diff --git a/dist/classes/Group.js.map b/dist/classes/Group.js.map index 08ad340..55c73a0 100644 --- a/dist/classes/Group.js.map +++ b/dist/classes/Group.js.map @@ -1 +1 @@ -{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../classes/Group.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAG5B,mDAA8C;AAE9C,MAAa,KAAM,SAAQ,WAAI;IAK3B,YAAY,OAAe,EAAE,MAAc;QACvC,KAAK,EAAE,CAAC;QALL,UAAK,GAAY,IAAI,CAAC;QAMzB,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA4B;QACxD,IAAI,SAAS,GAAG,MAAM,6BAAa,CAAC,QAAQ,CACxC,YAAY,EACZ;YACI,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAChB,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,IAAI;SAChB,EACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CACvB,CAAC;QAEF,MAAM,6BAAa,CAAC,QAAQ,CACxB,MAAM,EACN;YACI,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1F,OAAO,EAAE,IAAI;SAChB,EACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CACvB,CAAC;IACN,CAAC;CACJ;AAhCD,sBAgCC"}
\ No newline at end of file +{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../classes/Group.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAElC,mDAA8C;AAE9C,uDAAkD;AAGlD,MAAa,KAAM,SAAQ,iBAAO;IAK9B,YAAY,OAAe,EAAE,MAAc;QACvC,KAAK,EAAE,CAAC;QALL,UAAK,GAAY,IAAI,CAAC;QAMzB,IAAI,CAAC,EAA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CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1F,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE;SAC9C,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;IACN,CAAC;CACJ;AA9ED,sBA8EC"}
\ No newline at end of file diff --git a/dist/classes/GroupDataMessage.d.ts b/dist/classes/GroupDataMessage.d.ts index fe00141..21cab06 100644 --- a/dist/classes/GroupDataMessage.d.ts +++ b/dist/classes/GroupDataMessage.d.ts @@ -3,12 +3,18 @@ import { GroupMessage } from "./GroupMessage"; import { DataMessage } from "./DataMessage"; import { Attachment } from "./Attachment"; import { QuoteMessage } from "./QuoteMessage"; +import { MessageFormatting } from "./MessageFormatting"; +import { UserMention } from "./UserMention"; +import { IReceivedMessageURLPreview } from "../types/IReceivedMessageURLPreview"; /** * A data message as sent by Signal */ export declare class GroupDataMessage extends GroupMessage implements DataMessage { content?: string; attachments: Attachment[]; + mentions: UserMention[]; + previews: IReceivedMessageURLPreview[]; + formatting: MessageFormatting; quote?: QuoteMessage; constructor(user: User, data: any, time: number, groupId: string, client: any); markAsRead(): Promise<void>; diff --git a/dist/classes/GroupDataMessage.js b/dist/classes/GroupDataMessage.js index 9eac787..9f23568 100644 --- a/dist/classes/GroupDataMessage.js +++ b/dist/classes/GroupDataMessage.js @@ -1,12 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupDataMessage = void 0; +const User_1 = require("./User"); const GroupMessage_1 = require("./GroupMessage"); const Group_1 = require("./Group"); const Attachment_1 = require("./Attachment"); const QuoteMessage_1 = require("./QuoteMessage"); const CLIDispatcher_1 = require("./CLIDispatcher"); const MessageReceipt_1 = require("../enums/MessageReceipt"); +const MessageFormatting_1 = require("./MessageFormatting"); +const UserMention_1 = require("./UserMention"); +const UserDataType_1 = require("../enums/UserDataType"); +const ReceivedURLPreview_1 = require("./ReceivedURLPreview"); /** * A data message as sent by Signal */ @@ -14,25 +19,30 @@ class GroupDataMessage extends GroupMessage_1.GroupMessage { constructor(user, data, time, groupId, client) { super(user, time, new Group_1.Group(groupId, client), client, data.expiresInSeconds); this.attachments = []; + this.mentions = []; + this.previews = []; this.client = client; this.content = data.message && data.message.trim().length > 0 ? data.message : null; if (data.quote) this.quote = new QuoteMessage_1.QuoteMessage(data.quote); this.attachments = data.attachments?.map(i => new Attachment_1.Attachment(i)); + this.formatting = new MessageFormatting_1.MessageFormatting(data.message && data.message.trim().length > 0 ? data.message : "", data.textStyles); + this.mentions = data.mentions?.map(mention => new UserMention_1.UserMention(new User_1.User(mention, UserDataType_1.UserDataType.Mention), mention.start, mention.length)); + this.previews = data.previews?.map(preview => (new ReceivedURLPreview_1.ReceivedURLPreview(preview)).build()); } async markAsRead() { await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", { recipient: this.author.number, targetTimestamp: this.createdTimestamp, type: MessageReceipt_1.MessageReceipt.Read - }, this.client._process); + }, this.client.process); } async markAsViewed() { await CLIDispatcher_1.CLIDispatcher.dispatch("sendReceipt", { recipient: this.author.number, targetTimestamp: this.createdTimestamp, type: MessageReceipt_1.MessageReceipt.Viewed - }, this.client._process); + }, this.client.process); } } exports.GroupDataMessage = GroupDataMessage; diff --git a/dist/classes/GroupDataMessage.js.map b/dist/classes/GroupDataMessage.js.map index 97ee669..96f50b9 100644 --- a/dist/classes/GroupDataMessage.js.map +++ b/dist/classes/GroupDataMessage.js.map @@ -1 +1 @@ -{"version":3,"file":"GroupDataMessage.js","sourceRoot":"","sources":["../../classes/GroupDataMessage.ts"],"names":[],"mappings":";;;AAEA,iDAA4C;AAC5C,mCAA8B;AAG9B,6CAAwC;AACxC,i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ts new file mode 100644 index 0000000..c91dad1 --- /dev/null +++ b/dist/classes/GroupDeleteMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { Client } from "./Client"; +import { DeleteMessage } from "./DeleteMessage"; +import { GroupMessage } from "./GroupMessage"; +/** + * A deletion message as sent by Signal + */ +export declare class GroupDeleteMessage extends GroupMessage implements DeleteMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; + constructor(user: User, data: any, time: number, groupId: string, client: Client, originalTime: number); +} diff --git a/dist/classes/GroupDeleteMessage.js b/dist/classes/GroupDeleteMessage.js new file mode 100644 index 0000000..ab1248e --- /dev/null +++ b/dist/classes/GroupDeleteMessage.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GroupDeleteMessage = void 0; +const GroupMessage_1 = require("./GroupMessage"); +const Group_1 = require("./Group"); +/** + * A deletion message as sent by Signal + */ +class GroupDeleteMessage extends GroupMessage_1.GroupMessage { + constructor(user, data, time, groupId, client, originalTime) { + super(user, time, new Group_1.Group(groupId, client), client, data.expiresInSeconds); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} +exports.GroupDeleteMessage = GroupDeleteMessage; +//# sourceMappingURL=GroupDeleteMessage.js.map
\ No newline at end of file diff --git a/dist/classes/GroupDeleteMessage.js.map b/dist/classes/GroupDeleteMessage.js.map new file mode 100644 index 0000000..452598e --- /dev/null +++ b/dist/classes/GroupDeleteMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupDeleteMessage.js","sourceRoot":"","sources":["../../classes/GroupDeleteMessage.ts"],"names":[],"mappings":";;;AAQA,iDAA4C;AAC5C,mCAA8B;AAE9B;;GAEG;AACH,MAAa,kBAAmB,SAAQ,2BAAY;IAIhD,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,OAAe,EAAE,MAAc,EAAE,YAAoB;QAClG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,CAAC,iBAAiB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,wBAAwB,GAAG,YAAY,CAAC;IACjD,CAAC;CACJ;AATD,gDASC"}
\ No newline at end of file diff --git a/dist/classes/GroupEditMessage.d.ts b/dist/classes/GroupEditMessage.d.ts new file mode 100644 index 0000000..6e42851 --- /dev/null +++ b/dist/classes/GroupEditMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { Client } from "./Client"; +import { EditMessage } from "./EditMessage"; +import { GroupDataMessage } from "./GroupDataMessage"; +/** + * An edit message as sent by Signal + */ +export declare class GroupEditMessage extends GroupDataMessage implements EditMessage { + originalCreatedAt: Date; + originalCreatedTimestamp: number; + constructor(user: User, data: any, time: number, groupId: string, originalTime: number, client: Client); +} diff --git a/dist/classes/GroupEditMessage.js b/dist/classes/GroupEditMessage.js new file mode 100644 index 0000000..71ed0e7 --- /dev/null +++ b/dist/classes/GroupEditMessage.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GroupEditMessage = void 0; +const GroupDataMessage_1 = require("./GroupDataMessage"); +/** + * An edit message as sent by Signal + */ +class GroupEditMessage extends GroupDataMessage_1.GroupDataMessage { + constructor(user, data, time, groupId, originalTime, client) { + super(user, data, time, groupId, client); + this.originalCreatedAt = new Date(originalTime); + this.originalCreatedTimestamp = originalTime; + } +} +exports.GroupEditMessage = GroupEditMessage; +//# sourceMappingURL=GroupEditMessage.js.map
\ No newline at end of file diff --git a/dist/classes/GroupEditMessage.js.map b/dist/classes/GroupEditMessage.js.map new file mode 100644 index 0000000..a5f15ce --- /dev/null +++ b/dist/classes/GroupEditMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupEditMessage.js","sourceRoot":"","sources":["../../classes/GroupEditMessage.ts"],"names":[],"mappings":";;;AAaA,yDAAoD;AAEpD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,mCAAgB;IAIlD,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,OAAe,EAAE,YAAoB,EAAE,MAAc;QAClG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,iBAAiB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,wBAAwB,GAAG,YAAY,CAAC;IACjD,CAAC;CACJ;AATD,4CASC"}
\ No newline at end of file diff --git a/dist/classes/GroupReactionMessage.d.ts b/dist/classes/GroupReactionMessage.d.ts index 981d275..4c5566e 100644 --- a/dist/classes/GroupReactionMessage.d.ts +++ b/dist/classes/GroupReactionMessage.d.ts @@ -1,14 +1,14 @@ import { User } from "./User"; import { GroupMessage } from "./GroupMessage"; import { Client } from "./Client"; -import { ReactionEmoji } from "./ReactionEmoji"; +import { Emoji } from "./Emoji"; import { ReactionTarget } from "./ReactionTarget"; import { ReactionMessage } from "./ReactionMessage"; /** * A reaction message as sent by Signal */ export declare class GroupReactionMessage extends GroupMessage implements ReactionMessage { - emoji: ReactionEmoji; + emoji: Emoji; removed: boolean; target: ReactionTarget; constructor(user: User, data: any, time: number, groupId: string, client: Client); diff --git a/dist/classes/GroupReactionMessage.js b/dist/classes/GroupReactionMessage.js index d6c63ad..1b70178 100644 --- a/dist/classes/GroupReactionMessage.js +++ b/dist/classes/GroupReactionMessage.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupReactionMessage = void 0; const GroupMessage_1 = require("./GroupMessage"); const Group_1 = require("./Group"); -const ReactionEmoji_1 = require("./ReactionEmoji"); +const Emoji_1 = require("./Emoji"); const ReactionTarget_1 = require("./ReactionTarget"); /** * A reaction message as sent by Signal @@ -12,7 +12,7 @@ class GroupReactionMessage extends GroupMessage_1.GroupMessage { constructor(user, data, time, groupId, client) { super(user, time, new Group_1.Group(groupId, client), client, data.expiresInSeconds); this.removed = data.reaction.isRemove; - this.emoji = new ReactionEmoji_1.ReactionEmoji(data.reaction.emoji); + this.emoji = new Emoji_1.Emoji(data.reaction.emoji); this.target = new ReactionTarget_1.ReactionTarget(data, this.channel, client); } } diff --git a/dist/classes/GroupReactionMessage.js.map b/dist/classes/GroupReactionMessage.js.map index e5dc96b..3875476 100644 --- a/dist/classes/GroupReactionMessage.js.map +++ b/dist/classes/GroupReactionMessage.js.map @@ -1 +1 @@ -{"version":3,"file":"GroupReactionMessage.js","sourceRoot":"","sources":["../../classes/GroupReactionMessage.ts"],"names":[],"mappings":";;;AAEA,iDAA4C;AAC5C,mCAA8B;AAE9B,mDAA8C;AAC9C,qDAAgD;AAGhD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,2BAAY;IAKlD,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,OAAe,EAAE,MAAc;QAC5E,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ;AAXD,oDAWC"}
\ No newline at end of file +{"version":3,"file":"GroupReactionMessage.js","sourceRoot":"","sources":["../../classes/GroupReactionMessage.ts"],"names":[],"mappings":";;;AAEA,iDAA4C;AAC5C,mCAA8B;AAE9B,mCAA8B;AAC9B,qDAAgD;AAGhD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,2BAAY;IAKlD,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,OAAe,EAAE,MAAc;QAC5E,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ;AAXD,oDAWC"}
\ No newline at end of file diff --git a/dist/classes/GroupStickerMessage.d.ts b/dist/classes/GroupStickerMessage.d.ts new file mode 100644 index 0000000..aa587eb --- /dev/null +++ b/dist/classes/GroupStickerMessage.d.ts @@ -0,0 +1,12 @@ +import { User } from "./User"; +import { GroupMessage } from "./GroupMessage"; +import { Client } from "./Client"; +import { StickerMessage } from "./StickerMessage"; +import { Sticker } from "./Sticker"; +/** + * A sticker message as sent by Signal + */ +export declare class GroupStickerMessage extends GroupMessage implements StickerMessage { + sticker: Sticker; + constructor(user: User, data: any, time: number, groupId: string, client: Client); +} diff --git a/dist/classes/GroupStickerMessage.js b/dist/classes/GroupStickerMessage.js new file mode 100644 index 0000000..45f4fc2 --- /dev/null +++ b/dist/classes/GroupStickerMessage.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GroupStickerMessage = void 0; +const GroupMessage_1 = require("./GroupMessage"); +const Group_1 = require("./Group"); +const Sticker_1 = require("./Sticker"); +const StickerSource_1 = require("../enums/StickerSource"); +/** + * A sticker message as sent by Signal + */ +class GroupStickerMessage extends GroupMessage_1.GroupMessage { + constructor(user, data, time, groupId, client) { + super(user, time, new Group_1.Group(groupId, client), client, data.expiresInSeconds); + this.sticker = new Sticker_1.Sticker(StickerSource_1.StickerSource.Received, data.sticker, client); + } +} +exports.GroupStickerMessage = GroupStickerMessage; +//# sourceMappingURL=GroupStickerMessage.js.map
\ No newline at end of file diff --git a/dist/classes/GroupStickerMessage.js.map b/dist/classes/GroupStickerMessage.js.map new file mode 100644 index 0000000..b2f7ca0 --- /dev/null +++ b/dist/classes/GroupStickerMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupStickerMessage.js","sourceRoot":"","sources":["../../classes/GroupStickerMessage.ts"],"names":[],"mappings":";;;AACA,iDAA4C;AAC5C,mCAA8B;AAG9B,uCAAkC;AAClC,0DAAqD;AAErD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,2BAAY;IAGjD,YAAY,IAAU,EAAE,IAAS,EAAE,IAAY,EAAE,OAAe,EAAE,MAAc;QAC5E,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,6BAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;CACJ;AAPD,kDAOC"}
\ No newline at end of file diff --git a/dist/classes/MessageFormatting.d.ts b/dist/classes/MessageFormatting.d.ts new file mode 100644 index 0000000..1a5380a --- /dev/null +++ b/dist/classes/MessageFormatting.d.ts @@ -0,0 +1,6 @@ +import { MessageFormattingRule } from "./MessageFormattingRule"; +export declare class MessageFormatting { + rules: MessageFormattingRule[]; + constructor(plain?: string, data?: any); + static fromRules(rules: MessageFormattingRule[]): MessageFormatting; +} diff --git a/dist/classes/MessageFormatting.js b/dist/classes/MessageFormatting.js new file mode 100644 index 0000000..532fddd --- /dev/null +++ b/dist/classes/MessageFormatting.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageFormatting = void 0; +const MessageFormattingRule_1 = require("./MessageFormattingRule"); +class MessageFormatting { + constructor(plain, data) { + if (data && plain) { + this.rules = data.map(i => { + return new MessageFormattingRule_1.MessageFormattingRule(i, plain); + }); + } + else { + this.rules = []; + } + } + static fromRules(rules) { + let mf = new MessageFormatting(); + for (let rule of rules) { + mf.rules.push(rule); + } + return mf; + } +} +exports.MessageFormatting = MessageFormatting; +//# sourceMappingURL=MessageFormatting.js.map
\ No newline at end of file diff --git a/dist/classes/MessageFormatting.js.map b/dist/classes/MessageFormatting.js.map new file mode 100644 index 0000000..5431ab5 --- /dev/null +++ b/dist/classes/MessageFormatting.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MessageFormatting.js","sourceRoot":"","sources":["../../classes/MessageFormatting.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAG9D,MAAa,iBAAiB;IAG1B,YAAY,KAAc,EAAE,IAAU;QAClC,IAAI,IAAI,IAAI,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACtB,OAAO,IAAI,6CAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;SACN;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;SACnB;IACL,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,KAA8B;QAClD,IAAI,EAAE,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAEjC,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACpB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACvB;QAED,OAAO,EAAE,CAAC;IACd,CAAC;CAGJ;AAxBD,8CAwBC"}
\ No newline at end of file diff --git a/dist/classes/MessageFormattingRule.d.ts b/dist/classes/MessageFormattingRule.d.ts new file mode 100644 index 0000000..9418bdd --- /dev/null +++ b/dist/classes/MessageFormattingRule.d.ts @@ -0,0 +1,11 @@ +import { MessageFormattingStyle } from "../enums/MessageFormattingStyle"; +export declare class MessageFormattingRule { + start: number; + end: number; + length: number; + extract?: string; + styling: MessageFormattingStyle; + constructor(data: any, text?: string); + static build(style: MessageFormattingStyle, start: number, length: number): MessageFormattingRule; + toCLIFormat(): string; +} diff --git a/dist/classes/MessageFormattingRule.js b/dist/classes/MessageFormattingRule.js new file mode 100644 index 0000000..729a5d9 --- /dev/null +++ b/dist/classes/MessageFormattingRule.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageFormattingRule = void 0; +class MessageFormattingRule { + constructor(data, text) { + this.styling = data.style; + this.start = data.start; + this.length = data.length; + this.end = data.start + data.length; + this.extract = text?.substring(this.start, this.end); + } + static build(style, start, length) { + return new MessageFormattingRule({ + style, + start, + length + }); + } + toCLIFormat() { + return this.start + ":" + this.length + ":" + this.styling; + } +} +exports.MessageFormattingRule = MessageFormattingRule; +//# sourceMappingURL=MessageFormattingRule.js.map
\ No newline at end of file diff --git a/dist/classes/MessageFormattingRule.js.map b/dist/classes/MessageFormattingRule.js.map new file mode 100644 index 0000000..3ba897a --- /dev/null +++ b/dist/classes/MessageFormattingRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MessageFormattingRule.js","sourceRoot":"","sources":["../../classes/MessageFormattingRule.ts"],"names":[],"mappings":";;;AAEA,MAAa,qBAAqB;IAO9B,YAAY,IAAS,EAAE,IAAa;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,KAA6B,EAAE,KAAa,EAAE,MAAc;QAC5E,OAAO,IAAI,qBAAqB,CAAC;YAC7B,KAAK;YACL,KAAK;YACL,MAAM;SACT,CAAC,CAAC;IACP,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;IAC/D,CAAC;CACJ;AA1BD,sDA0BC"}
\ No newline at end of file diff --git a/dist/classes/ObjectCache.d.ts b/dist/classes/ObjectCache.d.ts new file mode 100644 index 0000000..6be6b62 --- /dev/null +++ b/dist/classes/ObjectCache.d.ts @@ -0,0 +1,3 @@ +export declare class ObjectCache extends Object { + constructor(props: any); +} diff --git a/dist/classes/ObjectCache.js b/dist/classes/ObjectCache.js new file mode 100644 index 0000000..7b52c42 --- /dev/null +++ b/dist/classes/ObjectCache.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ObjectCache = void 0; +class ObjectCache extends Object { + constructor(props) { + super(props); + } +} +exports.ObjectCache = ObjectCache; +//# sourceMappingURL=ObjectCache.js.map
\ No newline at end of file diff --git a/dist/classes/ObjectCache.js.map b/dist/classes/ObjectCache.js.map new file mode 100644 index 0000000..12a4c13 --- /dev/null +++ b/dist/classes/ObjectCache.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ObjectCache.js","sourceRoot":"","sources":["../../classes/ObjectCache.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,MAAM;IACnC,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACJ;AAJD,kCAIC"}
\ No newline at end of file diff --git a/dist/classes/QuoteBuilder.d.ts b/dist/classes/QuoteBuilder.d.ts new file mode 100644 index 0000000..facd561 --- /dev/null +++ b/dist/classes/QuoteBuilder.d.ts @@ -0,0 +1,8 @@ +import { QuoteMessage } from "./QuoteMessage"; +export declare class QuoteBuilder { + timestamp: number; + author: string; + content?: string; + constructor(timestamp: number, number: string, text?: string); + build(): QuoteMessage; +} diff --git a/dist/classes/QuoteBuilder.js b/dist/classes/QuoteBuilder.js new file mode 100644 index 0000000..6307ef8 --- /dev/null +++ b/dist/classes/QuoteBuilder.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.QuoteBuilder = void 0; +const QuoteMessage_1 = require("./QuoteMessage"); +class QuoteBuilder { + constructor(timestamp, number, text) { + this.timestamp = timestamp; + this.author = number; + this.content = text; + } + build() { + return new QuoteMessage_1.QuoteMessage({ + authorNumber: this.author, + id: this.timestamp, + text: this.content + }); + } +} +exports.QuoteBuilder = QuoteBuilder; +//# sourceMappingURL=QuoteBuilder.js.map
\ No newline at end of file diff --git a/dist/classes/QuoteBuilder.js.map b/dist/classes/QuoteBuilder.js.map new file mode 100644 index 0000000..655aebc --- /dev/null +++ b/dist/classes/QuoteBuilder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"QuoteBuilder.js","sourceRoot":"","sources":["../../classes/QuoteBuilder.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C,MAAa,YAAY;IAKrB,YAAY,SAAiB,EAAE,MAAc,EAAE,IAAa;QACxD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,2BAAY,CAAC;YACpB,YAAY,EAAE,IAAI,CAAC,MAAM;YACzB,EAAE,EAAE,IAAI,CAAC,SAAS;YAClB,IAAI,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACP,CAAC;CACJ;AAlBD,oCAkBC"}
\ No newline at end of file diff --git a/dist/classes/QuoteMessage.d.ts b/dist/classes/QuoteMessage.d.ts index 54b0b49..ae17d98 100644 --- a/dist/classes/QuoteMessage.d.ts +++ b/dist/classes/QuoteMessage.d.ts @@ -1,6 +1,8 @@ import { User } from "./User"; import { Attachment } from "./Attachment"; export declare class QuoteMessage { + createdAt: Date; + createdTimestamp: number; author: User; content?: string; attachments?: Attachment[]; diff --git a/dist/classes/QuoteMessage.js b/dist/classes/QuoteMessage.js index 411ff30..41110ea 100644 --- a/dist/classes/QuoteMessage.js +++ b/dist/classes/QuoteMessage.js @@ -8,7 +8,9 @@ class QuoteMessage { constructor(quoteData) { this.author = new User_1.User(quoteData, UserDataType_1.UserDataType.Quote); this.content = quoteData.text && quoteData.text.trim().length > 0 ? quoteData.text : null; - this.attachments = quoteData?.attachments.map(i => new Attachment_1.Attachment(i)); + this.attachments = quoteData.attachments?.map(i => new Attachment_1.Attachment(i)); + this.createdTimestamp = quoteData.id; + this.createdAt = new Date(quoteData.id); } } exports.QuoteMessage = QuoteMessage; diff --git a/dist/classes/QuoteMessage.js.map b/dist/classes/QuoteMessage.js.map index a1b6a46..6ade00a 100644 --- a/dist/classes/QuoteMessage.js.map +++ b/dist/classes/QuoteMessage.js.map @@ -1 +1 @@ -{"version":3,"file":"QuoteMessage.js","sourceRoot":"","sources":["../../classes/QuoteMessage.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAC5B,6CAAwC;AACxC,wDAAmD;AAEnD,MAAa,YAAY;IAKrB,YAAY,SAAc;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,WAAI,CAAC,SAAS,EAAE,2BAAY,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1F,IAAI,CAAC,WAAW,GAAG,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,uBAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;CACJ;AAVD,oCAUC"}
\ No newline at end of file +{"version":3,"file":"QuoteMessage.js","sourceRoot":"","sources":["../../classes/QuoteMessage.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAC5B,6CAAwC;AACxC,wDAAmD;AAEnD,MAAa,YAAY;IAOrB,YAAY,SAAc;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,WAAI,CAAC,SAAS,EAAE,2BAAY,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1F,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,uBAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ;AAdD,oCAcC"}
\ No newline at end of file diff --git a/dist/classes/ReactionMessage.d.ts b/dist/classes/ReactionMessage.d.ts index ef06f2a..cf5fcc5 100644 --- a/dist/classes/ReactionMessage.d.ts +++ b/dist/classes/ReactionMessage.d.ts @@ -1,7 +1,7 @@ -import { ReactionEmoji } from "./ReactionEmoji"; +import { Emoji } from "./Emoji"; import { ReactionTarget } from "./ReactionTarget"; export declare class ReactionMessage { - emoji: ReactionEmoji; + emoji: Emoji; removed: boolean; target: ReactionTarget; } diff --git a/dist/classes/ReceivedURLPreview.d.ts b/dist/classes/ReceivedURLPreview.d.ts new file mode 100644 index 0000000..a883e5a --- /dev/null +++ b/dist/classes/ReceivedURLPreview.d.ts @@ -0,0 +1,10 @@ +import { IReceivedMessageURLPreview } from "../types/IReceivedMessageURLPreview"; +import { Attachment } from "./Attachment"; +export declare class ReceivedURLPreview { + url: string; + title: string; + description?: string; + image?: Attachment; + constructor(data: any); + build(): IReceivedMessageURLPreview; +} diff --git a/dist/classes/ReceivedURLPreview.js b/dist/classes/ReceivedURLPreview.js new file mode 100644 index 0000000..8fe1339 --- /dev/null +++ b/dist/classes/ReceivedURLPreview.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReceivedURLPreview = void 0; +const Attachment_1 = require("./Attachment"); +class ReceivedURLPreview { + constructor(data) { + this.url = data.url; + this.title = data.title; + if (data.description) + this.description = data.description; + if (data.image) + this.image = new Attachment_1.Attachment(data.image); + } + build() { + return { + url: this.url, + title: this.title, + description: this.description, + image: this.image + }; + } +} +exports.ReceivedURLPreview = ReceivedURLPreview; +//# sourceMappingURL=ReceivedURLPreview.js.map
\ No newline at end of file diff --git a/dist/classes/ReceivedURLPreview.js.map b/dist/classes/ReceivedURLPreview.js.map new file mode 100644 index 0000000..af9e306 --- /dev/null +++ b/dist/classes/ReceivedURLPreview.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ReceivedURLPreview.js","sourceRoot":"","sources":["../../classes/ReceivedURLPreview.ts"],"names":[],"mappings":";;;AAEA,6CAAwC;AAExC,MAAa,kBAAkB;IAM3B,YAAY,IAAS;QACjB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAC1D,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAEM,KAAK;QACR,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;SACpB,CAAA;IACL,CAAC;CACJ;AArBD,gDAqBC"}
\ No newline at end of file diff --git a/dist/classes/SentDataMessage.d.ts b/dist/classes/SentDataMessage.d.ts new file mode 100644 index 0000000..2d07bc7 --- /dev/null +++ b/dist/classes/SentDataMessage.d.ts @@ -0,0 +1,12 @@ +import { Client } from "./Client"; +import { DM } from "./DM"; +import { Group } from "./Group"; +import { IChatMessageOptions } from "../types/IChatMessageOptions"; +import { SentMessage } from "./SentMessage"; +export declare class SentDataMessage extends SentMessage { + content: string; + options?: IChatMessageOptions; + constructor(time: number, channel: DM | Group, client: Client, content: string, options?: IChatMessageOptions); + edit(text: string, options?: IChatMessageOptions): Promise<SentDataMessage>; + delete(): Promise<void>; +} diff --git a/dist/classes/SentDataMessage.js b/dist/classes/SentDataMessage.js new file mode 100644 index 0000000..7f763a9 --- /dev/null +++ b/dist/classes/SentDataMessage.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SentDataMessage = void 0; +const Group_1 = require("./Group"); +const SentMessage_1 = require("./SentMessage"); +const CLIDispatcher_1 = require("./CLIDispatcher"); +class SentDataMessage extends SentMessage_1.SentMessage { + constructor(time, channel, client, content, options) { + super(time, channel, client); + this.content = content; + this.options = options; + } + async edit(text, options) { + if (options) { + options.original = this.createdTimestamp; + } + else { + options = { + original: this.createdTimestamp + }; + } + return await this.channel.send(text, options); + } + async delete() { + if (this.channel instanceof Group_1.Group) { + let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", {}, this.client.process); + await CLIDispatcher_1.CLIDispatcher.dispatch("remoteDelete", { + groupId: this.channel.id, + recipient: groupData['result'].filter(i => i.id === this.channel.id)[0].members.map(i => i.number), + targetTimestamp: this.createdTimestamp + }, this.client.process); + } + else { + await CLIDispatcher_1.CLIDispatcher.dispatch("remoteDelete", { + recipient: [this.channel.number], + targetTimestamp: this.createdTimestamp + }, this.client.process); + } + } +} +exports.SentDataMessage = SentDataMessage; +//# sourceMappingURL=SentDataMessage.js.map
\ No newline at end of file diff --git a/dist/classes/SentDataMessage.js.map b/dist/classes/SentDataMessage.js.map new file mode 100644 index 0000000..07347cf --- /dev/null +++ b/dist/classes/SentDataMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SentDataMessage.js","sourceRoot":"","sources":["../../classes/SentDataMessage.ts"],"names":[],"mappings":";;;AAGA,mCAA8B;AAE9B,+CAA0C;AAC1C,mDAA8C;AAG9C,MAAa,eAAgB,SAAQ,yBAAW;IAI5C,YAAY,IAAY,EAAE,OAAiB,EAAE,MAAc,EAAE,OAAe,EAAE,OAA6B;QACvG,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,OAA6B;QACzD,IAAI,OAAO,EAAE;YACT,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC;SAC5C;aAAM;YACH,OAAO,GAAG;gBACN,QAAQ,EAAE,IAAI,CAAC,gBAAgB;aAClC,CAAA;SACJ;QAED,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM;QACf,IAAI,IAAI,CAAC,OAAO,YAAY,aAAK,EAAE;YAC/B,IAAI,SAAS,GAAG,MAAM,6BAAa,CAAC,QAAQ,CACxC,YAAY,EACZ,EAAE,EACF,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;YAEF,MAAM,6BAAa,CAAC,QAAQ,CACxB,cAAc,EACd;gBACI,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;gBACxB,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;gBAClG,eAAe,EAAE,IAAI,CAAC,gBAAgB;aACzC,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;SACL;aAAM;YACH,MAAM,6BAAa,CAAC,QAAQ,CACxB,cAAc,EACd;gBACI,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;gBAChC,eAAe,EAAE,IAAI,CAAC,gBAAgB;aACzC,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;SACL;IACL,CAAC;CACJ;AAlDD,0CAkDC"}
\ No newline at end of file diff --git a/dist/classes/SentMessage.d.ts b/dist/classes/SentMessage.d.ts new file mode 100644 index 0000000..03abdf5 --- /dev/null +++ b/dist/classes/SentMessage.d.ts @@ -0,0 +1,10 @@ +import { Client } from "./Client"; +import { DM } from "./DM"; +import { Group } from "./Group"; +export declare class SentMessage { + client: Client; + createdAt: Date; + createdTimestamp: number; + channel: DM | Group; + constructor(time: number, channel: DM | Group, client: Client); +} diff --git a/dist/classes/SentMessage.js b/dist/classes/SentMessage.js new file mode 100644 index 0000000..03f4b83 --- /dev/null +++ b/dist/classes/SentMessage.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SentMessage = void 0; +class SentMessage { + constructor(time, channel, client) { + this.client = client; + this.channel = channel; + this.createdAt = new Date(time); + this.createdTimestamp = time; + } +} +exports.SentMessage = SentMessage; +//# sourceMappingURL=SentMessage.js.map
\ No newline at end of file diff --git a/dist/classes/SentMessage.js.map b/dist/classes/SentMessage.js.map new file mode 100644 index 0000000..d3000bf --- /dev/null +++ b/dist/classes/SentMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SentMessage.js","sourceRoot":"","sources":["../../classes/SentMessage.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAMpB,YAAY,IAAY,EAAE,OAAiB,EAAE,MAAc;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACjC,CAAC;CACJ;AAZD,kCAYC"}
\ No newline at end of file diff --git a/dist/classes/SentStickerMessage.d.ts b/dist/classes/SentStickerMessage.d.ts new file mode 100644 index 0000000..1a5bef8 --- /dev/null +++ b/dist/classes/SentStickerMessage.d.ts @@ -0,0 +1,10 @@ +import { Client } from "./Client"; +import { DM } from "./DM"; +import { Group } from "./Group"; +import { SentMessage } from "./SentMessage"; +import { Sticker } from "./Sticker"; +export declare class SentStickerMessage extends SentMessage { + sticker: Sticker; + constructor(time: number, channel: DM | Group, client: Client, sticker: Sticker); + delete(): Promise<void>; +} diff --git a/dist/classes/SentStickerMessage.js b/dist/classes/SentStickerMessage.js new file mode 100644 index 0000000..d7e10f2 --- /dev/null +++ b/dist/classes/SentStickerMessage.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SentStickerMessage = void 0; +const Group_1 = require("./Group"); +const SentMessage_1 = require("./SentMessage"); +const CLIDispatcher_1 = require("./CLIDispatcher"); +class SentStickerMessage extends SentMessage_1.SentMessage { + constructor(time, channel, client, sticker) { + super(time, channel, client); + this.sticker = sticker; + } + async delete() { + if (this.channel instanceof Group_1.Group) { + let groupData = await CLIDispatcher_1.CLIDispatcher.dispatch("listGroups", {}, this.client.process); + await CLIDispatcher_1.CLIDispatcher.dispatch("remoteDelete", { + groupId: this.channel.id, + recipient: groupData['result'].filter(i => i.id === this.channel.id)[0].members.map(i => i.number), + targetTimestamp: this.createdTimestamp + }, this.client.process); + } + else { + await CLIDispatcher_1.CLIDispatcher.dispatch("remoteDelete", { + recipient: [this.channel.number], + targetTimestamp: this.createdTimestamp + }, this.client.process); + } + } +} +exports.SentStickerMessage = SentStickerMessage; +//# sourceMappingURL=SentStickerMessage.js.map
\ No newline at end of file diff --git a/dist/classes/SentStickerMessage.js.map b/dist/classes/SentStickerMessage.js.map new file mode 100644 index 0000000..b3ec747 --- /dev/null +++ b/dist/classes/SentStickerMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SentStickerMessage.js","sourceRoot":"","sources":["../../classes/SentStickerMessage.ts"],"names":[],"mappings":";;;AAGA,mCAA8B;AAE9B,+CAA0C;AAC1C,mDAA8C;AAI9C,MAAa,kBAAmB,SAAQ,yBAAW;IAG/C,YAAY,IAAY,EAAE,OAAiB,EAAE,MAAc,EAAE,OAAgB;QACzE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,MAAM;QACf,IAAI,IAAI,CAAC,OAAO,YAAY,aAAK,EAAE;YAC/B,IAAI,SAAS,GAAG,MAAM,6BAAa,CAAC,QAAQ,CACxC,YAAY,EACZ,EAAE,EACF,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;YAEF,MAAM,6BAAa,CAAC,QAAQ,CACxB,cAAc,EACd;gBACI,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;gBACxB,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;gBAClG,eAAe,EAAE,IAAI,CAAC,gBAAgB;aACzC,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;SACL;aAAM;YACH,MAAM,6BAAa,CAAC,QAAQ,CACxB,cAAc,EACd;gBACI,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;gBAChC,eAAe,EAAE,IAAI,CAAC,gBAAgB;aACzC,EACD,IAAI,CAAC,MAAM,CAAC,OAAO,CACtB,CAAC;SACL;IACL,CAAC;CACJ;AApCD,gDAoCC"}
\ No newline at end of file diff --git a/dist/classes/Sticker.d.ts b/dist/classes/Sticker.d.ts new file mode 100644 index 0000000..ec6cffa --- /dev/null +++ b/dist/classes/Sticker.d.ts @@ -0,0 +1,10 @@ +import { StickerPack } from "./StickerPack"; +import { Client } from "./Client"; +import { Emoji } from "./Emoji"; +import { StickerSource } from "../enums/StickerSource"; +export declare class Sticker { + pack: StickerPack; + id: number; + emoji?: Emoji; + constructor(source: StickerSource, data: any, client: Client, pack?: StickerPack); +} diff --git a/dist/classes/Sticker.js b/dist/classes/Sticker.js new file mode 100644 index 0000000..a140d97 --- /dev/null +++ b/dist/classes/Sticker.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Sticker = void 0; +const StickerPack_1 = require("./StickerPack"); +const Emoji_1 = require("./Emoji"); +const StickerSource_1 = require("../enums/StickerSource"); +class Sticker { + constructor(source, data, client, pack) { + if (source === StickerSource_1.StickerSource.Received) { + this.pack = new StickerPack_1.StickerPack(data.packId, client); + this.id = data.stickerId; + } + else if (source === StickerSource_1.StickerSource.Pack) { + this.pack = pack; + this.id = data.id; + this.emoji = new Emoji_1.Emoji(data.emoji); + } + } +} +exports.Sticker = Sticker; +//# sourceMappingURL=Sticker.js.map
\ No newline at end of file diff --git a/dist/classes/Sticker.js.map b/dist/classes/Sticker.js.map new file mode 100644 index 0000000..773fad9 --- /dev/null +++ b/dist/classes/Sticker.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Sticker.js","sourceRoot":"","sources":["../../classes/Sticker.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,mCAA8B;AAC9B,0DAAqD;AAErD,MAAa,OAAO;IAKhB,YAAY,MAAqB,EAAE,IAAS,EAAE,MAAc,EAAE,IAAkB;QAC5E,IAAI,MAAM,KAAK,6BAAa,CAAC,QAAQ,EAAE;YACnC,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACjD,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;SAC5B;aAAM,IAAI,MAAM,KAAK,6BAAa,CAAC,IAAI,EAAE;YACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACtC;IACL,CAAC;CACJ;AAfD,0BAeC"}
\ No newline at end of file diff --git a/dist/classes/StickerMessage.d.ts b/dist/classes/StickerMessage.d.ts new file mode 100644 index 0000000..44c6b59 --- /dev/null +++ b/dist/classes/StickerMessage.d.ts @@ -0,0 +1,4 @@ +import { Sticker } from "./Sticker"; +export declare class StickerMessage { + sticker: Sticker; +} diff --git a/dist/classes/StickerMessage.js b/dist/classes/StickerMessage.js new file mode 100644 index 0000000..376b5c1 --- /dev/null +++ b/dist/classes/StickerMessage.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StickerMessage = void 0; +class StickerMessage { +} +exports.StickerMessage = StickerMessage; +//# sourceMappingURL=StickerMessage.js.map
\ No newline at end of file diff --git a/dist/classes/StickerMessage.js.map b/dist/classes/StickerMessage.js.map new file mode 100644 index 0000000..2654a4b --- /dev/null +++ b/dist/classes/StickerMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StickerMessage.js","sourceRoot":"","sources":["../../classes/StickerMessage.ts"],"names":[],"mappings":";;;AAMA,MAAa,cAAc;CAE1B;AAFD,wCAEC"}
\ No newline at end of file diff --git a/dist/classes/StickerPack.d.ts b/dist/classes/StickerPack.d.ts new file mode 100644 index 0000000..26f7424 --- /dev/null +++ b/dist/classes/StickerPack.d.ts @@ -0,0 +1,11 @@ +import { Client } from "./Client"; +import { Sticker } from "./Sticker"; +export declare class StickerPack { + id: string; + title: string; + author: string; + url: string; + cover: Sticker; + items: Sticker[]; + constructor(id: string, client: Client); +} diff --git a/dist/classes/StickerPack.js b/dist/classes/StickerPack.js new file mode 100644 index 0000000..82cf1d5 --- /dev/null +++ b/dist/classes/StickerPack.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StickerPack = void 0; +const Sticker_1 = require("./Sticker"); +const StickerSource_1 = require("../enums/StickerSource"); +class StickerPack { + constructor(id, client) { + let cacheData = client.stickerPacks['list'].filter(i => i.packId === id)[0]; + this.id = cacheData.packId; + this.title = cacheData.title; + this.author = cacheData.author; + this.url = cacheData.url; + this.cover = new Sticker_1.Sticker(StickerSource_1.StickerSource.Pack, cacheData.cover, client, this); + this.items = cacheData.stickers.map(i => { + return new Sticker_1.Sticker(StickerSource_1.StickerSource.Pack, i, client, this); + }); + } +} +exports.StickerPack = StickerPack; +//# sourceMappingURL=StickerPack.js.map
\ No newline at end of file diff --git a/dist/classes/StickerPack.js.map b/dist/classes/StickerPack.js.map new file mode 100644 index 0000000..70ee4c3 --- /dev/null +++ b/dist/classes/StickerPack.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StickerPack.js","sourceRoot":"","sources":["../../classes/StickerPack.ts"],"names":[],"mappings":";;;AACA,uCAAkC;AAClC,0DAAqD;AAErD,MAAa,WAAW;IAQpB,YAAY,EAAU,EAAE,MAAc;QAClC,IAAI,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5E,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAO,CAAC,6BAAa,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACpC,OAAO,IAAI,iBAAO,CAAC,6BAAa,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AApBD,kCAoBC"}
\ No newline at end of file diff --git a/dist/classes/User.d.ts b/dist/classes/User.d.ts index f8a9752..41800ba 100644 --- a/dist/classes/User.d.ts +++ b/dist/classes/User.d.ts @@ -1,8 +1,8 @@ import { UserDataType } from "../enums/UserDataType"; export declare class User { - number: string | null; - nickName: string | null; - uuid: string | null; - device: number | null; + number?: string; + nickName?: string; + uuid?: string; + device?: number; constructor(data: any, dataType: UserDataType); } diff --git a/dist/classes/User.js b/dist/classes/User.js index ff8a3eb..7bbb1f5 100644 --- a/dist/classes/User.js +++ b/dist/classes/User.js @@ -15,7 +15,7 @@ class User { this.nickName = data.sourceName; if (data.sourceUuid && typeof data.sourceUuid === "string") this.uuid = data.sourceUuid; - if (data.sourceDevice && typeof data.sourceDevice === "string") + if (data.sourceDevice && typeof data.sourceDevice === "number") this.device = data.sourceDevice; } else if (dataType === UserDataType_1.UserDataType.Quote) { @@ -30,6 +30,12 @@ class User { if (data.targetAuthorUuid && typeof data.targetAuthorUuid === "string") this.uuid = data.targetAuthorUuid; } + else if (dataType === UserDataType_1.UserDataType.Mention) { + if (data.number && typeof data.number === "string") + this.number = data.number; + if (data.uuid && typeof data.uuid === "string") + this.uuid = data.uuid; + } } } exports.User = User; diff --git a/dist/classes/User.js.map b/dist/classes/User.js.map index 9ddd1bb..1667a02 100644 --- a/dist/classes/User.js.map +++ b/dist/classes/User.js.map @@ -1 +1 @@ -{"version":3,"file":"User.js","sourceRoot":"","sources":["../../classes/User.ts"],"names":[],"mappings":";;;AAAA,wDAAmD;AAEnD,MAAa,IAAI;IAMb,YAAY,IAAS,EAAE,QAAsB;QALtC,WAAM,GAAgB,IAAI,CAAC;QAC3B,aAAQ,GAAgB,IAAI,CAAC;QAC7B,SAAI,GAAgB,IAAI,CAAC;QACzB,WAAM,GAAgB,IAAI,CAAC;QAG9B,IAAI,QAAQ,KAAK,2BAAY,CAAC,QAAQ,EAAE;YACpC,IAAI,IAAI,CAAC,YAAY,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ;gBAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChG,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC;YAC5F,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;gBAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;YACxF,IAAI,IAAI,CAAC,YAAY,IAAI,O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AC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SACzE;IACL,CAAC;CACJ;AAvBD,oBAuBC"}
\ No newline at end of file diff --git a/dist/classes/UserMention.d.ts b/dist/classes/UserMention.d.ts new file mode 100644 index 0000000..130de9b --- /dev/null +++ b/dist/classes/UserMention.d.ts @@ -0,0 +1,10 @@ +import { User } from "./User"; +import { IUserResolvable } from "../types/IUserResolvable"; +export declare class UserMention { + number: string; + uuid?: string; + start: number; + length?: number; + constructor(user: User | IUserResolvable, start?: number, length?: number); + toCLIFormat(): string; +} diff --git a/dist/classes/UserMention.js b/dist/classes/UserMention.js new file mode 100644 index 0000000..984bf4d --- /dev/null +++ b/dist/classes/UserMention.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UserMention = void 0; +const User_1 = require("./User"); +class UserMention { + constructor(user, start, length) { + this.length = 1; + this.number = user instanceof User_1.User ? user.number : user; + this.start = start ?? 0; + this.length = length ?? 1; + } + toCLIFormat() { + return this.start + ":" + this.length + ":" + this.number; + } +} +exports.UserMention = UserMention; +//# sourceMappingURL=UserMention.js.map
\ No newline at end of file diff --git a/dist/classes/UserMention.js.map b/dist/classes/UserMention.js.map new file mode 100644 index 0000000..545b556 --- /dev/null +++ b/dist/classes/UserMention.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserMention.js","sourceRoot":"","sources":["../../classes/UserMention.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAG5B,MAAa,WAAW;IAMpB,YAAY,IAA0B,EAAE,KAAc,EAAE,MAAe;QAFhE,WAAM,GAAY,CAAC,CAAC;QAGvB,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,WAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9D,CAAC;CACJ;AAfD,kCAeC"}
\ No newline at end of file diff --git a/dist/classes/UserResolvable.d.ts b/dist/classes/UserResolvable.d.ts new file mode 100644 index 0000000..a517246 --- /dev/null +++ b/dist/classes/UserResolvable.d.ts @@ -0,0 +1,4 @@ +export declare class UserResolvable { + number: string; + constructor(number: string); +} diff --git a/dist/classes/UserResolvable.js b/dist/classes/UserResolvable.js new file mode 100644 index 0000000..f4211b9 --- /dev/null +++ b/dist/classes/UserResolvable.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UserResolvable = void 0; +class UserResolvable { + constructor(number) { + this.number = number; + } +} +exports.UserResolvable = UserResolvable; +//# sourceMappingURL=UserResolvable.js.map
\ No newline at end of file diff --git a/dist/classes/UserResolvable.js.map b/dist/classes/UserResolvable.js.map new file mode 100644 index 0000000..dce1040 --- /dev/null +++ b/dist/classes/UserResolvable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserResolvable.js","sourceRoot":"","sources":["../../classes/UserResolvable.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IAGvB,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAND,wCAMC"}
\ No newline at end of file diff --git a/dist/enums/MessageFormattingFormat.d.ts b/dist/enums/MessageFormattingFormat.d.ts new file mode 100644 index 0000000..9698dba --- /dev/null +++ b/dist/enums/MessageFormattingFormat.d.ts @@ -0,0 +1,4 @@ +export declare enum MessageFormattingFormat { + Signal = 0, + Markdown = 1 +} diff --git a/dist/enums/MessageFormattingFormat.js b/dist/enums/MessageFormattingFormat.js new file mode 100644 index 0000000..94e2daf --- /dev/null +++ b/dist/enums/MessageFormattingFormat.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageFormattingFormat = void 0; +var MessageFormattingFormat; +(function (MessageFormattingFormat) { + MessageFormattingFormat[MessageFormattingFormat["Signal"] = 0] = "Signal"; + MessageFormattingFormat[MessageFormattingFormat["Markdown"] = 1] = "Markdown"; +})(MessageFormattingFormat || (exports.MessageFormattingFormat = MessageFormattingFormat = {})); +//# sourceMappingURL=MessageFormattingFormat.js.map
\ No newline at end of file diff --git a/dist/enums/MessageFormattingFormat.js.map b/dist/enums/MessageFormattingFormat.js.map new file mode 100644 index 0000000..9d7b441 --- /dev/null +++ b/dist/enums/MessageFormattingFormat.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MessageFormattingFormat.js","sourceRoot":"","sources":["../../enums/MessageFormattingFormat.ts"],"names":[],"mappings":";;;AAAA,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IAC/B,yEAAM,CAAA;IACN,6EAAQ,CAAA;AACZ,CAAC,EAHW,uBAAuB,uCAAvB,uBAAuB,QAGlC"}
\ No newline at end of file diff --git a/dist/enums/MessageFormattingStyle.d.ts b/dist/enums/MessageFormattingStyle.d.ts new file mode 100644 index 0000000..b3cf4b4 --- /dev/null +++ b/dist/enums/MessageFormattingStyle.d.ts @@ -0,0 +1,7 @@ +export declare enum MessageFormattingStyle { + Bold = "BOLD", + Italic = "ITALIC", + Strikethrough = "STRIKETHROUGH", + Monospace = "MONOSPACE", + Spoiler = "SPOILER" +} diff --git a/dist/enums/MessageFormattingStyle.js b/dist/enums/MessageFormattingStyle.js new file mode 100644 index 0000000..5560b4a --- /dev/null +++ b/dist/enums/MessageFormattingStyle.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageFormattingStyle = void 0; +var MessageFormattingStyle; +(function (MessageFormattingStyle) { + MessageFormattingStyle["Bold"] = "BOLD"; + MessageFormattingStyle["Italic"] = "ITALIC"; + MessageFormattingStyle["Strikethrough"] = "STRIKETHROUGH"; + MessageFormattingStyle["Monospace"] = "MONOSPACE"; + MessageFormattingStyle["Spoiler"] = "SPOILER"; +})(MessageFormattingStyle || (exports.MessageFormattingStyle = MessageFormattingStyle = {})); +//# sourceMappingURL=MessageFormattingStyle.js.map
\ No newline at end of file diff --git a/dist/enums/MessageFormattingStyle.js.map b/dist/enums/MessageFormattingStyle.js.map new file mode 100644 index 0000000..07734df --- /dev/null +++ b/dist/enums/MessageFormattingStyle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MessageFormattingStyle.js","sourceRoot":"","sources":["../../enums/MessageFormattingStyle.ts"],"names":[],"mappings":";;;AAAA,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAC9B,uCAAa,CAAA;IACb,2CAAiB,CAAA;IACjB,yDAA+B,CAAA;IAC/B,iDAAuB,CAAA;IACvB,6CAAmB,CAAA;AACvB,CAAC,EANW,sBAAsB,sCAAtB,sBAAsB,QAMjC"}
\ No newline at end of file diff --git a/dist/enums/StickerSource.d.ts b/dist/enums/StickerSource.d.ts new file mode 100644 index 0000000..a0b68c9 --- /dev/null +++ b/dist/enums/StickerSource.d.ts @@ -0,0 +1,4 @@ +export declare enum StickerSource { + Received = 0, + Pack = 1 +} diff --git a/dist/enums/StickerSource.js b/dist/enums/StickerSource.js new file mode 100644 index 0000000..66cb34c --- /dev/null +++ b/dist/enums/StickerSource.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StickerSource = void 0; +var StickerSource; +(function (StickerSource) { + StickerSource[StickerSource["Received"] = 0] = "Received"; + StickerSource[StickerSource["Pack"] = 1] = "Pack"; +})(StickerSource || (exports.StickerSource = StickerSource = {})); +//# sourceMappingURL=StickerSource.js.map
\ No newline at end of file diff --git a/dist/enums/StickerSource.js.map b/dist/enums/StickerSource.js.map new file mode 100644 index 0000000..9be615c --- /dev/null +++ b/dist/enums/StickerSource.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StickerSource.js","sourceRoot":"","sources":["../../enums/StickerSource.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,yDAAQ,CAAA;IACR,iDAAI,CAAA;AACR,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
\ No newline at end of file diff --git a/dist/enums/UserDataType.d.ts b/dist/enums/UserDataType.d.ts index 790cca9..a365f9f 100644 --- a/dist/enums/UserDataType.d.ts +++ b/dist/enums/UserDataType.d.ts @@ -1,5 +1,6 @@ export declare enum UserDataType { - Envelope = "envelope", - Quote = "quote", - Reaction = "reaction" + Envelope = 0, + Quote = 1, + Reaction = 2, + Mention = 3 } diff --git a/dist/enums/UserDataType.js b/dist/enums/UserDataType.js index 93df91e..0a714c1 100644 --- a/dist/enums/UserDataType.js +++ b/dist/enums/UserDataType.js @@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.UserDataType = void 0; var UserDataType; (function (UserDataType) { - UserDataType["Envelope"] = "envelope"; - UserDataType["Quote"] = "quote"; - UserDataType["Reaction"] = "reaction"; + UserDataType[UserDataType["Envelope"] = 0] = "Envelope"; + UserDataType[UserDataType["Quote"] = 1] = "Quote"; + UserDataType[UserDataType["Reaction"] = 2] = "Reaction"; + UserDataType[UserDataType["Mention"] = 3] = "Mention"; })(UserDataType || (exports.UserDataType = UserDataType = {})); //# sourceMappingURL=UserDataType.js.map
\ No newline at end of file diff --git a/dist/enums/UserDataType.js.map b/dist/enums/UserDataType.js.map index 34b14dd..8ec88cb 100644 --- a/dist/enums/UserDataType.js.map +++ b/dist/enums/UserDataType.js.map @@ -1 +1 @@ -{"version":3,"file":"UserDataType.js","sourceRoot":"","sources":["../../enums/UserDataType.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,+BAAe,CAAA;IACf,qCAAqB,CAAA;AACzB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB"}
\ No newline at end of file +{"version":3,"file":"UserDataType.js","sourceRoot":"","sources":["../../enums/UserDataType.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,uDAAQ,CAAA;IACR,iDAAK,CAAA;IACL,uDAAQ,CAAA;IACR,qDAAO,CAAA;AACX,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB"}
\ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 06b7054..3d76003 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1 +1,8 @@ export { Client } from "./classes/Client"; +export { QuoteMessage } from "./classes/QuoteMessage"; +export { QuoteBuilder } from "./classes/QuoteBuilder"; +export { AttachmentBuilder } from "./classes/AttachmentBuilder"; +export { MessageFormatting } from "./classes/MessageFormatting"; +export { MessageFormattingRule } from "./classes/MessageFormattingRule"; +export { IUserResolvable } from "./types/IUserResolvable"; +export { UserMention } from "./classes/UserMention"; diff --git a/dist/index.js b/dist/index.js index 4c69e67..ae57320 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,6 +1,18 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Client = void 0; +exports.UserMention = exports.MessageFormattingRule = exports.MessageFormatting = exports.AttachmentBuilder = exports.QuoteBuilder = exports.QuoteMessage = exports.Client = void 0; var Client_1 = require("./classes/Client"); Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } }); +var QuoteMessage_1 = require("./classes/QuoteMessage"); +Object.defineProperty(exports, "QuoteMessage", { enumerable: true, get: function () { return QuoteMessage_1.QuoteMessage; } }); +var QuoteBuilder_1 = require("./classes/QuoteBuilder"); +Object.defineProperty(exports, "QuoteBuilder", { enumerable: true, get: function () { return QuoteBuilder_1.QuoteBuilder; } }); +var AttachmentBuilder_1 = require("./classes/AttachmentBuilder"); +Object.defineProperty(exports, "AttachmentBuilder", { enumerable: true, get: function () { return AttachmentBuilder_1.AttachmentBuilder; } }); +var MessageFormatting_1 = require("./classes/MessageFormatting"); +Object.defineProperty(exports, "MessageFormatting", { enumerable: true, get: function () { return MessageFormatting_1.MessageFormatting; } }); +var MessageFormattingRule_1 = require("./classes/MessageFormattingRule"); +Object.defineProperty(exports, "MessageFormattingRule", { enumerable: true, get: function () { return MessageFormattingRule_1.MessageFormattingRule; } }); +var UserMention_1 = require("./classes/UserMention"); +Object.defineProperty(exports, "UserMention", { enumerable: true, get: function () { return UserMention_1.UserMention; } }); //# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index 51458ae..5936a01 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAAhC,gGAAA,MAAM,OAAA"}
\ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAAhC,gGAAA,MAAM,OAAA;AACd,uDAAoD;AAA5C,4GAAA,YAAY,OAAA;AACpB,uDAAoD;AAA5C,4GAAA,YAAY,OAAA;AACpB,iEAA8D;AAAtD,sHAAA,iBAAiB,OAAA;AACzB,iEAA8D;AAAtD,sHAAA,iBAAiB,OAAA;AACzB,yEAAsE;AAA9D,8HAAA,qBAAqB,OAAA;AAE7B,qDAAkD;AAA1C,0GAAA,WAAW,OAAA"}
\ No newline at end of file diff --git a/dist/types/IAttachmentBuilderData.d.ts b/dist/types/IAttachmentBuilderData.d.ts new file mode 100644 index 0000000..fd61f9c --- /dev/null +++ b/dist/types/IAttachmentBuilderData.d.ts @@ -0,0 +1,7 @@ +/// <reference types="node" /> +import { IMimeType } from "./IMimeType"; +export interface IAttachmentBuilderData { + data: Buffer; + type?: IMimeType; + fileName?: string; +} diff --git a/dist/types/IAttachmentBuilderData.js b/dist/types/IAttachmentBuilderData.js new file mode 100644 index 0000000..eb2e5a6 --- /dev/null +++ b/dist/types/IAttachmentBuilderData.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IAttachmentBuilderData.js.map
\ No newline at end of file diff --git a/dist/types/IAttachmentBuilderData.js.map b/dist/types/IAttachmentBuilderData.js.map new file mode 100644 index 0000000..e1caa41 --- /dev/null +++ b/dist/types/IAttachmentBuilderData.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IAttachmentBuilderData.js","sourceRoot":"","sources":["../../types/IAttachmentBuilderData.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IChatMessageOptions.d.ts b/dist/types/IChatMessageOptions.d.ts new file mode 100644 index 0000000..9b0ee5b --- /dev/null +++ b/dist/types/IChatMessageOptions.d.ts @@ -0,0 +1,13 @@ +import { AttachmentBuilder } from "../classes/AttachmentBuilder"; +import { QuoteBuilder } from "../classes/QuoteBuilder"; +import { MessageFormatting } from "../classes/MessageFormatting"; +import { UserMention } from "../classes/UserMention"; +import { IReceivedMessageURLPreview } from "./IReceivedMessageURLPreview"; +export interface IChatMessageOptions { + attachments?: AttachmentBuilder[]; + quote?: QuoteBuilder; + original?: number; + preview?: IReceivedMessageURLPreview; + formatting?: MessageFormatting; + mentions?: UserMention[]; +} diff --git a/dist/types/IChatMessageOptions.js b/dist/types/IChatMessageOptions.js new file mode 100644 index 0000000..155bd09 --- /dev/null +++ b/dist/types/IChatMessageOptions.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IChatMessageOptions.js.map
\ No newline at end of file diff --git a/dist/types/IChatMessageOptions.js.map b/dist/types/IChatMessageOptions.js.map new file mode 100644 index 0000000..9384f0a --- /dev/null +++ b/dist/types/IChatMessageOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IChatMessageOptions.js","sourceRoot":"","sources":["../../types/IChatMessageOptions.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IChatMessageURLPreview.d.ts b/dist/types/IChatMessageURLPreview.d.ts new file mode 100644 index 0000000..db4718c --- /dev/null +++ b/dist/types/IChatMessageURLPreview.d.ts @@ -0,0 +1,9 @@ +import { IFilePath } from "./IFilePath"; +import { Attachment } from "../classes/Attachment"; +import { IDataURI } from "./IDataURI"; +export interface IChatMessageURLPreview { + url: string; + title: string; + description?: string; + image?: IFilePath | Attachment | IDataURI; +} diff --git a/dist/types/IChatMessageURLPreview.js b/dist/types/IChatMessageURLPreview.js new file mode 100644 index 0000000..abc9133 --- /dev/null +++ b/dist/types/IChatMessageURLPreview.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IChatMessageURLPreview.js.map
\ No newline at end of file diff --git a/dist/types/IChatMessageURLPreview.js.map b/dist/types/IChatMessageURLPreview.js.map new file mode 100644 index 0000000..b0fcb42 --- /dev/null +++ b/dist/types/IChatMessageURLPreview.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IChatMessageURLPreview.js","sourceRoot":"","sources":["../../types/IChatMessageURLPreview.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IDataURI.d.ts b/dist/types/IDataURI.d.ts new file mode 100644 index 0000000..fc468bd --- /dev/null +++ b/dist/types/IDataURI.d.ts @@ -0,0 +1,2 @@ +import { IMimeType } from "./IMimeType"; +export type IDataURI = `data:${IMimeType};base64,${string}` | `data:${IMimeType};filename=${string};base64,${string}`; diff --git a/dist/types/IDataURI.js b/dist/types/IDataURI.js new file mode 100644 index 0000000..e5f7341 --- /dev/null +++ b/dist/types/IDataURI.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IDataURI.js.map
\ No newline at end of file diff --git a/dist/types/IDataURI.js.map b/dist/types/IDataURI.js.map new file mode 100644 index 0000000..e3d007f --- /dev/null +++ b/dist/types/IDataURI.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IDataURI.js","sourceRoot":"","sources":["../../types/IDataURI.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IFilePath.d.ts b/dist/types/IFilePath.d.ts new file mode 100644 index 0000000..1bbf34f --- /dev/null +++ b/dist/types/IFilePath.d.ts @@ -0,0 +1 @@ +export type IFilePath = string; diff --git a/dist/types/IFilePath.js b/dist/types/IFilePath.js new file mode 100644 index 0000000..ab41a56 --- /dev/null +++ b/dist/types/IFilePath.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IFilePath.js.map
\ No newline at end of file diff --git a/dist/types/IFilePath.js.map b/dist/types/IFilePath.js.map new file mode 100644 index 0000000..c129082 --- /dev/null +++ b/dist/types/IFilePath.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IFilePath.js","sourceRoot":"","sources":["../../types/IFilePath.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IReceivedMessageURLPreview.d.ts b/dist/types/IReceivedMessageURLPreview.d.ts new file mode 100644 index 0000000..c0dd3fe --- /dev/null +++ b/dist/types/IReceivedMessageURLPreview.d.ts @@ -0,0 +1,5 @@ +import { Attachment } from "../classes/Attachment"; +import { IChatMessageURLPreview } from "./IChatMessageURLPreview"; +export interface IReceivedMessageURLPreview extends IChatMessageURLPreview { + image?: Attachment; +} diff --git a/dist/types/IReceivedMessageURLPreview.js b/dist/types/IReceivedMessageURLPreview.js new file mode 100644 index 0000000..db2ea64 --- /dev/null +++ b/dist/types/IReceivedMessageURLPreview.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IReceivedMessageURLPreview.js.map
\ No newline at end of file diff --git a/dist/types/IReceivedMessageURLPreview.js.map b/dist/types/IReceivedMessageURLPreview.js.map new file mode 100644 index 0000000..1ee1d4a --- /dev/null +++ b/dist/types/IReceivedMessageURLPreview.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IReceivedMessageURLPreview.js","sourceRoot":"","sources":["../../types/IReceivedMessageURLPreview.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/ISentMessageURLPreview.d.ts b/dist/types/ISentMessageURLPreview.d.ts new file mode 100644 index 0000000..83ca4df --- /dev/null +++ b/dist/types/ISentMessageURLPreview.d.ts @@ -0,0 +1,6 @@ +import { IFilePath } from "./IFilePath"; +import { IDataURI } from "./IDataURI"; +import { IChatMessageURLPreview } from "./IChatMessageURLPreview"; +export interface ISentMessageURLPreview extends IChatMessageURLPreview { + image?: IFilePath | IDataURI; +} diff --git a/dist/types/ISentMessageURLPreview.js b/dist/types/ISentMessageURLPreview.js new file mode 100644 index 0000000..22d0a9a --- /dev/null +++ b/dist/types/ISentMessageURLPreview.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=ISentMessageURLPreview.js.map
\ No newline at end of file diff --git a/dist/types/ISentMessageURLPreview.js.map b/dist/types/ISentMessageURLPreview.js.map new file mode 100644 index 0000000..4b51e31 --- /dev/null +++ b/dist/types/ISentMessageURLPreview.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ISentMessageURLPreview.js","sourceRoot":"","sources":["../../types/ISentMessageURLPreview.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/dist/types/IUserResolvable.d.ts b/dist/types/IUserResolvable.d.ts new file mode 100644 index 0000000..4f19eac --- /dev/null +++ b/dist/types/IUserResolvable.d.ts @@ -0,0 +1 @@ +export type IUserResolvable = `+${number}`; diff --git a/dist/types/IUserResolvable.js b/dist/types/IUserResolvable.js new file mode 100644 index 0000000..5446e57 --- /dev/null +++ b/dist/types/IUserResolvable.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IUserResolvable.js.map
\ No newline at end of file diff --git a/dist/types/IUserResolvable.js.map b/dist/types/IUserResolvable.js.map new file mode 100644 index 0000000..00348e8 --- /dev/null +++ b/dist/types/IUserResolvable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IUserResolvable.js","sourceRoot":"","sources":["../../types/IUserResolvable.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/enums/MessageFormattingFormat.ts b/enums/MessageFormattingFormat.ts new file mode 100644 index 0000000..d3a0904 --- /dev/null +++ b/enums/MessageFormattingFormat.ts @@ -0,0 +1,4 @@ +export enum MessageFormattingFormat { + Signal, + Markdown +}
\ No newline at end of file diff --git a/enums/MessageFormattingStyle.ts b/enums/MessageFormattingStyle.ts new file mode 100644 index 0000000..e469da0 --- /dev/null +++ b/enums/MessageFormattingStyle.ts @@ -0,0 +1,7 @@ +export enum MessageFormattingStyle { + Bold = "BOLD", + Italic = "ITALIC", + Strikethrough = "STRIKETHROUGH", + Monospace = "MONOSPACE", + Spoiler = "SPOILER" +}
\ No newline at end of file diff --git a/enums/StickerSource.ts b/enums/StickerSource.ts new file mode 100644 index 0000000..00d610a --- /dev/null +++ b/enums/StickerSource.ts @@ -0,0 +1,4 @@ +export enum StickerSource { + Received, + Pack +}
\ No newline at end of file diff --git a/enums/UserDataType.ts b/enums/UserDataType.ts index c6179d9..829f9bb 100644 --- a/enums/UserDataType.ts +++ b/enums/UserDataType.ts @@ -1,5 +1,6 @@ export enum UserDataType { - Envelope = "envelope", - Quote = "quote", - Reaction = "reaction" + Envelope, + Quote, + Reaction, + Mention }
\ No newline at end of file @@ -1 +1,8 @@ -export {Client} from "./classes/Client";
\ No newline at end of file +export {Client} from "./classes/Client"; +export {QuoteMessage} from "./classes/QuoteMessage"; +export {QuoteBuilder} from "./classes/QuoteBuilder"; +export {AttachmentBuilder} from "./classes/AttachmentBuilder"; +export {MessageFormatting} from "./classes/MessageFormatting"; +export {MessageFormattingRule} from "./classes/MessageFormattingRule"; +export {IUserResolvable} from "./types/IUserResolvable"; +export {UserMention} from "./classes/UserMention";
\ No newline at end of file diff --git a/package.json b/package.json index 5eb8d0f..7a70b64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "signal.js", - "version": "0.1.0", + "version": "0.2.0", "description": "An easy-to-use Node.js library for Signal", "main": "dist/index.js", "repository": { diff --git a/types/IAttachmentBuilderData.ts b/types/IAttachmentBuilderData.ts new file mode 100644 index 0000000..43157d7 --- /dev/null +++ b/types/IAttachmentBuilderData.ts @@ -0,0 +1,7 @@ +import {IMimeType} from "./IMimeType"; + +export interface IAttachmentBuilderData { + data: Buffer; + type?: IMimeType; + fileName?: string; +}
\ No newline at end of file diff --git a/types/IChatMessageOptions.ts b/types/IChatMessageOptions.ts new file mode 100644 index 0000000..8ea3939 --- /dev/null +++ b/types/IChatMessageOptions.ts @@ -0,0 +1,15 @@ +import {AttachmentBuilder} from "../classes/AttachmentBuilder"; +import {QuoteBuilder} from "../classes/QuoteBuilder"; +import {IChatMessageURLPreview} from "./IChatMessageURLPreview"; +import {MessageFormatting} from "../classes/MessageFormatting"; +import {UserMention} from "../classes/UserMention"; +import {IReceivedMessageURLPreview} from "./IReceivedMessageURLPreview"; + +export interface IChatMessageOptions { + attachments?: AttachmentBuilder[]; + quote?: QuoteBuilder; + original?: number; + preview?: IReceivedMessageURLPreview; + formatting?: MessageFormatting; + mentions?: UserMention[]; +}
\ No newline at end of file diff --git a/types/IChatMessageURLPreview.ts b/types/IChatMessageURLPreview.ts new file mode 100644 index 0000000..1c63a2b --- /dev/null +++ b/types/IChatMessageURLPreview.ts @@ -0,0 +1,10 @@ +import {IFilePath} from "./IFilePath"; +import {Attachment} from "../classes/Attachment"; +import {IDataURI} from "./IDataURI"; + +export interface IChatMessageURLPreview { + url: string; + title: string; + description?: string; + image?: IFilePath|Attachment|IDataURI; +}
\ No newline at end of file diff --git a/types/IDataURI.ts b/types/IDataURI.ts new file mode 100644 index 0000000..7010c1e --- /dev/null +++ b/types/IDataURI.ts @@ -0,0 +1,3 @@ +import {IMimeType} from "./IMimeType"; + +export type IDataURI = `data:${IMimeType};base64,${string}`|`data:${IMimeType};filename=${string};base64,${string}`;
\ No newline at end of file diff --git a/types/IFilePath.ts b/types/IFilePath.ts new file mode 100644 index 0000000..f5d20a9 --- /dev/null +++ b/types/IFilePath.ts @@ -0,0 +1 @@ +export type IFilePath = string;
\ No newline at end of file diff --git a/types/IReceivedMessageURLPreview.ts b/types/IReceivedMessageURLPreview.ts new file mode 100644 index 0000000..4521ffa --- /dev/null +++ b/types/IReceivedMessageURLPreview.ts @@ -0,0 +1,8 @@ +import {IFilePath} from "./IFilePath"; +import {Attachment} from "../classes/Attachment"; +import {IDataURI} from "./IDataURI"; +import {IChatMessageURLPreview} from "./IChatMessageURLPreview"; + +export interface IReceivedMessageURLPreview extends IChatMessageURLPreview { + image?: Attachment; +}
\ No newline at end of file diff --git a/types/ISentMessageURLPreview.ts b/types/ISentMessageURLPreview.ts new file mode 100644 index 0000000..cd68607 --- /dev/null +++ b/types/ISentMessageURLPreview.ts @@ -0,0 +1,8 @@ +import {IFilePath} from "./IFilePath"; +import {Attachment} from "../classes/Attachment"; +import {IDataURI} from "./IDataURI"; +import {IChatMessageURLPreview} from "./IChatMessageURLPreview"; + +export interface ISentMessageURLPreview extends IChatMessageURLPreview { + image?: IFilePath|IDataURI; +}
\ No newline at end of file diff --git a/types/IUserResolvable.ts b/types/IUserResolvable.ts new file mode 100644 index 0000000..5710755 --- /dev/null +++ b/types/IUserResolvable.ts @@ -0,0 +1 @@ +export type IUserResolvable = `+${number}`
\ No newline at end of file |