Added List message support and removed "saving auth state" (#1048)

* Added template support and footers for buttons & templates

* Template message readme

* got rid of "saving auth state" and added lists

* added body

* Update README.md
This commit is contained in:
Rajeh Taher
2021-12-19 18:59:35 +02:00
committed by GitHub
parent db941f1472
commit d62db2bbd6
4 changed files with 58 additions and 8 deletions

View File

@@ -58,6 +58,16 @@ type Templatable = {
footer?: string
}
type Listable = {
/** Sections of the List */
sections?: proto.ISection[]
/** Title of a List Message only */
title?: string
/** Text of the bnutton on the list (required) */
buttonText: string
}
type WithDimensions = {
width?: number
height?: number
@@ -93,7 +103,7 @@ export type AnyRegularMessageContent = (
({
text: string
}
& Mentionable & Buttonable & Templatable) |
& Mentionable & Buttonable & Templatable & Listable) |
AnyMediaMessageContent |
{
contacts: {

View File

@@ -112,7 +112,7 @@ export const initAuthCreds = (): AuthenticationCreds => {
}
/** stores the full authentication state in a single JSON file */
export const useSingleFileAuthState = (filename: string): { state: AuthenticationState, saveState: () => void } => {
export const useSingleFileAuthState = (filename: string, logger?: Logger): { state: AuthenticationState, saveState: () => void } => {
// require fs here so that in case "fs" is not available -- the app does not crash
const { readFileSync, writeFileSync, existsSync } = require('fs')
let creds: AuthenticationCreds
@@ -120,7 +120,7 @@ export const useSingleFileAuthState = (filename: string): { state: Authenticatio
// save the authentication state to a file
const saveState = () => {
console.log('saving auth state')
logger && logger.trace('saving auth state')
writeFileSync(
filename,
// BufferJSON replacer utility saves buffers nicely

View File

@@ -314,6 +314,18 @@ export const generateWAMessageContent = async(
m = { templateMessage }
}
if ('sections' in message && !!message.sections) {
const listMessage: proto.IListMessage = {
sections: message.sections,
buttonText: message.buttonText,
title: message.title,
footerText: message.footer,
description: message.text
}
m = { listMessage }
}
if('viewOnce' in message && !!message.viewOnce) {
m = { viewOnceMessage: { message: m } }