diff --git a/src/Defaults/baileys-version.json b/src/Defaults/baileys-version.json new file mode 100644 index 00000000..0590b2e6 --- /dev/null +++ b/src/Defaults/baileys-version.json @@ -0,0 +1,3 @@ +{ + "version": [2, 3000, 1023223821] +} diff --git a/src/Utils/generics.ts b/src/Utils/generics.ts index 612100f4..c1277aef 100644 --- a/src/Utils/generics.ts +++ b/src/Utils/generics.ts @@ -245,15 +245,31 @@ export const bindWaitForConnectionUpdate = (ev: BaileysEventEmitter) => bindWait * Use to ensure your WA connection is always on the latest version */ export const fetchLatestBaileysVersion = async (options: AxiosRequestConfig<{}> = {}) => { - const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json' + const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts' try { - const result = await axios.get<{ version: WAVersion }>(URL, { + const result = await axios.get(URL, { ...options, - responseType: 'json' + responseType: 'text' }) - return { - version: result.data.version, - isLatest: true + + // Extract version from line 7 (const version = [...]) + const lines = result.data.split('\n') + const versionLine = lines[6] // Line 7 (0-indexed) + const versionMatch = versionLine!.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/) + + if (versionMatch) { + const version = [ + parseInt(versionMatch[1]!), + parseInt(versionMatch[2]!), + parseInt(versionMatch[3]!) + ] as WAVersion + + return { + version, + isLatest: true + } + } else { + throw new Error('Could not parse version from Defaults/index.ts') } } catch (error) { return {