Skip to content

Commit

Permalink
feat: Added WPP.status.sendImageStatus function
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jun 27, 2022
1 parent 55cd0a4 commit 2814ef3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/status/functions/index.ts
Expand Up @@ -16,5 +16,6 @@

export { get } from './get';
export { getMyStatus } from './getMyStatus';
export { ImageStatusOptions, sendImageStatus } from './sendImageStatus';
export { sendRawStatus, SendStatusOptions } from './sendRawStatus';
export { sendTextStatus, TextStatusOptions } from './sendTextStatus';
45 changes: 45 additions & 0 deletions src/status/functions/sendImageStatus.ts
@@ -0,0 +1,45 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { sendFileMessage } from '../../chat';
import { defaultSendStatusOptions } from '..';
import { SendStatusOptions } from './sendRawStatus';

export type ImageStatusOptions = SendStatusOptions;

/**
* Send a image message to status stories
*
* @example
* ```javascript
* WPP.status.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
* ```
*/
export async function sendImageStatus(
content: any,
options: ImageStatusOptions = {}
): Promise<any> {
options = {
...defaultSendStatusOptions,
...options,
};

return sendFileMessage('status@broadcast', content, {
...options,
createChat: true,
type: 'image',
});
}
11 changes: 3 additions & 8 deletions src/whatsapp/models/StatusV3Model.ts
Expand Up @@ -17,13 +17,8 @@
import { StatusV3Collection } from '../collections';
import { exportProxyModel } from '../exportModule';
import { Wid } from '../misc';
import {
Model,
ModelOptions,
ModelPropertiesContructor,
ModelProxy,
} from './Model';
import { PropsChatBase, SessionChatBase } from './ModelChatBase';
import { ModelOptions, ModelPropertiesContructor, ModelProxy } from './Model';
import { ModelChatBase, PropsChatBase, SessionChatBase } from './ModelChatBase';

interface Props extends PropsChatBase {
t?: any;
Expand Down Expand Up @@ -55,7 +50,7 @@ export declare interface StatusV3Model
/** @whatsapp 47896
* @whatsapp 547896 >= 2.2222.8
*/
export declare class StatusV3Model extends Model<StatusV3Collection> {
export declare class StatusV3Model extends ModelChatBase {
idClass: typeof Wid;
constructor(
proterties?: ModelPropertiesContructor<StatusV3Model>,
Expand Down

0 comments on commit 2814ef3

Please sign in to comment.