Skip to content

Commit

Permalink
feat: Aded call.incoming_call event
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jun 9, 2022
1 parent 652c46f commit e318902
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/call/events/eventTypes.ts
@@ -0,0 +1,31 @@
/*!
* Copyright 2022 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 { CallModel } from '../../whatsapp';

export interface CallEventTypes {
/**
* Triggered when you a incoming call
*
* @example
* ```javascript
* WPP.on('call.incoming_call', (call) => {
* // Your code
* });
* ```
*/
'call.incoming_call': CallModel;
}
17 changes: 17 additions & 0 deletions src/call/events/index.ts
@@ -0,0 +1,17 @@
/*!
* Copyright 2022 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 './registerIncomingCallEvent';
27 changes: 27 additions & 0 deletions src/call/events/registerIncomingCallEvent.ts
@@ -0,0 +1,27 @@
/*!
* Copyright 2022 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 { internalEv } from '../../eventEmitter';
import * as webpack from '../../webpack';
import { CallModel, CallStore } from '../../whatsapp';

webpack.onInjected(() => register());

function register() {
CallStore.on('add', (call: CallModel) => {
internalEv.emit('call.incoming_call', call);
});
}
5 changes: 4 additions & 1 deletion src/eventEmitter/eventTypes.ts
@@ -1,5 +1,5 @@
/*!
* Copyright 2021 WPPConnect Team
* Copyright 2022 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,18 +15,21 @@
*/

import { BlocklistEventTypes } from '../blocklist/events/eventTypes';
import { CallEventTypes } from '../call/events/eventTypes';
import { ChatEventTypes } from '../chat/events/eventTypes';
import { ConnEventTypes } from '../conn/events/eventTypes';
import { StatusEventTypes } from '../status/events/eventTypes';
import { WebpackEvents } from '../webpack/eventTypes';

export { BlocklistEventTypes } from '../blocklist/events/eventTypes';
export { CallEventTypes } from '../call/events/eventTypes';
export { ChatEventTypes } from '../chat/events/eventTypes';
export { ConnEventTypes } from '../conn/events/eventTypes';
export { StatusEventTypes } from '../status/events/eventTypes';
export { WebpackEvents } from '../webpack/eventTypes';

export type EventTypes = BlocklistEventTypes &
CallEventTypes &
ChatEventTypes &
ConnEventTypes &
StatusEventTypes &
Expand Down

0 comments on commit e318902

Please sign in to comment.