zalo-toolkit 1.0.0
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/dist/Errors/ZaloApiError.d.ts +4 -0
- package/dist/Errors/ZaloApiError.js +7 -0
- package/dist/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRAborted.js +7 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.js +7 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.js +7 -0
- package/dist/Errors/index.d.ts +4 -0
- package/dist/Errors/index.js +4 -0
- package/dist/apis/acceptFriendRequest.d.ts +2 -0
- package/dist/apis/acceptFriendRequest.js +28 -0
- package/dist/apis/addGroupBlockedMember.d.ts +2 -0
- package/dist/apis/addGroupBlockedMember.js +28 -0
- package/dist/apis/addGroupDeputy.d.ts +2 -0
- package/dist/apis/addGroupDeputy.js +31 -0
- package/dist/apis/addPollOptions.d.ts +14 -0
- package/dist/apis/addPollOptions.js +26 -0
- package/dist/apis/addQuickMessage.d.ts +11 -0
- package/dist/apis/addQuickMessage.js +60 -0
- package/dist/apis/addReaction.d.ts +19 -0
- package/dist/apis/addReaction.js +292 -0
- package/dist/apis/addUnreadMark.d.ts +8 -0
- package/dist/apis/addUnreadMark.js +52 -0
- package/dist/apis/addUserToGroup.d.ts +5 -0
- package/dist/apis/addUserToGroup.js +34 -0
- package/dist/apis/blockUser.d.ts +2 -0
- package/dist/apis/blockUser.js +28 -0
- package/dist/apis/blockViewFeed.d.ts +2 -0
- package/dist/apis/blockViewFeed.js +30 -0
- package/dist/apis/changeAccountAvatar.d.ts +2 -0
- package/dist/apis/changeAccountAvatar.js +51 -0
- package/dist/apis/changeFriendAlias.d.ts +2 -0
- package/dist/apis/changeFriendAlias.js +27 -0
- package/dist/apis/changeGroupAvatar.d.ts +2 -0
- package/dist/apis/changeGroupAvatar.js +42 -0
- package/dist/apis/changeGroupName.d.ts +4 -0
- package/dist/apis/changeGroupName.js +32 -0
- package/dist/apis/changeGroupOwner.d.ts +4 -0
- package/dist/apis/changeGroupOwner.js +31 -0
- package/dist/apis/createAutoReply.d.ts +14 -0
- package/dist/apis/createAutoReply.js +37 -0
- package/dist/apis/createCatalog.d.ts +7 -0
- package/dist/apis/createCatalog.js +29 -0
- package/dist/apis/createGroup.d.ts +22 -0
- package/dist/apis/createGroup.js +43 -0
- package/dist/apis/createNote.d.ts +7 -0
- package/dist/apis/createNote.js +47 -0
- package/dist/apis/createPoll.d.ts +55 -0
- package/dist/apis/createPoll.js +40 -0
- package/dist/apis/createProductCatalog.d.ts +23 -0
- package/dist/apis/createProductCatalog.js +50 -0
- package/dist/apis/createReminder.d.ts +12 -0
- package/dist/apis/createReminder.js +63 -0
- package/dist/apis/custom.d.ts +9 -0
- package/dist/apis/custom.js +15 -0
- package/dist/apis/deleteAutoReply.d.ts +5 -0
- package/dist/apis/deleteAutoReply.js +29 -0
- package/dist/apis/deleteAvatar.d.ts +9 -0
- package/dist/apis/deleteAvatar.js +27 -0
- package/dist/apis/deleteCatalog.d.ts +2 -0
- package/dist/apis/deleteCatalog.js +28 -0
- package/dist/apis/deleteChat.d.ts +19 -0
- package/dist/apis/deleteChat.js +50 -0
- package/dist/apis/deleteGroupInviteBox.d.ts +9 -0
- package/dist/apis/deleteGroupInviteBox.js +27 -0
- package/dist/apis/deleteMessage.d.ts +14 -0
- package/dist/apis/deleteMessage.js +52 -0
- package/dist/apis/deleteProductCatalog.d.ts +10 -0
- package/dist/apis/deleteProductCatalog.js +31 -0
- package/dist/apis/disableGroupLink.d.ts +2 -0
- package/dist/apis/disableGroupLink.js +24 -0
- package/dist/apis/disperseGroup.d.ts +2 -0
- package/dist/apis/disperseGroup.js +28 -0
- package/dist/apis/editNote.d.ts +17 -0
- package/dist/apis/editNote.js +46 -0
- package/dist/apis/editReminder.d.ts +13 -0
- package/dist/apis/editReminder.js +61 -0
- package/dist/apis/enableGroupLink.d.ts +6 -0
- package/dist/apis/enableGroupLink.js +25 -0
- package/dist/apis/fetchAccountInfo.d.ts +3 -0
- package/dist/apis/fetchAccountInfo.js +10 -0
- package/dist/apis/findUser.d.ts +15 -0
- package/dist/apis/findUser.js +40 -0
- package/dist/apis/forwardAttachment.d.ts +16 -0
- package/dist/apis/forwardAttachment.js +80 -0
- package/dist/apis/forwardMessage.d.ts +33 -0
- package/dist/apis/forwardMessage.js +119 -0
- package/dist/apis/getAliasList.d.ts +8 -0
- package/dist/apis/getAliasList.js +28 -0
- package/dist/apis/getAllFriends.d.ts +3 -0
- package/dist/apis/getAllFriends.js +32 -0
- package/dist/apis/getAllGroups.d.ts +7 -0
- package/dist/apis/getAllGroups.js +10 -0
- package/dist/apis/getArchivedChatList.d.ts +5 -0
- package/dist/apis/getArchivedChatList.js +23 -0
- package/dist/apis/getAutoDeleteChat.d.ts +9 -0
- package/dist/apis/getAutoDeleteChat.js +21 -0
- package/dist/apis/getAutoReplyList.d.ts +6 -0
- package/dist/apis/getAutoReplyList.js +24 -0
- package/dist/apis/getAvatarList.d.ts +12 -0
- package/dist/apis/getAvatarList.js +28 -0
- package/dist/apis/getBizAccount.d.ts +24 -0
- package/dist/apis/getBizAccount.js +27 -0
- package/dist/apis/getCatalogList.d.ts +18 -0
- package/dist/apis/getCatalogList.js +32 -0
- package/dist/apis/getContext.d.ts +1 -0
- package/dist/apis/getContext.js +4 -0
- package/dist/apis/getCookie.d.ts +1 -0
- package/dist/apis/getCookie.js +9 -0
- package/dist/apis/getFriendBoardList.d.ts +5 -0
- package/dist/apis/getFriendBoardList.js +26 -0
- package/dist/apis/getFriendOnlines.d.ts +10 -0
- package/dist/apis/getFriendOnlines.js +35 -0
- package/dist/apis/getFriendRecommendations.d.ts +42 -0
- package/dist/apis/getFriendRecommendations.js +27 -0
- package/dist/apis/getFriendRequestStatus.d.ts +8 -0
- package/dist/apis/getFriendRequestStatus.js +25 -0
- package/dist/apis/getGroupBlockedMember.d.ts +23 -0
- package/dist/apis/getGroupBlockedMember.js +29 -0
- package/dist/apis/getGroupInfo.d.ts +16 -0
- package/dist/apis/getGroupInfo.js +32 -0
- package/dist/apis/getGroupInviteBoxInfo.d.ts +32 -0
- package/dist/apis/getGroupInviteBoxInfo.js +38 -0
- package/dist/apis/getGroupInviteBoxList.d.ts +38 -0
- package/dist/apis/getGroupInviteBoxList.js +31 -0
- package/dist/apis/getGroupLinkDetail.d.ts +9 -0
- package/dist/apis/getGroupLinkDetail.js +25 -0
- package/dist/apis/getGroupLinkInfo.d.ts +34 -0
- package/dist/apis/getGroupLinkInfo.js +28 -0
- package/dist/apis/getGroupMembersInfo.d.ts +17 -0
- package/dist/apis/getGroupMembersInfo.js +24 -0
- package/dist/apis/getHiddenConversations.d.ts +11 -0
- package/dist/apis/getHiddenConversations.js +23 -0
- package/dist/apis/getLabels.d.ts +7 -0
- package/dist/apis/getLabels.js +28 -0
- package/dist/apis/getLastMessage.d.ts +9 -0
- package/dist/apis/getLastMessage.js +20 -0
- package/dist/apis/getListBoard.d.ts +21 -0
- package/dist/apis/getListBoard.js +45 -0
- package/dist/apis/getListReminder.d.ts +28 -0
- package/dist/apis/getListReminder.js +47 -0
- package/dist/apis/getMute.d.ts +13 -0
- package/dist/apis/getMute.js +22 -0
- package/dist/apis/getOwnId.d.ts +1 -0
- package/dist/apis/getOwnId.js +4 -0
- package/dist/apis/getPendingGroupMembers.d.ts +11 -0
- package/dist/apis/getPendingGroupMembers.js +27 -0
- package/dist/apis/getPinConversations.d.ts +5 -0
- package/dist/apis/getPinConversations.js +22 -0
- package/dist/apis/getPollDetail.d.ts +3 -0
- package/dist/apis/getPollDetail.js +30 -0
- package/dist/apis/getProductCatalogList.d.ts +20 -0
- package/dist/apis/getProductCatalogList.js +33 -0
- package/dist/apis/getQR.d.ts +4 -0
- package/dist/apis/getQR.js +29 -0
- package/dist/apis/getQuickMessageList.d.ts +7 -0
- package/dist/apis/getQuickMessageList.js +24 -0
- package/dist/apis/getRecommendFriends.d.ts +40 -0
- package/dist/apis/getRecommendFriends.js +20 -0
- package/dist/apis/getRelatedFriendGroup.d.ts +6 -0
- package/dist/apis/getRelatedFriendGroup.js +30 -0
- package/dist/apis/getReminder.d.ts +3 -0
- package/dist/apis/getReminder.js +25 -0
- package/dist/apis/getReminderResponses.d.ts +5 -0
- package/dist/apis/getReminderResponses.js +24 -0
- package/dist/apis/getSentFriendRequest.d.ts +18 -0
- package/dist/apis/getSentFriendRequest.js +24 -0
- package/dist/apis/getSettings.d.ts +3 -0
- package/dist/apis/getSettings.js +20 -0
- package/dist/apis/getStickers.d.ts +1 -0
- package/dist/apis/getStickers.js +40 -0
- package/dist/apis/getStickersDetail.d.ts +24 -0
- package/dist/apis/getStickersDetail.js +40 -0
- package/dist/apis/getUnreadMark.d.ts +14 -0
- package/dist/apis/getUnreadMark.js +30 -0
- package/dist/apis/getUserInfo.d.ts +8 -0
- package/dist/apis/getUserInfo.js +42 -0
- package/dist/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/apis/inviteUserToGroups.js +30 -0
- package/dist/apis/joinGroupInviteBox.d.ts +2 -0
- package/dist/apis/joinGroupInviteBox.js +25 -0
- package/dist/apis/joinGroupLink.d.ts +2 -0
- package/dist/apis/joinGroupLink.js +27 -0
- package/dist/apis/keepAlive.d.ts +4 -0
- package/dist/apis/keepAlive.js +22 -0
- package/dist/apis/lastOnline.d.ts +7 -0
- package/dist/apis/lastOnline.js +26 -0
- package/dist/apis/leaveGroup.d.ts +4 -0
- package/dist/apis/leaveGroup.js +33 -0
- package/dist/apis/listen.d.ts +141 -0
- package/dist/apis/listen.js +822 -0
- package/dist/apis/lockPoll.d.ts +2 -0
- package/dist/apis/lockPoll.js +28 -0
- package/dist/apis/login.d.ts +3 -0
- package/dist/apis/login.js +96 -0
- package/dist/apis/loginQR.d.ts +42 -0
- package/dist/apis/loginQR.js +274 -0
- package/dist/apis/parseLink.d.ts +21 -0
- package/dist/apis/parseLink.js +27 -0
- package/dist/apis/rejectFriendRequest.d.ts +2 -0
- package/dist/apis/rejectFriendRequest.js +27 -0
- package/dist/apis/removeFriend.d.ts +2 -0
- package/dist/apis/removeFriend.js +28 -0
- package/dist/apis/removeFriendAlias.d.ts +2 -0
- package/dist/apis/removeFriendAlias.js +24 -0
- package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
- package/dist/apis/removeGroupBlockedMember.js +28 -0
- package/dist/apis/removeGroupDeputy.d.ts +2 -0
- package/dist/apis/removeGroupDeputy.js +30 -0
- package/dist/apis/removeQuickMessage.d.ts +5 -0
- package/dist/apis/removeQuickMessage.js +27 -0
- package/dist/apis/removeReminder.d.ts +3 -0
- package/dist/apis/removeReminder.js +40 -0
- package/dist/apis/removeUnreadMark.d.ts +8 -0
- package/dist/apis/removeUnreadMark.js +50 -0
- package/dist/apis/removeUserFromGroup.d.ts +4 -0
- package/dist/apis/removeUserFromGroup.js +34 -0
- package/dist/apis/resetHiddenConversPin.d.ts +2 -0
- package/dist/apis/resetHiddenConversPin.js +20 -0
- package/dist/apis/reuseAvatar.d.ts +2 -0
- package/dist/apis/reuseAvatar.js +26 -0
- package/dist/apis/reviewPendingMemberRequest.d.ts +14 -0
- package/dist/apis/reviewPendingMemberRequest.js +38 -0
- package/dist/apis/sendBankCard.d.ts +9 -0
- package/dist/apis/sendBankCard.js +37 -0
- package/dist/apis/sendCard.d.ts +10 -0
- package/dist/apis/sendCard.js +59 -0
- package/dist/apis/sendDeliveredEvent.d.ts +16 -0
- package/dist/apis/sendDeliveredEvent.js +55 -0
- package/dist/apis/sendFriendRequest.d.ts +2 -0
- package/dist/apis/sendFriendRequest.js +39 -0
- package/dist/apis/sendLink.d.ts +10 -0
- package/dist/apis/sendLink.js +57 -0
- package/dist/apis/sendMessage.d.ts +100 -0
- package/dist/apis/sendMessage.js +437 -0
- package/dist/apis/sendReport.d.ts +17 -0
- package/dist/apis/sendReport.js +53 -0
- package/dist/apis/sendSeenEvent.d.ts +16 -0
- package/dist/apis/sendSeenEvent.js +63 -0
- package/dist/apis/sendSticker.d.ts +10 -0
- package/dist/apis/sendSticker.js +56 -0
- package/dist/apis/sendTypingEvent.d.ts +5 -0
- package/dist/apis/sendTypingEvent.js +33 -0
- package/dist/apis/sendVideo.d.ts +35 -0
- package/dist/apis/sendVideo.js +118 -0
- package/dist/apis/sendVoice.d.ts +12 -0
- package/dist/apis/sendVoice.js +73 -0
- package/dist/apis/setArchivedConversations.d.ts +10 -0
- package/dist/apis/setArchivedConversations.js +34 -0
- package/dist/apis/setHiddenConversations.d.ts +3 -0
- package/dist/apis/setHiddenConversations.js +39 -0
- package/dist/apis/setMute.d.ts +20 -0
- package/dist/apis/setMute.js +67 -0
- package/dist/apis/setPinnedConversations.d.ts +3 -0
- package/dist/apis/setPinnedConversations.js +34 -0
- package/dist/apis/sharePoll.d.ts +2 -0
- package/dist/apis/sharePoll.js +28 -0
- package/dist/apis/unblockUser.d.ts +2 -0
- package/dist/apis/unblockUser.js +28 -0
- package/dist/apis/undo.d.ts +9 -0
- package/dist/apis/undo.js +42 -0
- package/dist/apis/undoFriendRequest.d.ts +2 -0
- package/dist/apis/undoFriendRequest.js +27 -0
- package/dist/apis/updateActiveStatus.d.ts +4 -0
- package/dist/apis/updateActiveStatus.js +27 -0
- package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
- package/dist/apis/updateAutoDeleteChat.js +40 -0
- package/dist/apis/updateAutoReply.d.ts +15 -0
- package/dist/apis/updateAutoReply.js +38 -0
- package/dist/apis/updateCatalog.d.ts +11 -0
- package/dist/apis/updateCatalog.js +30 -0
- package/dist/apis/updateGroupSettings.d.ts +40 -0
- package/dist/apis/updateGroupSettings.js +43 -0
- package/dist/apis/updateHiddenConversPin.d.ts +2 -0
- package/dist/apis/updateHiddenConversPin.js +30 -0
- package/dist/apis/updateLabels.d.ts +15 -0
- package/dist/apis/updateLabels.js +34 -0
- package/dist/apis/updateLang.d.ts +6 -0
- package/dist/apis/updateLang.js +30 -0
- package/dist/apis/updateProductCatalog.d.ts +25 -0
- package/dist/apis/updateProductCatalog.js +51 -0
- package/dist/apis/updateProfile.d.ts +20 -0
- package/dist/apis/updateProfile.js +43 -0
- package/dist/apis/updateQuickMessage.d.ts +11 -0
- package/dist/apis/updateQuickMessage.js +61 -0
- package/dist/apis/updateSettings.d.ts +16 -0
- package/dist/apis/updateSettings.js +90 -0
- package/dist/apis/uploadAttachment.d.ts +51 -0
- package/dist/apis/uploadAttachment.js +195 -0
- package/dist/apis/uploadProductPhoto.d.ts +13 -0
- package/dist/apis/uploadProductPhoto.js +45 -0
- package/dist/apis/votePoll.d.ts +5 -0
- package/dist/apis/votePoll.js +29 -0
- package/dist/apis.d.ts +293 -0
- package/dist/apis.js +287 -0
- package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
- package/dist/cjs/Errors/ZaloApiLoginQRAborted.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiLoginQRDeclined.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiMissingImageMetadataGetter.cjs +12 -0
- package/dist/cjs/apis/login.cjs +102 -0
- package/dist/cjs/apis/loginQR.cjs +282 -0
- package/dist/cjs/apis/reviewPendingMemberRequest.cjs +21 -0
- package/dist/cjs/apis/sendMessage.cjs +44 -0
- package/dist/cjs/apis/sendReport.cjs +28 -0
- package/dist/cjs/apis/setMute.cjs +33 -0
- package/dist/cjs/apis/updateAutoDeleteChat.cjs +28 -0
- package/dist/cjs/apis/updateLang.cjs +19 -0
- package/dist/cjs/apis/updateSettings.cjs +29 -0
- package/dist/cjs/context.cjs +19 -0
- package/dist/cjs/index.cjs +142 -0
- package/dist/cjs/models/AutoReply.cjs +9 -0
- package/dist/cjs/models/Board.cjs +8 -0
- package/dist/cjs/models/DeliveredMessage.cjs +23 -0
- package/dist/cjs/models/Enum.cjs +253 -0
- package/dist/cjs/models/FriendEvent.cjs +87 -0
- package/dist/cjs/models/Group.cjs +13 -0
- package/dist/cjs/models/GroupEvent.cjs +94 -0
- package/dist/cjs/models/Listen.cjs +134 -0
- package/dist/cjs/models/Message.cjs +40 -0
- package/dist/cjs/models/Reaction.cjs +74 -0
- package/dist/cjs/models/Reminder.cjs +9 -0
- package/dist/cjs/models/SeenMessage.cjs +23 -0
- package/dist/cjs/models/Typing.cjs +23 -0
- package/dist/cjs/models/Undo.cjs +16 -0
- package/dist/cjs/models/ZBusiness.cjs +39 -0
- package/dist/cjs/utils.cjs +320 -0
- package/dist/cjs/zalo.cjs +127 -0
- package/dist/context.d.ts +199 -0
- package/dist/context.js +27 -0
- package/dist/core/enums/common.d.ts +11 -0
- package/dist/core/enums/common.js +12 -0
- package/dist/core/interfaces/common.d.ts +7 -0
- package/dist/core/interfaces/common.js +1 -0
- package/dist/core/utils/deserializer.d.ts +4 -0
- package/dist/core/utils/deserializer.js +25 -0
- package/dist/core/utils/index.d.ts +2 -0
- package/dist/core/utils/index.js +28 -0
- package/dist/core/utils/serializer.d.ts +9 -0
- package/dist/core/utils/serializer.js +24 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +12 -0
- package/dist/models/AutoReply.d.ts +20 -0
- package/dist/models/AutoReply.js +7 -0
- package/dist/models/Board.d.ts +60 -0
- package/dist/models/Board.js +6 -0
- package/dist/models/Catalog.d.ts +16 -0
- package/dist/models/Catalog.js +1 -0
- package/dist/models/DeliveredMessage.d.ts +27 -0
- package/dist/models/DeliveredMessage.js +17 -0
- package/dist/models/Enum.d.ts +247 -0
- package/dist/models/Enum.js +251 -0
- package/dist/models/FriendEvent.d.ts +107 -0
- package/dist/models/FriendEvent.js +83 -0
- package/dist/models/Group.d.ts +125 -0
- package/dist/models/Group.js +11 -0
- package/dist/models/GroupEvent.d.ts +178 -0
- package/dist/models/GroupEvent.js +90 -0
- package/dist/models/Label.d.ts +10 -0
- package/dist/models/Label.js +1 -0
- package/dist/models/Listen.d.ts +186 -0
- package/dist/models/Listen.js +194 -0
- package/dist/models/Message.d.ts +97 -0
- package/dist/models/Message.js +34 -0
- package/dist/models/Mute.d.ts +10 -0
- package/dist/models/Mute.js +1 -0
- package/dist/models/ProductCatalog.d.ts +17 -0
- package/dist/models/ProductCatalog.js +1 -0
- package/dist/models/QuickMessage.d.ts +25 -0
- package/dist/models/QuickMessage.js +1 -0
- package/dist/models/Reaction.d.ts +85 -0
- package/dist/models/Reaction.js +70 -0
- package/dist/models/Reminder.d.ts +51 -0
- package/dist/models/Reminder.js +7 -0
- package/dist/models/SeenMessage.d.ts +26 -0
- package/dist/models/SeenMessage.js +17 -0
- package/dist/models/Typing.d.ts +24 -0
- package/dist/models/Typing.js +17 -0
- package/dist/models/Undo.d.ts +34 -0
- package/dist/models/Undo.js +12 -0
- package/dist/models/User.d.ts +49 -0
- package/dist/models/User.js +1 -0
- package/dist/models/ZBusiness.d.ts +22 -0
- package/dist/models/ZBusiness.js +35 -0
- package/dist/models/index.d.ts +19 -0
- package/dist/models/index.js +19 -0
- package/dist/socket/config-socket.d.ts +38 -0
- package/dist/socket/config-socket.js +202 -0
- package/dist/utils.d.ts +190 -0
- package/dist/utils.js +749 -0
- package/dist/zalo.d.ts +64 -0
- package/dist/zalo.js +103 -0
- package/package.json +61 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SendStickerPayload = {
|
|
3
|
+
id: number;
|
|
4
|
+
cateId: number;
|
|
5
|
+
type: number;
|
|
6
|
+
};
|
|
7
|
+
export type SendStickerResponse = {
|
|
8
|
+
msgId: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const sendStickerFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (sticker: SendStickerPayload, threadId: string, type?: ThreadType) => Promise<SendStickerResponse>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory, removeUndefinedKeys } from '../utils.js';
|
|
4
|
+
export const sendStickerFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = {
|
|
6
|
+
[ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/sticker`, {
|
|
7
|
+
nretry: '0',
|
|
8
|
+
}),
|
|
9
|
+
[ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sticker`, {
|
|
10
|
+
nretry: '0',
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Send a sticker to a thread
|
|
15
|
+
*
|
|
16
|
+
* @param sticker Sticker object
|
|
17
|
+
* @param threadId group or user id
|
|
18
|
+
* @param type Message type (User or GroupMessage)
|
|
19
|
+
*
|
|
20
|
+
* @throws {ZaloApiError}
|
|
21
|
+
*/
|
|
22
|
+
return async function sendSticker(sticker, threadId, type = ThreadType.User) {
|
|
23
|
+
if (!sticker)
|
|
24
|
+
throw new ZaloApiError('Missing sticker');
|
|
25
|
+
if (!threadId)
|
|
26
|
+
throw new ZaloApiError('Missing threadId');
|
|
27
|
+
if (!sticker.id)
|
|
28
|
+
throw new ZaloApiError('Missing sticker id');
|
|
29
|
+
if (!sticker.cateId)
|
|
30
|
+
throw new ZaloApiError('Missing sticker cateId');
|
|
31
|
+
if (!sticker.type)
|
|
32
|
+
throw new ZaloApiError('Missing sticker type');
|
|
33
|
+
const isGroupMessage = type === ThreadType.Group;
|
|
34
|
+
const params = {
|
|
35
|
+
stickerId: sticker.id,
|
|
36
|
+
cateId: sticker.cateId,
|
|
37
|
+
type: sticker.type,
|
|
38
|
+
clientId: Date.now(),
|
|
39
|
+
imei: ctx.imei,
|
|
40
|
+
zsource: 101,
|
|
41
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
42
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
43
|
+
};
|
|
44
|
+
removeUndefinedKeys(params);
|
|
45
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
46
|
+
if (!encryptedParams)
|
|
47
|
+
throw new ZaloApiError('Failed to encrypt message');
|
|
48
|
+
const response = await utils.request(serviceURL[type], {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
body: new URLSearchParams({
|
|
51
|
+
params: encryptedParams,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
return utils.resolve(response);
|
|
55
|
+
};
|
|
56
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DestType, ThreadType } from '../models/index.js';
|
|
2
|
+
export type SendTypingEventResponse = {
|
|
3
|
+
status: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const sendTypingEventFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (threadId: string, type?: ThreadType, destType?: DestType) => Promise<SendTypingEventResponse>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { DestType, ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const sendTypingEventFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = {
|
|
6
|
+
[ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/typing`),
|
|
7
|
+
[ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/typing`),
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Send typing event
|
|
11
|
+
*
|
|
12
|
+
* @param threadId The ID of the User or Group to send the typing event to
|
|
13
|
+
* @param type The type of thread (User or Group)
|
|
14
|
+
* @param destType The destination type (User or Page), for User threads only, defaults to User
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function sendTypingEvent(threadId, type = ThreadType.User, destType = DestType.User) {
|
|
19
|
+
if (!threadId)
|
|
20
|
+
throw new ZaloApiError('Missing threadId');
|
|
21
|
+
const params = Object.assign(Object.assign({ [type === ThreadType.User ? 'toid' : 'grid']: threadId }, (type === ThreadType.User ? { destType } : {})), { imei: ctx.imei });
|
|
22
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
23
|
+
if (!encryptedParams)
|
|
24
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
25
|
+
const response = await utils.request(serviceURL[type], {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: new URLSearchParams({
|
|
28
|
+
params: encryptedParams,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
return utils.resolve(response);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SendVideoOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Optional message to send along with the video
|
|
5
|
+
*/
|
|
6
|
+
msg?: string;
|
|
7
|
+
/**
|
|
8
|
+
* URL of the video
|
|
9
|
+
*/
|
|
10
|
+
videoUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* URL of the thumbnail
|
|
13
|
+
*/
|
|
14
|
+
thumbnailUrl: string;
|
|
15
|
+
/**
|
|
16
|
+
* Video duration in milliseconds || Eg: video duration: 5.5s => 5.5 * 1000 = 5500
|
|
17
|
+
*/
|
|
18
|
+
duration?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Width of the video
|
|
21
|
+
*/
|
|
22
|
+
width?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Height of the video
|
|
25
|
+
*/
|
|
26
|
+
height?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Time to live in milliseconds (default: 0)
|
|
29
|
+
*/
|
|
30
|
+
ttl?: number;
|
|
31
|
+
};
|
|
32
|
+
export type SendVideoResponse = {
|
|
33
|
+
msgId: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const sendVideoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (options: SendVideoOptions, threadId: string, type?: ThreadType) => Promise<SendVideoResponse>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const sendVideoFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = {
|
|
6
|
+
[ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
|
|
7
|
+
[ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Send a video to a User - Group
|
|
11
|
+
*
|
|
12
|
+
* @param options send video options
|
|
13
|
+
* @param threadId ID of the user or group to send the video to
|
|
14
|
+
* @param type Type of thread (USER or GROUP)
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*
|
|
18
|
+
* @examples Example Video Resolutions:
|
|
19
|
+
* - **Standard Videos**:
|
|
20
|
+
* - 3840x2160 (4K UHD): Width 3840px, Height 2160px.
|
|
21
|
+
* - 1920x1080 (Full HD): Width 1920px, Height 1080px.
|
|
22
|
+
* - 1280x720 (HD): Width 1280px, Height 720px.
|
|
23
|
+
* - **Document-Oriented Videos** (Portrait):
|
|
24
|
+
* - 3840x2160 (4K UHD): Width 3840px, Height 2160px.
|
|
25
|
+
* - 720x1280 (HD): Width 720px, Height 1280px.
|
|
26
|
+
* - 1440x2560 (2K): Width 1440px, Height 2560px.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
return async function sendVideo(options, threadId, type = ThreadType.User) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
31
|
+
let fileSize = 0;
|
|
32
|
+
const clientId = Date.now();
|
|
33
|
+
try {
|
|
34
|
+
const headResponse = await utils.request(options.videoUrl, { method: 'HEAD' }, true);
|
|
35
|
+
if (headResponse.ok) {
|
|
36
|
+
fileSize = parseInt(headResponse.headers.get('content-length') || '0');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new ZaloApiError(`Unable to get video content: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
+
}
|
|
42
|
+
const params = type === ThreadType.User
|
|
43
|
+
? {
|
|
44
|
+
toId: threadId,
|
|
45
|
+
clientId: String(clientId),
|
|
46
|
+
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 0,
|
|
47
|
+
zsource: 704,
|
|
48
|
+
msgType: 5,
|
|
49
|
+
msgInfo: JSON.stringify({
|
|
50
|
+
videoUrl: options.videoUrl,
|
|
51
|
+
thumbUrl: options.thumbnailUrl,
|
|
52
|
+
duration: (_b = options.duration) !== null && _b !== void 0 ? _b : 0,
|
|
53
|
+
width: (_c = options.width) !== null && _c !== void 0 ? _c : 1280,
|
|
54
|
+
height: (_d = options.height) !== null && _d !== void 0 ? _d : 720,
|
|
55
|
+
fileSize: fileSize,
|
|
56
|
+
properties: {
|
|
57
|
+
color: -1,
|
|
58
|
+
size: -1,
|
|
59
|
+
type: 1003,
|
|
60
|
+
subType: 0,
|
|
61
|
+
ext: {
|
|
62
|
+
sSrcType: -1,
|
|
63
|
+
sSrcStr: '',
|
|
64
|
+
msg_warning_type: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
title: (_e = options.msg) !== null && _e !== void 0 ? _e : '',
|
|
68
|
+
}),
|
|
69
|
+
imei: ctx.imei,
|
|
70
|
+
}
|
|
71
|
+
: {
|
|
72
|
+
grid: threadId,
|
|
73
|
+
visibility: 0,
|
|
74
|
+
clientId: String(clientId),
|
|
75
|
+
ttl: (_f = options.ttl) !== null && _f !== void 0 ? _f : 0,
|
|
76
|
+
zsource: 704,
|
|
77
|
+
msgType: 5,
|
|
78
|
+
msgInfo: JSON.stringify({
|
|
79
|
+
videoUrl: options.videoUrl,
|
|
80
|
+
thumbUrl: options.thumbnailUrl,
|
|
81
|
+
duration: (_g = options.duration) !== null && _g !== void 0 ? _g : 0,
|
|
82
|
+
width: (_h = options.width) !== null && _h !== void 0 ? _h : 1280,
|
|
83
|
+
height: (_j = options.height) !== null && _j !== void 0 ? _j : 720,
|
|
84
|
+
fileSize: fileSize,
|
|
85
|
+
properties: {
|
|
86
|
+
color: -1,
|
|
87
|
+
size: -1,
|
|
88
|
+
type: 1003,
|
|
89
|
+
subType: 0,
|
|
90
|
+
ext: {
|
|
91
|
+
sSrcType: -1,
|
|
92
|
+
sSrcStr: '',
|
|
93
|
+
msg_warning_type: 0,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
title: (_k = options.msg) !== null && _k !== void 0 ? _k : '',
|
|
97
|
+
}),
|
|
98
|
+
imei: ctx.imei,
|
|
99
|
+
};
|
|
100
|
+
// @TODO: later
|
|
101
|
+
// if (typeof message !== "string" && message.mention) {
|
|
102
|
+
// params.mentionInfo = message.mention;
|
|
103
|
+
// }
|
|
104
|
+
if (type !== ThreadType.User && type !== ThreadType.Group) {
|
|
105
|
+
throw new ZaloApiError('Thread type is invalid');
|
|
106
|
+
}
|
|
107
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
108
|
+
if (!encryptedParams)
|
|
109
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
110
|
+
const response = await utils.request(serviceURL[type], {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
body: new URLSearchParams({
|
|
113
|
+
params: encryptedParams,
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
return utils.resolve(response);
|
|
117
|
+
};
|
|
118
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SendVoiceOptions = {
|
|
3
|
+
voiceUrl: string;
|
|
4
|
+
/**
|
|
5
|
+
* Time to live in milliseconds (default: 0)
|
|
6
|
+
*/
|
|
7
|
+
ttl?: number;
|
|
8
|
+
};
|
|
9
|
+
export type SendVoiceResponse = {
|
|
10
|
+
msgId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const sendVoiceFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (options: SendVoiceOptions, threadId: string, type?: ThreadType) => Promise<SendVoiceResponse>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const sendVoiceFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = {
|
|
6
|
+
[ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
|
|
7
|
+
[ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Send a voice to a User - Group
|
|
11
|
+
*
|
|
12
|
+
* @param options voice options
|
|
13
|
+
* @param threadId ID of the user or group to send the voice to
|
|
14
|
+
* @param type Type of thread, default user
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function sendVoice(options, threadId, type = ThreadType.User) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
let fileSize = null;
|
|
21
|
+
const clientId = Date.now().toString();
|
|
22
|
+
try {
|
|
23
|
+
const headResponse = await utils.request(options.voiceUrl, { method: 'HEAD' }, true);
|
|
24
|
+
if (headResponse.ok) {
|
|
25
|
+
fileSize = parseInt(headResponse.headers.get('content-length') || '0');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new ZaloApiError(`Unable to get voice content: ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
const params = type === ThreadType.User
|
|
32
|
+
? {
|
|
33
|
+
toId: threadId,
|
|
34
|
+
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 0,
|
|
35
|
+
zsource: -1,
|
|
36
|
+
msgType: 3,
|
|
37
|
+
clientId: clientId,
|
|
38
|
+
msgInfo: JSON.stringify({
|
|
39
|
+
voiceUrl: options.voiceUrl,
|
|
40
|
+
m4aUrl: options.voiceUrl,
|
|
41
|
+
fileSize: fileSize !== null && fileSize !== void 0 ? fileSize : 0,
|
|
42
|
+
}),
|
|
43
|
+
imei: ctx.imei,
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
grid: threadId,
|
|
47
|
+
visibility: 0,
|
|
48
|
+
ttl: (_b = options.ttl) !== null && _b !== void 0 ? _b : 0,
|
|
49
|
+
zsource: -1,
|
|
50
|
+
msgType: 3,
|
|
51
|
+
clientId: clientId,
|
|
52
|
+
msgInfo: JSON.stringify({
|
|
53
|
+
voiceUrl: options.voiceUrl,
|
|
54
|
+
m4aUrl: options.voiceUrl,
|
|
55
|
+
fileSize: fileSize !== null && fileSize !== void 0 ? fileSize : 0,
|
|
56
|
+
}),
|
|
57
|
+
imei: ctx.imei,
|
|
58
|
+
};
|
|
59
|
+
if (type !== ThreadType.User && type !== ThreadType.Group) {
|
|
60
|
+
throw new ZaloApiError('Thread type is invalid');
|
|
61
|
+
}
|
|
62
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
63
|
+
if (!encryptedParams)
|
|
64
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
65
|
+
const response = await utils.request(serviceURL[type], {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: new URLSearchParams({
|
|
68
|
+
params: encryptedParams,
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
return utils.resolve(response);
|
|
72
|
+
};
|
|
73
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ThreadType } from '../models/Enum.js';
|
|
2
|
+
export type SetArchivedConversationsTarget = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: ThreadType;
|
|
5
|
+
};
|
|
6
|
+
export type SetArchivedConversationsResponse = {
|
|
7
|
+
needResync: boolean;
|
|
8
|
+
version: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const setArchivedConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (isArchived: boolean, conversations: SetArchivedConversationsTarget | SetArchivedConversationsTarget[]) => Promise<SetArchivedConversationsResponse>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const setArchivedConversationsFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.label[0]}/api/archivedchat/update`);
|
|
5
|
+
/**
|
|
6
|
+
* Archive conversations
|
|
7
|
+
*
|
|
8
|
+
* @param isArchived - true to archive, false to unarchive
|
|
9
|
+
* @param conversations - List of conversations to archive/unarchive
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function setArchivedConversations(isArchived, conversations) {
|
|
14
|
+
if (!Array.isArray(conversations)) {
|
|
15
|
+
conversations = [conversations];
|
|
16
|
+
}
|
|
17
|
+
const params = {
|
|
18
|
+
actionType: isArchived ? 0 : 1,
|
|
19
|
+
ids: conversations,
|
|
20
|
+
imei: ctx.imei,
|
|
21
|
+
version: Date.now(),
|
|
22
|
+
};
|
|
23
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
24
|
+
if (!encryptedParams)
|
|
25
|
+
throw new ZaloApiError('Failed to encrypt message');
|
|
26
|
+
const response = await utils.request(serviceURL, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: new URLSearchParams({
|
|
29
|
+
params: encryptedParams,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
return utils.resolve(response);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SetHiddenConversationsResponse = '';
|
|
3
|
+
export declare const setHiddenConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (hidden: boolean, threadId: string | string[], type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const setHiddenConversationsFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/hiddenconvers/add-remove`);
|
|
6
|
+
/**
|
|
7
|
+
* Set hidden conversations
|
|
8
|
+
*
|
|
9
|
+
* @param hidden - Hide or unhide conversations
|
|
10
|
+
* @param threadId Thread ID(s)
|
|
11
|
+
* @param type Thread type (User/Group)
|
|
12
|
+
*
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function setHiddenConversations(hidden, threadId, type = ThreadType.User) {
|
|
16
|
+
threadId = Array.isArray(threadId) ? threadId : [threadId];
|
|
17
|
+
if (threadId.length === 0)
|
|
18
|
+
throw new ZaloApiError('threadId is required');
|
|
19
|
+
const is_group = type === ThreadType.Group ? 1 : 0;
|
|
20
|
+
const params = {
|
|
21
|
+
[hidden ? 'add_threads' : 'del_threads']: JSON.stringify(threadId.map((id) => ({
|
|
22
|
+
thread_id: id,
|
|
23
|
+
is_group: is_group,
|
|
24
|
+
}))),
|
|
25
|
+
[hidden ? 'del_threads' : 'add_threads']: '[]',
|
|
26
|
+
imei: ctx.imei,
|
|
27
|
+
};
|
|
28
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
29
|
+
if (!encryptedParams)
|
|
30
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
31
|
+
const response = await utils.request(serviceURL, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body: new URLSearchParams({
|
|
34
|
+
params: encryptedParams,
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
return utils.resolve(response);
|
|
38
|
+
};
|
|
39
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SetMuteParams = {
|
|
3
|
+
/**
|
|
4
|
+
* Mute duration in seconds or predefined durations
|
|
5
|
+
*/
|
|
6
|
+
duration?: MuteDuration | number;
|
|
7
|
+
action?: MuteAction;
|
|
8
|
+
};
|
|
9
|
+
export type SetMuteResponse = '';
|
|
10
|
+
export declare enum MuteDuration {
|
|
11
|
+
ONE_HOUR = 3600,
|
|
12
|
+
FOUR_HOURS = 14400,
|
|
13
|
+
FOREVER = -1,
|
|
14
|
+
UNTIL_8AM = "until8AM"
|
|
15
|
+
}
|
|
16
|
+
export declare enum MuteAction {
|
|
17
|
+
MUTE = 1,
|
|
18
|
+
UNMUTE = 3
|
|
19
|
+
}
|
|
20
|
+
export declare const setMuteFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (params: SetMuteParams | undefined, threadID: string, type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export var MuteDuration;
|
|
5
|
+
(function (MuteDuration) {
|
|
6
|
+
MuteDuration[MuteDuration["ONE_HOUR"] = 3600] = "ONE_HOUR";
|
|
7
|
+
MuteDuration[MuteDuration["FOUR_HOURS"] = 14400] = "FOUR_HOURS";
|
|
8
|
+
MuteDuration[MuteDuration["FOREVER"] = -1] = "FOREVER";
|
|
9
|
+
MuteDuration["UNTIL_8AM"] = "until8AM";
|
|
10
|
+
})(MuteDuration || (MuteDuration = {}));
|
|
11
|
+
export var MuteAction;
|
|
12
|
+
(function (MuteAction) {
|
|
13
|
+
MuteAction[MuteAction["MUTE"] = 1] = "MUTE";
|
|
14
|
+
MuteAction[MuteAction["UNMUTE"] = 3] = "UNMUTE";
|
|
15
|
+
})(MuteAction || (MuteAction = {}));
|
|
16
|
+
export const setMuteFactory = apiFactory()((api, ctx, utils) => {
|
|
17
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/setmute`);
|
|
18
|
+
/**
|
|
19
|
+
* Set mute
|
|
20
|
+
*
|
|
21
|
+
* @param params - Mute parameters
|
|
22
|
+
* @param threadID - ID of the thread to mute
|
|
23
|
+
* @param type - Type of thread (User or Group)
|
|
24
|
+
*
|
|
25
|
+
* @throws {ZaloApiError}
|
|
26
|
+
*/
|
|
27
|
+
return async function setMute(params = {}, threadID, type = ThreadType.User) {
|
|
28
|
+
const { duration = MuteDuration.FOREVER, action = MuteAction.MUTE } = params;
|
|
29
|
+
let muteDuration;
|
|
30
|
+
if (action === MuteAction.UNMUTE) {
|
|
31
|
+
muteDuration = -1;
|
|
32
|
+
}
|
|
33
|
+
else if (duration === MuteDuration.FOREVER) {
|
|
34
|
+
muteDuration = -1;
|
|
35
|
+
}
|
|
36
|
+
else if (duration === MuteDuration.UNTIL_8AM) {
|
|
37
|
+
const now = new Date();
|
|
38
|
+
const next8AM = new Date(now);
|
|
39
|
+
next8AM.setHours(8, 0, 0, 0);
|
|
40
|
+
if (now.getHours() >= 8) {
|
|
41
|
+
next8AM.setDate(next8AM.getDate() + 1);
|
|
42
|
+
}
|
|
43
|
+
muteDuration = Math.floor((next8AM.getTime() - now.getTime()) / 1000);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
muteDuration = duration;
|
|
47
|
+
}
|
|
48
|
+
const requestParams = {
|
|
49
|
+
toid: threadID,
|
|
50
|
+
duration: muteDuration,
|
|
51
|
+
action: action,
|
|
52
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
53
|
+
muteType: type === ThreadType.User ? 1 : 2,
|
|
54
|
+
imei: ctx.imei,
|
|
55
|
+
};
|
|
56
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(requestParams));
|
|
57
|
+
if (!encryptedParams)
|
|
58
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
59
|
+
const response = await utils.request(serviceURL, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
body: new URLSearchParams({
|
|
62
|
+
params: encryptedParams,
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
return utils.resolve(response);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type SetPinnedConversationsResponse = '';
|
|
3
|
+
export declare const setPinnedConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (pinned: boolean, threadId: string | string[], type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const setPinnedConversationsFactory = apiFactory()((api, _, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/pinconvers/updatev2`);
|
|
6
|
+
/**
|
|
7
|
+
* Pin and unpin conversations of threads)
|
|
8
|
+
*
|
|
9
|
+
* @param pinned Should pin conversations
|
|
10
|
+
* @param threadId The ID(s) of the thread
|
|
11
|
+
* @param type Type of thread, default User
|
|
12
|
+
*
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
return async function setPinnedConversations(pinned, threadId, type = ThreadType.User) {
|
|
17
|
+
if (typeof threadId == 'string')
|
|
18
|
+
threadId = [threadId];
|
|
19
|
+
const params = {
|
|
20
|
+
actionType: pinned ? 1 : 2,
|
|
21
|
+
conversations: type == ThreadType.Group ? threadId.map((id) => `g${id}`) : threadId.map((id) => `u${id}`),
|
|
22
|
+
};
|
|
23
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
24
|
+
if (!encryptedParams)
|
|
25
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
26
|
+
const response = await utils.request(serviceURL, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: new URLSearchParams({
|
|
29
|
+
params: encryptedParams,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
return utils.resolve(response);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const sharePollFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/poll/share`);
|
|
5
|
+
/**
|
|
6
|
+
* Share a poll
|
|
7
|
+
*
|
|
8
|
+
* @param pollId poll id to share
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function sharePoll(pollId) {
|
|
13
|
+
const params = {
|
|
14
|
+
poll_id: pollId,
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
20
|
+
const response = await utils.request(serviceURL, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
body: new URLSearchParams({
|
|
23
|
+
params: encryptedParams,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const unblockUserFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/unblock`);
|
|
5
|
+
/**
|
|
6
|
+
* Unblock a User
|
|
7
|
+
*
|
|
8
|
+
* @param userId The ID of the User to unblock
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function unblockUser(userId) {
|
|
13
|
+
const params = {
|
|
14
|
+
fid: userId,
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
20
|
+
const response = await utils.request(serviceURL, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
body: new URLSearchParams({
|
|
23
|
+
params: encryptedParams,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ThreadType } from '../models/index.js';
|
|
2
|
+
export type UndoPayload = {
|
|
3
|
+
msgId: string | number;
|
|
4
|
+
cliMsgId: string | number;
|
|
5
|
+
};
|
|
6
|
+
export type UndoResponse = {
|
|
7
|
+
status: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const undoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (payload: UndoPayload, threadId: string, type?: ThreadType) => Promise<UndoResponse>;
|