mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge branch 'master' of https://github.com/adiwajshing/Baileys
This commit is contained in:
@@ -749,6 +749,13 @@ Of course, replace ``` xyz ``` with an actual ID.
|
||||
```
|
||||
Of course, replace ``` xxx ``` with invitation code.
|
||||
|
||||
|
||||
- To join the group using groupInviteMessage
|
||||
``` ts
|
||||
const response = await sock.groupAcceptInviteV4(groupInviteMessage)
|
||||
console.log("joined to: " + response)
|
||||
```
|
||||
Of course, replace ``` xxx ``` with invitation code.
|
||||
## Broadcast Lists & Stories
|
||||
|
||||
**Note:** messages cannot be sent to broadcast lists from the MD version right now
|
||||
|
||||
@@ -421,6 +421,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
type = 'available'
|
||||
}
|
||||
|
||||
if (firstChild.attrs?.media === 'audio'){
|
||||
type = 'recording';
|
||||
}
|
||||
|
||||
presence = { lastKnownPresence: type }
|
||||
} else {
|
||||
logger.error({ tag, attrs, content }, 'recv invalid presence node')
|
||||
|
||||
@@ -2,6 +2,7 @@ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types'
|
||||
import { generateMessageID } from '../Utils'
|
||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, jidNormalizedUser } from '../WABinary'
|
||||
import { makeSocket } from './socket'
|
||||
import { proto } from '../../WAProto'
|
||||
|
||||
export const makeGroupsSocket = (config: SocketConfig) => {
|
||||
const sock = makeSocket(config)
|
||||
@@ -134,6 +135,13 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
||||
const result = getBinaryNodeChild(results, 'group')
|
||||
return result.attrs.jid
|
||||
},
|
||||
groupAcceptInviteV4: async(jid: string, inviteMessage: proto.IGroupInviteMessage) => {
|
||||
const results = await groupQuery(inviteMessage.groupJid, 'set', [{ tag: 'accept', attrs: {
|
||||
code: inviteMessage.inviteCode,
|
||||
expiration: inviteMessage.inviteExpiration.toString(),
|
||||
admin: jid} }])
|
||||
return results.attrs.from;
|
||||
},
|
||||
groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => {
|
||||
const content: BinaryNode = ephemeralExpiration ?
|
||||
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
||||
|
||||
@@ -239,7 +239,7 @@ export default (
|
||||
|
||||
const fromJSON = (json: { chats: Chat[], contacts: { [id: string]: Contact }, messages: { [id: string]: WAMessage[] } }) => {
|
||||
chats.upsert(...json.chats)
|
||||
contactsUpsert(Object.values(contacts))
|
||||
contactsUpsert(Object.values(json.contacts))
|
||||
for(const jid in json.messages) {
|
||||
const list = assertMessageList(jid)
|
||||
for(const msg of json.messages[jid]) {
|
||||
|
||||
@@ -81,7 +81,7 @@ const extractVideoThumb = async(
|
||||
time: string,
|
||||
size: { width: number; height: number },
|
||||
) => new Promise((resolve, reject) => {
|
||||
const cmd = `ffmpeg -ss ${time} -i ${path} -y -s ${size.width}x${size.height} -vframes 1 -f image2 ${destPath}`
|
||||
const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}`
|
||||
exec(cmd, (err) => {
|
||||
if(err) {
|
||||
reject(err)
|
||||
@@ -99,17 +99,17 @@ export const extractImageThumb = async(bufferOrFilePath: Readable | Buffer | str
|
||||
const lib = await getImageProcessingLibrary()
|
||||
if('sharp' in lib) {
|
||||
const result = await lib.sharp!.default(bufferOrFilePath)
|
||||
.resize(32, 32)
|
||||
.resize(32)
|
||||
.jpeg({ quality: 50 })
|
||||
.toBuffer()
|
||||
return result
|
||||
} else {
|
||||
const { read, MIME_JPEG, RESIZE_BILINEAR } = lib.jimp
|
||||
const { read, MIME_JPEG, RESIZE_BILINEAR, AUTO } = lib.jimp
|
||||
|
||||
const jimp = await read(bufferOrFilePath as any)
|
||||
const result = await jimp
|
||||
.quality(50)
|
||||
.resize(32, 32, RESIZE_BILINEAR)
|
||||
.resize(32, AUTO, RESIZE_BILINEAR)
|
||||
.getBufferAsync(MIME_JPEG)
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user