mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 04:59:14 +00:00
Reaction feature added. (#1400)
* Fix get order. * Fix types. * Add set picture for profile and for groups. * Fix bug. * Fix * Fix types * Fix eslint * Add send reaction feature. * Add send reaction feature. * Add set picture for profile and for groups. * Add send reaction feature. * Add send reaction feature. * Add send reaction feature. * Add send reaction feature. * Add send reaction feature. * Add send reaction feature. * Update src/structures/Reaction.js Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> * Bug fixes. * Bug fixes. * Bug fixes. * Fix * Fix * Fix example * Fix conflict * Fix conflict * Fix conflict * Fix conflict * Fix conflict * Fix conflict * move implementation to message model Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Pedro Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
GitHub
parent
a0b18fb685
commit
61c0a6be56
@@ -1,4 +1,4 @@
|
|||||||
const { Client, Location, List, Buttons, LocalAuth } = require('./index');
|
const { Client, Location, List, Buttons, LocalAuth} = require('./index');
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
authStrategy: new LocalAuth(),
|
authStrategy: new LocalAuth(),
|
||||||
@@ -191,6 +191,8 @@ client.on('message', async msg => {
|
|||||||
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];
|
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];
|
||||||
let list = new List('List body','btnText',sections,'Title','footer');
|
let list = new List('List body','btnText',sections,'Title','footer');
|
||||||
client.sendMessage(msg.from, list);
|
client.sendMessage(msg.from, list);
|
||||||
|
} else if (msg.body === '!reaction') {
|
||||||
|
msg.react('👍');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
8
index.d.ts
vendored
8
index.d.ts
vendored
@@ -687,7 +687,7 @@ declare namespace WAWebJS {
|
|||||||
acceptGroupV4Invite: () => Promise<{status: number}>,
|
acceptGroupV4Invite: () => Promise<{status: number}>,
|
||||||
/** Deletes the message from the chat */
|
/** Deletes the message from the chat */
|
||||||
delete: (everyone?: boolean) => Promise<void>,
|
delete: (everyone?: boolean) => Promise<void>,
|
||||||
/** Downloads and returns the attatched message media */
|
/** Downloads and returns the attached message media */
|
||||||
downloadMedia: () => Promise<MessageMedia>,
|
downloadMedia: () => Promise<MessageMedia>,
|
||||||
/** Returns the Chat this message was sent in */
|
/** Returns the Chat this message was sent in */
|
||||||
getChat: () => Promise<Chat>,
|
getChat: () => Promise<Chat>,
|
||||||
@@ -703,6 +703,8 @@ declare namespace WAWebJS {
|
|||||||
* If not, it will send the message in the same Chat as the original message was sent.
|
* If not, it will send the message in the same Chat as the original message was sent.
|
||||||
*/
|
*/
|
||||||
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
|
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
|
||||||
|
/** React to this message with an emoji*/
|
||||||
|
react: (reaction: string) => Promise,
|
||||||
/**
|
/**
|
||||||
* Forwards this message to another chat
|
* Forwards this message to another chat
|
||||||
*/
|
*/
|
||||||
@@ -711,7 +713,7 @@ declare namespace WAWebJS {
|
|||||||
star: () => Promise<void>,
|
star: () => Promise<void>,
|
||||||
/** Unstar this message */
|
/** Unstar this message */
|
||||||
unstar: () => Promise<void>,
|
unstar: () => Promise<void>,
|
||||||
/** Get information about message delivery statuso */
|
/** Get information about message delivery status */
|
||||||
getInfo: () => Promise<MessageInfo | null>,
|
getInfo: () => Promise<MessageInfo | null>,
|
||||||
/**
|
/**
|
||||||
* Gets the order associated with a given message
|
* Gets the order associated with a given message
|
||||||
@@ -1287,7 +1289,7 @@ declare namespace WAWebJS {
|
|||||||
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
|
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Message type buttons */
|
/** Message type Buttons */
|
||||||
export class Buttons {
|
export class Buttons {
|
||||||
body: string | MessageMedia
|
body: string | MessageMedia
|
||||||
buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
|
buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constan
|
|||||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||||
const ChatFactory = require('./factories/ChatFactory');
|
const ChatFactory = require('./factories/ChatFactory');
|
||||||
const ContactFactory = require('./factories/ContactFactory');
|
const ContactFactory = require('./factories/ContactFactory');
|
||||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List } = require('./structures');
|
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List} = require('./structures');
|
||||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
||||||
const NoAuth = require('./authStrategies/NoAuth');
|
const NoAuth = require('./authStrategies/NoAuth');
|
||||||
|
|
||||||
|
|||||||
@@ -335,6 +335,18 @@ class Message extends Base {
|
|||||||
return this.client.sendMessage(chatId, content, options);
|
return this.client.sendMessage(chatId, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* React to this message with an emoji
|
||||||
|
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
async react(reaction){
|
||||||
|
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
||||||
|
const msg = await window.Store.Msg.get(messageId);
|
||||||
|
await window.Store.sendReactionToMsg(msg, reaction);
|
||||||
|
}, this.id._serialized, reaction);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept Group V4 Invite
|
* Accept Group V4 Invite
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ module.exports = {
|
|||||||
Call: require('./Call'),
|
Call: require('./Call'),
|
||||||
Buttons: require('./Buttons'),
|
Buttons: require('./Buttons'),
|
||||||
List: require('./List'),
|
List: require('./List'),
|
||||||
Payment: require('./Payment')
|
Payment: require('./Payment'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|||||||
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
||||||
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
||||||
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
||||||
|
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
||||||
window.Store.StickerTools = {
|
window.Store.StickerTools = {
|
||||||
...window.mR.findModule('toWebpSticker')[0],
|
...window.mR.findModule('toWebpSticker')[0],
|
||||||
...window.mR.findModule('addWebpMetadata')[0]
|
...window.mR.findModule('addWebpMetadata')[0]
|
||||||
@@ -99,7 +100,6 @@ exports.LoadUtils = () => {
|
|||||||
delete options.attachment;
|
delete options.attachment;
|
||||||
delete options.sendMediaAsSticker;
|
delete options.sendMediaAsSticker;
|
||||||
}
|
}
|
||||||
|
|
||||||
let quotedMsgOptions = {};
|
let quotedMsgOptions = {};
|
||||||
if (options.quotedMessageId) {
|
if (options.quotedMessageId) {
|
||||||
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const { tmpdir } = require('os');
|
|||||||
const ffmpeg = require('fluent-ffmpeg');
|
const ffmpeg = require('fluent-ffmpeg');
|
||||||
const webp = require('node-webpmux');
|
const webp = require('node-webpmux');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ describe('Client', function() {
|
|||||||
'QueryOrder',
|
'QueryOrder',
|
||||||
'QueryProduct',
|
'QueryProduct',
|
||||||
'PresenceUtils',
|
'PresenceUtils',
|
||||||
|
'ProfilePic',
|
||||||
'QueryExist',
|
'QueryExist',
|
||||||
'QueryProduct',
|
'QueryProduct',
|
||||||
'QueryOrder',
|
'QueryOrder',
|
||||||
@@ -347,7 +348,7 @@ describe('Client', function() {
|
|||||||
'Wap',
|
'Wap',
|
||||||
'WidFactory',
|
'WidFactory',
|
||||||
'findCommonGroups',
|
'findCommonGroups',
|
||||||
'ProfilePic',
|
'sendReactionToMsg',
|
||||||
];
|
];
|
||||||
|
|
||||||
const loadedModules = await client.pupPage.evaluate((expectedModules) => {
|
const loadedModules = await client.pupPage.evaluate((expectedModules) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user