@neelegirl/baileys 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Socket/chats.js +20 -0
- package/lib/Socket/messages-send.js +31 -0
- package/lib/Socket/socket.js +11 -4
- package/lib/Types/Bussines.d.ts +20 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Chat.d.ts +3 -0
- package/lib/Types/Events.d.ts +8 -0
- package/lib/Types/index.d.ts +1 -0
- package/lib/Utils/chat-utils.js +17 -0
- package/lib/Utils/check-npm-version.d.ts +2 -0
- package/lib/Utils/check-npm-version.js +2 -0
- package/lib/Utils/message-retry-manager.d.ts +2 -0
- package/lib/Utils/message-retry-manager.js +2 -0
- package/lib/Utils/process-message.js +12 -0
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -888,6 +888,24 @@ const makeChatsSocket = (config) => {
|
|
|
888
888
|
}, jid)
|
|
889
889
|
}
|
|
890
890
|
|
|
891
|
+
/**
|
|
892
|
+
* Add or Edit Quick Reply
|
|
893
|
+
*/
|
|
894
|
+
const addOrEditQuickReply = (quickReply) => {
|
|
895
|
+
return chatModify({
|
|
896
|
+
quickReply
|
|
897
|
+
}, '')
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Remove Quick Reply
|
|
902
|
+
*/
|
|
903
|
+
const removeQuickReply = (timestamp) => {
|
|
904
|
+
return chatModify({
|
|
905
|
+
quickReply: { timestamp, deleted: true }
|
|
906
|
+
}, '')
|
|
907
|
+
}
|
|
908
|
+
|
|
891
909
|
/**
|
|
892
910
|
* Removes Chats
|
|
893
911
|
*/
|
|
@@ -1104,6 +1122,8 @@ const makeChatsSocket = (config) => {
|
|
|
1104
1122
|
removeChatLabel,
|
|
1105
1123
|
addMessageLabel,
|
|
1106
1124
|
removeMessageLabel,
|
|
1125
|
+
addOrEditQuickReply,
|
|
1126
|
+
removeQuickReply,
|
|
1107
1127
|
clearMessage
|
|
1108
1128
|
}
|
|
1109
1129
|
}
|
|
@@ -956,6 +956,36 @@ const makeMessagesSocket = (config) => {
|
|
|
956
956
|
.then((metadata) => WABinary_1.getBinaryNodeChild(metadata, 'ephemeral')?.attrs?.expiration || 0)
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
+
/**
|
|
960
|
+
* Update Member Label
|
|
961
|
+
*/
|
|
962
|
+
const updateMemberLabel = (jid, memberLabel) => {
|
|
963
|
+
return relayMessage(
|
|
964
|
+
jid,
|
|
965
|
+
{
|
|
966
|
+
protocolMessage: {
|
|
967
|
+
type: WAProto_1.proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE,
|
|
968
|
+
memberLabel: {
|
|
969
|
+
label: memberLabel?.slice(0, 30),
|
|
970
|
+
labelTimestamp: Utils_1.unixTimestampSeconds()
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
additionalNodes: [
|
|
976
|
+
{
|
|
977
|
+
tag: 'meta',
|
|
978
|
+
attrs: {
|
|
979
|
+
tag_reason: 'user_update',
|
|
980
|
+
appdata: 'member_tag'
|
|
981
|
+
},
|
|
982
|
+
content: undefined
|
|
983
|
+
}
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
)
|
|
987
|
+
}
|
|
988
|
+
|
|
959
989
|
const waUploadToServer = Utils_1.getWAUploadToServer(config, refreshMediaConn)
|
|
960
990
|
|
|
961
991
|
const waitForMsgMediaUpdate = Utils_1.bindWaitForEvent(ev, 'messages.media-update')
|
|
@@ -977,6 +1007,7 @@ const makeMessagesSocket = (config) => {
|
|
|
977
1007
|
createParticipantNodes,
|
|
978
1008
|
sendPeerDataOperationMessage,
|
|
979
1009
|
messageRetryManager,
|
|
1010
|
+
updateMemberLabel,
|
|
980
1011
|
updateMediaMessage: async (message) => {
|
|
981
1012
|
const content = Utils_1.assertMediaContent(message.message)
|
|
982
1013
|
const mediaKey = content.mediaKey
|
package/lib/Socket/socket.js
CHANGED
|
@@ -727,10 +727,17 @@ const makeSocket = (config) => {
|
|
|
727
727
|
if (!versionChecked) {
|
|
728
728
|
versionChecked = true
|
|
729
729
|
Utils_1.checkNpmVersion('@neelegirl/baileys', CURRENT_VERSION).then((versionInfo) => {
|
|
730
|
-
if (versionInfo
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
730
|
+
if (versionInfo) {
|
|
731
|
+
if (versionInfo.hasUpdate) {
|
|
732
|
+
const updateMessage = `\n╔════════════════════════════════════════╗\n║ 🔔 NEUE VERSION VERFÜGBAR! 🔔 ║\n╠════════════════════════════════════════╣\n║ Aktuelle Version: ${versionInfo.current.padEnd(20)} ║\n║ Neue Version: ${versionInfo.latest.padEnd(20)} ║\n║ ║\n║ Bitte aktualisiere @neelegirl/baileys ║\n║ npm install @neelegirl/baileys@latest ║\n╚════════════════════════════════════════╝\n`
|
|
733
|
+
if (printQRInTerminal) {
|
|
734
|
+
logger.info(updateMessage)
|
|
735
|
+
}
|
|
736
|
+
} else {
|
|
737
|
+
const currentVersionMessage = `\n╔════════════════════════════════════════╗\n║ ✅ Du nutzt gerade die aktuelle ║\n║ Version von @neelegirl/baileys ║\n║ ║\n║ Wir informieren dich, wenn es ein ║\n║ Update gibt. ║\n╚════════════════════════════════════════╝\n`
|
|
738
|
+
if (printQRInTerminal) {
|
|
739
|
+
logger.info(currentVersionMessage)
|
|
740
|
+
}
|
|
734
741
|
}
|
|
735
742
|
}
|
|
736
743
|
}).catch(() => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto'
|
|
2
|
+
|
|
3
|
+
export type DayOfWeekBussines = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
|
|
4
|
+
|
|
5
|
+
export type HoursDay =
|
|
6
|
+
| { day: DayOfWeekBussines; mode: 'specific_hours'; openTimeInMinutes: string; closeTimeInMinutes: string }
|
|
7
|
+
| { day: DayOfWeekBussines; mode: 'open_24h' | 'appointment_only' }
|
|
8
|
+
|
|
9
|
+
export type UpdateBussinesProfileProps = {
|
|
10
|
+
address?: string
|
|
11
|
+
websites?: string[]
|
|
12
|
+
email?: string
|
|
13
|
+
description?: string
|
|
14
|
+
hours?: {
|
|
15
|
+
timezone: string
|
|
16
|
+
days: HoursDay[]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type QuickReplyAction = proto.SyncActionValue.IQuickReplyAction & { timestamp?: string }
|
package/lib/Types/Chat.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { LabelActionBody } from './Label'
|
|
|
6
6
|
import type { ChatLabelAssociationActionBody } from './LabelAssociation'
|
|
7
7
|
import type { MessageLabelAssociationActionBody } from './LabelAssociation'
|
|
8
8
|
import type { MinimalMessage, WAMessageKey } from './Message'
|
|
9
|
+
import type { QuickReplyAction } from './Bussines'
|
|
9
10
|
|
|
10
11
|
/** privacy settings in WhatsApp Web */
|
|
11
12
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
@@ -122,6 +123,8 @@ export type ChatModification = {
|
|
|
122
123
|
addMessageLabel: MessageLabelAssociationActionBody
|
|
123
124
|
} | {
|
|
124
125
|
removeMessageLabel: MessageLabelAssociationActionBody
|
|
126
|
+
} | {
|
|
127
|
+
quickReply: QuickReplyAction
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
export type InitialReceivedChatsState = {
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -96,6 +96,14 @@ export type BaileysEventMap = {
|
|
|
96
96
|
action: RequestJoinAction
|
|
97
97
|
method: RequestJoinMethod
|
|
98
98
|
}
|
|
99
|
+
/* update the labels assigned to a group participant */
|
|
100
|
+
'group.member-tag.update': {
|
|
101
|
+
groupId: string
|
|
102
|
+
participant: string
|
|
103
|
+
participantAlt?: string
|
|
104
|
+
label: string
|
|
105
|
+
messageTimestamp?: number
|
|
106
|
+
}
|
|
99
107
|
'newsletter.reaction': {
|
|
100
108
|
id: string
|
|
101
109
|
newsletter_server_id: string
|
package/lib/Types/index.d.ts
CHANGED
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -514,6 +514,23 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
514
514
|
operation: OP.SET,
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
+
else if ('quickReply' in mod) {
|
|
518
|
+
patch = {
|
|
519
|
+
syncAction: {
|
|
520
|
+
quickReplyAction: {
|
|
521
|
+
count: 0,
|
|
522
|
+
deleted: mod.quickReply.deleted || false,
|
|
523
|
+
keywords: [],
|
|
524
|
+
message: mod.quickReply.message || '',
|
|
525
|
+
shortcut: mod.quickReply.shortcut || ''
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
index: ['quick_reply', mod.quickReply.timestamp || String(Math.floor(Date.now() / 1000))],
|
|
529
|
+
type: 'regular',
|
|
530
|
+
apiVersion: 2,
|
|
531
|
+
operation: OP.SET
|
|
532
|
+
}
|
|
533
|
+
}
|
|
517
534
|
else if ('addLabel' in mod) {
|
|
518
535
|
patch = {
|
|
519
536
|
syncAction: {
|
|
@@ -249,6 +249,18 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
249
249
|
update_time: protocolMsg.limitSharing.limitSharingSettingTimestamp
|
|
250
250
|
})
|
|
251
251
|
break
|
|
252
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE:
|
|
253
|
+
const labelAssociationMsg = protocolMsg.memberLabel
|
|
254
|
+
if (labelAssociationMsg?.label) {
|
|
255
|
+
ev.emit('group.member-tag.update', {
|
|
256
|
+
groupId: chat.id,
|
|
257
|
+
label: labelAssociationMsg.label,
|
|
258
|
+
participant: message.key.participant,
|
|
259
|
+
participantAlt: message.key.participantAlt,
|
|
260
|
+
messageTimestamp: Number(message.messageTimestamp)
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
break
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
else if (content?.reactionMessage) {
|