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", "build:tsc": "tsc",
"example": "node --inspect -r ts-node/register Example/example.ts", "example": "node --inspect -r ts-node/register Example/example.ts",
"gen-protobuf": "bash src/Binary/GenerateStatics.sh", "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", "author": "Adhiraj Singh",
"license": "MIT", "license": "MIT",

View File

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

View File

@@ -1,7 +1,7 @@
import * as QR from 'qrcode-terminal' import * as QR from 'qrcode-terminal'
import { WAConnection as Base } from './3.Connect' 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 { 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, waMessageKey, newMessagesDB, shallowChanges, toNumber } from './Utils' import { whatsappID, unixTimestampSeconds, GET_MESSAGE_ID, WA_MESSAGE_ID, newMessagesDB, shallowChanges, toNumber, isGroupID } from './Utils'
import KeyedDB from '@adiwajshing/keyed-db' import KeyedDB from '@adiwajshing/keyed-db'
import { Mutex } from './Mutex' import { Mutex } from './Mutex'
@@ -488,6 +488,10 @@ export class WAConnection extends Base {
/** Adds the given message to the appropriate chat, if the chat doesn't exist, it is created */ /** Adds the given message to the appropriate chat, if the chat doesn't exist, it is created */
protected async chatAddMessageAppropriate (message: WAMessage) { 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) const chat = this.chats.get(jid) || await this.chatAdd (jid)
this.chatAddMessage (message, chat) this.chatAddMessage (message, chat)
} }