Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37c4a85e76 | ||
|
|
8732af0f43 | ||
|
|
dfa7bc2ca8 | ||
|
|
f857bab540 | ||
|
|
59f2e1526d |
No files matched your search
@@ -1,3 +1,4 @@
|
||||
Dockerfile
|
||||
tokens
|
||||
files
|
||||
venv
|
||||
|
||||
+2
-1
@@ -19,5 +19,6 @@ RUN npm install
|
||||
WORKDIR /app
|
||||
ADD . /app
|
||||
RUN npm run build
|
||||
ENTRYPOINT npm run start:prod
|
||||
EXPOSE 3000
|
||||
|
||||
CMD npm run start:prod
|
||||
@@ -144,11 +144,18 @@ The description of [webhooks you can in Venom README.md, section Events](https:/
|
||||
|
||||
All webhooks are disabled by default:
|
||||
|
||||
- `WHATSAPP_HOOK_ONANYMESSAGE=http://localhost/uri`
|
||||
- `WHATSAPP_HOOK_ONMESSAGE=http://localhost/uri`
|
||||
- `WHATSAPP_HOOK_ONSTATECHANGE=http://localhost/uri`
|
||||
- `WHATSAPP_HOOK_ONACK=http://localhost/uri`
|
||||
- `WHATSAPP_HOOK_ONADDEDTOGROUP=http://localhost/uri`
|
||||
|
||||
If you want to look at the payload of the webhooks - use the url for that `https://httpbin.org/post`.
|
||||
|
||||
```bash
|
||||
docker run -it -v `pwd`/tokens:/app/tokens --network=host -e WHATSAPP_HOOK_ONMESSAGE=https://httpbin.org/post allburov/whatsapp-http-api
|
||||
```
|
||||
|
||||
## File storage
|
||||
|
||||
- `WHATSAPP_FILES_FOLDER` - folder where will be stored files from chats (images, voice messages) (
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
MessageLocation,
|
||||
MessageReply,
|
||||
MessageText,
|
||||
MessageTextQuery,
|
||||
MessageTextButtons
|
||||
MessageTextButtons,
|
||||
MessageTextQuery
|
||||
} from "./all.dto";
|
||||
import {ensureSuffix, WhatsappSessionManager} from "../whatsapp.service";
|
||||
|
||||
@@ -30,7 +30,11 @@ export class ChattingController {
|
||||
try {
|
||||
const result = await whatsapp.checkNumberStatus(ensureSuffix(request.phone))
|
||||
return {numberExists: result['numberExists']}
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
// We need to "touch" the error in order to get unhandled rejections
|
||||
// It logs out the session and stop the app
|
||||
console.log(typeof error)
|
||||
console.log(error)
|
||||
return {numberExists: false}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,11 @@ const writeFileAsync = promisify(fs.writeFile)
|
||||
|
||||
const SECOND = 1000;
|
||||
|
||||
const ONMESSAGE_HOOK = "onMessage"
|
||||
const ON_ANY_MESSAGE_HOOK = "onAnyMessage"
|
||||
const ON_MESSAGE_HOOK = "onMessage"
|
||||
const HOOKS = [
|
||||
ONMESSAGE_HOOK,
|
||||
ON_ANY_MESSAGE_HOOK,
|
||||
ON_MESSAGE_HOOK,
|
||||
"onStateChange",
|
||||
"onAck",
|
||||
// TODO: IMPLEMENTED THESE TOO
|
||||
@@ -191,7 +193,7 @@ export class WhatsappService {
|
||||
continue
|
||||
}
|
||||
|
||||
if (hook === ONMESSAGE_HOOK) {
|
||||
if (hook === ON_MESSAGE_HOOK || hook == ON_ANY_MESSAGE_HOOK) {
|
||||
this.whatsapp[hook](data => this.onMessageHook(data, url))
|
||||
} else {
|
||||
this.whatsapp[hook](data => this.callWebhook(data, url))
|
||||
|
||||
Reference in new issue
Block a user