Added logger, handled checksum fail

This commit is contained in:
Adhiraj Singh
2020-10-12 20:32:32 +05:30
parent 3fa2db4864
commit 6c000ab093
12 changed files with 342 additions and 101 deletions

View File

@@ -1,5 +1,5 @@
import {WAConnection as Base} from './7.MessagesExtra'
import { WAMetric, WAFlag, WANode, WAGroupMetadata, WAGroupCreateResponse, WAGroupModification, MessageLogLevel } from '../WAConnection/Constants'
import { WAMetric, WAFlag, WANode, WAGroupMetadata, WAGroupCreateResponse, WAGroupModification } from '../WAConnection/Constants'
import { GroupSettingChange } from './Constants'
import { generateMessageID } from '../WAConnection/Utils'
@@ -52,13 +52,13 @@ export class WAConnection extends Base {
try {
await this.groupMetadata (gid)
} catch (error) {
this.log (`error in group creation: ${error}, switching gid & checking`, MessageLogLevel.info)
this.logger.warn (`error in group creation: ${error}, switching gid & checking`)
// if metadata is not available
const comps = gid.replace ('@g.us', '').split ('-')
response.gid = `${comps[0]}-${+comps[1] + 1}@g.us`
await this.groupMetadata (gid)
this.log (`group ID switched from ${gid} to ${response.gid}`, MessageLogLevel.info)
this.logger.warn (`group ID switched from ${gid} to ${response.gid}`)
}
await this.chatAdd (response.gid, title)
return response