feat: add periodic version check with soft reconnection
Implements automatic version updates that are transparent to users:
- Checks for new WhatsApp Web version every 6 hours (configurable)
- When new version detected, saves it for next natural reconnection
- Emits 'version.update' event so users can track updates
- No disconnection required - WhatsApp naturally reconnects every 30min-2h
- Cleans up interval when socket closes
Configuration:
```typescript
const sock = await makeWASocketAutoVersion({
auth: state,
versionCheckIntervalMs: 6 * 60 * 60 * 1000 // 6 hours (default)
})
sock.ev.on('version.update', ({ currentVersion, newVersion, isCritical }) => {
console.log(`New version: ${newVersion.join('.')}`)
})
```
This commit is contained in:
@@ -56,6 +56,13 @@ export type SocketConfig = {
|
||||
* @default false
|
||||
*/
|
||||
fetchLatestVersion: boolean
|
||||
/**
|
||||
* Interval in milliseconds to check for new WhatsApp Web versions.
|
||||
* When a new version is detected, it will be used on the next reconnection.
|
||||
* Set to 0 to disable periodic checks.
|
||||
* @default 21600000 (6 hours)
|
||||
*/
|
||||
versionCheckIntervalMs: number
|
||||
/** override browser config */
|
||||
browser: WABrowserDescription
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
|
||||
Reference in New Issue
Block a user