diff --git a/package.json b/package.json index e1a165a..c0f0307 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/WAConnection/0.Base.ts b/src/WAConnection/0.Base.ts index d35f430..b60c102 100644 --- a/src/WAConnection/0.Base.ts +++ b/src/WAConnection/0.Base.ts @@ -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. */ diff --git a/src/WAConnection/4.Events.ts b/src/WAConnection/4.Events.ts index a41bcf0..b5b54ed 100644 --- a/src/WAConnection/4.Events.ts +++ b/src/WAConnection/4.Events.ts @@ -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) }