feat: send polls (#2377)
* feat: added Poll class * feat: logic for sending polls added * updated poll properties on returned message instance * docs updated * usage example updated * module fixed * 'pollSendOptions' changed to 'options' * window.compareWwebVersions fixed * small update to improve the performance of findImpl fix * added option for custom message secret * usage example updated
This commit is contained in:
parent
49feb3660c
commit
67d305be78
9 changed files with 131 additions and 6 deletions
29
index.d.ts
vendored
29
index.d.ts
vendored
|
|
@ -707,6 +707,7 @@ declare namespace WAWebJS {
|
|||
PROTOCOL = 'protocol',
|
||||
REACTION = 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY = 'template_button_reply',
|
||||
POLL_CREATION = 'poll_creation',
|
||||
}
|
||||
|
||||
/** Client status */
|
||||
|
|
@ -866,6 +867,11 @@ declare namespace WAWebJS {
|
|||
selectedRowId?: string,
|
||||
/** Returns message in a raw format */
|
||||
rawData: object,
|
||||
pollName: string,
|
||||
/** Avaiaible poll voting options */
|
||||
pollOptions: string[],
|
||||
/** False for a single choice poll, true for a multiple choice poll */
|
||||
allowMultipleAnswers: boolean,
|
||||
/*
|
||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
||||
|
|
@ -946,6 +952,27 @@ declare namespace WAWebJS {
|
|||
constructor(latitude: number, longitude: number, options?: LocationSendOptions)
|
||||
}
|
||||
|
||||
/** Poll send options */
|
||||
export interface PollSendOptions {
|
||||
/** False for a single choice poll, true for a multiple choice poll (false by default) */
|
||||
allowMultipleAnswers?: boolean,
|
||||
/**
|
||||
* The custom message secret, can be used as a poll ID
|
||||
* @note It has to be a unique vector with a length of 32
|
||||
*/
|
||||
messageSecret: ?Array<number>
|
||||
}
|
||||
|
||||
/** Represents a Poll on WhatsApp */
|
||||
export interface Poll {
|
||||
pollName: string,
|
||||
pollOptions: Array<{
|
||||
name: string,
|
||||
localId: number
|
||||
}>,
|
||||
options: PollSendOptions
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
/** Label name */
|
||||
name: string,
|
||||
|
|
@ -1037,7 +1064,7 @@ declare namespace WAWebJS {
|
|||
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
|
||||
}
|
||||
|
||||
export type MessageContent = string | MessageMedia | Location | Contact | Contact[] | List | Buttons
|
||||
export type MessageContent = string | MessageMedia | Location | Poll | Contact | Contact[] | List | Buttons
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
|
|
|
|||
Loading…
Reference in a new issue