Send message without quote if quoteFails (#3475)
* Send message without quote if quoteFails New option to send a message without quote when quotedMessage fails * Rest * Changing to sendMessage level * Update Utils.js * Update Utils.js * Update Utils.js --------- Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
parent
6d1655503f
commit
ad11b5bfee
2 changed files with 19 additions and 12 deletions
5
index.d.ts
vendored
5
index.d.ts
vendored
|
|
@ -1158,7 +1158,10 @@ declare namespace WAWebJS {
|
|||
/** Sticker author, if sendMediaAsSticker is true */
|
||||
stickerAuthor?: string
|
||||
/** Sticker categories, if sendMediaAsSticker is true */
|
||||
stickerCategories?: string[]
|
||||
stickerCategories?: string[],
|
||||
/** Should the bot send a quoted message without the quoted message if it fails to get the quote?
|
||||
* @default false (disabled) */
|
||||
ignoreQuoteErrors?: boolean
|
||||
}
|
||||
|
||||
/** Options for editing a message */
|
||||
|
|
|
|||
|
|
@ -46,20 +46,24 @@ exports.LoadUtils = () => {
|
|||
if (options.quotedMessageId) {
|
||||
let quotedMessage = await window.Store.Msg.getMessagesById([options.quotedMessageId]);
|
||||
|
||||
if (quotedMessage['messages'].length != 1) {
|
||||
throw new Error('Could not get the quoted message.');
|
||||
}
|
||||
if (quotedMessage['messages'].length == 1) {
|
||||
quotedMessage = quotedMessage['messages'][0];
|
||||
|
||||
quotedMessage = quotedMessage['messages'][0];
|
||||
// TODO remove .canReply() once all clients are updated to >= v2.2241.6
|
||||
const canReply = window.Store.ReplyUtils ?
|
||||
window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
|
||||
quotedMessage.canReply();
|
||||
|
||||
// TODO remove .canReply() once all clients are updated to >= v2.2241.6
|
||||
const canReply = window.Store.ReplyUtils ?
|
||||
window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
|
||||
quotedMessage.canReply();
|
||||
|
||||
if (canReply) {
|
||||
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
||||
if (canReply) {
|
||||
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
||||
}
|
||||
}else{
|
||||
if(!options.ignoreQuoteErrors) {
|
||||
throw new Error('Could not get the quoted message.');
|
||||
}
|
||||
}
|
||||
|
||||
delete options.ignoreQuoteErrors;
|
||||
delete options.quotedMessageId;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue