weird group ID patch

This commit is contained in:
Adhiraj Singh
2021-04-20 13:04:11 +05:30
parent 3b2618910c
commit 15ff592534
3 changed files with 11 additions and 7 deletions

View File

@@ -24,7 +24,7 @@
"build:tsc": "tsc",
"example": "node --inspect -r ts-node/register Example/example.ts",
"gen-protobuf": "bash src/Binary/GenerateStatics.sh",
"browser-decode": "npx ts-node src/BrowserMessageDecoding.ts"
"browser-decode": "yarn ts-node src/BrowserMessageDecoding.ts"
},
"author": "Adhiraj Singh",
"license": "MIT",

View File

@@ -32,7 +32,7 @@ const logger = pino({ prettyPrint: { levelFirst: true, ignore: 'hostname', trans
export class WAConnection extends EventEmitter {
/** The version of WhatsApp Web we're telling the servers we are */
version: [number, number, number] = [2, 2102, 9]
version: [number, number, number] = [2, 2112, 10]
/** The Browser we're telling the WhatsApp Web servers we are */
browserDescription: [string, string, string] = Utils.Browsers.baileys ('Chrome')
/** Metadata like WhatsApp id, name set on WhatsApp etc. */

View File

@@ -1,7 +1,7 @@
import * as QR from 'qrcode-terminal'
import { WAConnection as Base } from './3.Connect'
import { WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, AuthenticationCredentials, WAParticipantAction, WAGroupMetadata, WAUser, WANode, WAPresenceData, WAChatUpdate, BlocklistUpdate, WAContactUpdate, WAMetric, WAFlag } from './Constants'
import { whatsappID, unixTimestampSeconds, GET_MESSAGE_ID, WA_MESSAGE_ID, waMessageKey, newMessagesDB, shallowChanges, toNumber } from './Utils'
import { WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, WAParticipantAction, WAGroupMetadata, WANode, WAPresenceData, WAChatUpdate, BlocklistUpdate, WAContactUpdate, WAMetric, WAFlag } from './Constants'
import { whatsappID, unixTimestampSeconds, GET_MESSAGE_ID, WA_MESSAGE_ID, newMessagesDB, shallowChanges, toNumber, isGroupID } from './Utils'
import KeyedDB from '@adiwajshing/keyed-db'
import { Mutex } from './Mutex'
@@ -453,8 +453,8 @@ export class WAConnection extends Base {
modify_tag: '',
spam: 'false'
}
if(this.chats.insertIfAbsent (chat).length) {
this.emit ('chat-new', chat)
if(this.chats.insertIfAbsent(chat).length) {
this.emit('chat-new', chat)
return chat
}
}
@@ -487,7 +487,11 @@ export class WAConnection extends Base {
}
/** Adds the given message to the appropriate chat, if the chat doesn't exist, it is created */
protected async chatAddMessageAppropriate (message: WAMessage) {
const jid = whatsappID (message.key.remoteJid)
const jid = whatsappID(message.key.remoteJid)
if(isGroupID(jid) && !jid.includes('-')) {
this.logger.warn({ gid: jid }, 'recieved odd group ID')
return
}
const chat = this.chats.get(jid) || await this.chatAdd (jid)
this.chatAddMessage (message, chat)
}