mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge branch 'WhiskeySockets:master' into master
This commit is contained in:
48
README.md
48
README.md
@@ -741,6 +741,11 @@ await sock.sendMessage(
|
|||||||
const jid = '111234567890-1594482450@g.us' // can be your own too
|
const jid = '111234567890-1594482450@g.us' // can be your own too
|
||||||
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
||||||
```
|
```
|
||||||
|
- To remove your display picture or a group's
|
||||||
|
``` ts
|
||||||
|
const jid = '111234567890-1594482450@g.us' // can be your own too
|
||||||
|
await sock.removeProfilePicture(jid)
|
||||||
|
```
|
||||||
- To get someone's presence (if they're typing or online)
|
- To get someone's presence (if they're typing or online)
|
||||||
``` ts
|
``` ts
|
||||||
// the presence update is fetched and called here
|
// the presence update is fetched and called here
|
||||||
@@ -832,7 +837,48 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|||||||
console.log("joined to: " + response)
|
console.log("joined to: " + response)
|
||||||
```
|
```
|
||||||
Of course, replace ``` xxx ``` with invitation code.
|
Of course, replace ``` xxx ``` with invitation code.
|
||||||
|
|
||||||
|
## Privacy
|
||||||
|
- To get the privacy settings
|
||||||
|
``` ts
|
||||||
|
const privacySettings = await sock.fetchPrivacySettings(true)
|
||||||
|
console.log("privacy settings: " + privacySettings)
|
||||||
|
```
|
||||||
|
- To update the LastSeen privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateLastSeenPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Online privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'match_last_seen'
|
||||||
|
await sock.updateOnlinePrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Profile Picture privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateProfilePicturePrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Status privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateStatusPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Read Receipts privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'none'
|
||||||
|
await sock.updateReadReceiptsPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Groups Add privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateGroupsAddPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Default Disappearing Mode
|
||||||
|
``` ts
|
||||||
|
const duration = 86400 // 604800 | 7776000 | 0
|
||||||
|
await sock.updateDefaultDisappearingMode(duration)
|
||||||
|
```
|
||||||
## Broadcast Lists & Stories
|
## Broadcast Lists & Stories
|
||||||
|
|
||||||
**Note:** messages currently cannot be sent to broadcast lists from the MD version.
|
**Note:** messages currently cannot be sent to broadcast lists from the MD version.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { PROCESSABLE_HISTORY_TYPES } from '../Defaults'
|
import { PROCESSABLE_HISTORY_TYPES } from '../Defaults'
|
||||||
import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence } from '../Types'
|
import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types'
|
||||||
import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils'
|
import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils'
|
||||||
import { makeMutex } from '../Utils/make-mutex'
|
import { makeMutex } from '../Utils/make-mutex'
|
||||||
import processMessage from '../Utils/process-message'
|
import processMessage from '../Utils/process-message'
|
||||||
@@ -61,6 +61,69 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
return privacySettings
|
return privacySettings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** helper function to run a privacy IQ query */
|
||||||
|
const privacyQuery = async(name: string, value: string) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
xmlns: 'privacy',
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
|
type: 'set'
|
||||||
|
},
|
||||||
|
content: [{
|
||||||
|
tag: 'privacy',
|
||||||
|
attrs: {},
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
tag: 'category',
|
||||||
|
attrs: { name, value }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateLastSeenPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('last', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateOnlinePrivacy = async(value: WAPrivacyOnlineValue) => {
|
||||||
|
await privacyQuery('online', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateProfilePicturePrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('profile', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStatusPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('status', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateReadReceiptsPrivacy = async(value: WAReadReceiptsValue) => {
|
||||||
|
await privacyQuery('readreceipts', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateGroupsAddPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('groupadd', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateDefaultDisappearingMode = async(duration: number) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
xmlns: 'disappearing_mode',
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
|
type: 'set'
|
||||||
|
},
|
||||||
|
content: [{
|
||||||
|
tag: 'disappearing_mode',
|
||||||
|
attrs: {
|
||||||
|
duration : duration.toString()
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** helper function to run a generic IQ query */
|
/** helper function to run a generic IQ query */
|
||||||
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
||||||
const result = await query({
|
const result = await query({
|
||||||
@@ -161,6 +224,18 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** remove the profile picture for yourself or a group */
|
||||||
|
const removeProfilePicture = async(jid: string) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
to: jidNormalizedUser(jid),
|
||||||
|
type: 'set',
|
||||||
|
xmlns: 'w:profile:picture'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** update the profile status for yourself */
|
/** update the profile status for yourself */
|
||||||
const updateProfileStatus = async(status: string) => {
|
const updateProfileStatus = async(status: string) => {
|
||||||
await query({
|
await query({
|
||||||
@@ -857,9 +932,17 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
fetchBlocklist,
|
fetchBlocklist,
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
updateProfilePicture,
|
updateProfilePicture,
|
||||||
|
removeProfilePicture,
|
||||||
updateProfileStatus,
|
updateProfileStatus,
|
||||||
updateProfileName,
|
updateProfileName,
|
||||||
updateBlockStatus,
|
updateBlockStatus,
|
||||||
|
updateLastSeenPrivacy,
|
||||||
|
updateOnlinePrivacy,
|
||||||
|
updateProfilePicturePrivacy,
|
||||||
|
updateStatusPrivacy,
|
||||||
|
updateReadReceiptsPrivacy,
|
||||||
|
updateGroupsAddPrivacy,
|
||||||
|
updateDefaultDisappearingMode,
|
||||||
getBusinessProfile,
|
getBusinessProfile,
|
||||||
resyncAppState,
|
resyncAppState,
|
||||||
chatModify
|
chatModify
|
||||||
|
|||||||
@@ -3,6 +3,13 @@ import type { AccountSettings } from './Auth'
|
|||||||
import type { BufferedEventData } from './Events'
|
import type { BufferedEventData } from './Events'
|
||||||
import type { MinimalMessage } from './Message'
|
import type { MinimalMessage } from './Message'
|
||||||
|
|
||||||
|
/** privacy settings in WhatsApp Web */
|
||||||
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
|
||||||
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen'
|
||||||
|
|
||||||
|
export type WAReadReceiptsValue = 'all' | 'none'
|
||||||
|
|
||||||
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
||||||
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user