Skip to content

Commit

Permalink
feat: Added WPP.group.join function
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 29, 2022
1 parent 675845c commit 2f92669
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/group/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export { iAmAdmin } from './iAmAdmin';
export { iAmMember } from './iAmMember';
export { iAmRestrictedMember } from './iAmRestrictedMember';
export { iAmSuperAdmin } from './iAmSuperAdmin';
export { join } from './join';
export { leave } from './leave';
export { promoteParticipants } from './promoteParticipants';
export { removeParticipants } from './removeParticipants';
40 changes: 40 additions & 0 deletions src/group/functions/join.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*!
* 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 { sendJoinGroupViaInvite } from '../../whatsapp/functions';

/**
* Join in a group from an invite code.
*
* @example
* ```javascript
* await WPP.group.join('abcde....');
* ```
*
* @category Group
*/
export async function join(inviteCode: string) {
inviteCode = inviteCode.replace('chat.whatsapp.com/', '');
inviteCode = inviteCode.replace('invite/', '');
inviteCode = inviteCode.replace('https://', '');
inviteCode = inviteCode.replace('http://', '');

const result = await sendJoinGroupViaInvite(inviteCode);

return {
id: result.toString(),
};
}
1 change: 1 addition & 0 deletions src/whatsapp/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export * from './sendClear';
export * from './sendCreateGroup';
export * from './sendDelete';
export * from './sendExitGroup';
export * from './sendJoinGroupViaInvite';
export * from './sendQueryExists';
export * from './sendTextMsgToChat';
export * from './status';
Expand Down
29 changes: 29 additions & 0 deletions src/whatsapp/functions/sendJoinGroupViaInvite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*!
* 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 { Wid } from '..';
import { exportModule } from '../exportModule';

/** @whatsapp 65705 */
export declare function sendJoinGroupViaInvite(code: string): Promise<Wid>;

exportModule(
exports,
{
sendJoinGroupViaInvite: 'sendJoinGroupViaInvite',
},
(m) => m.sendJoinGroupViaInvite
);

0 comments on commit 2f92669

Please sign in to comment.