- 
      
 - 
        
Save Zcoder4/80e45547650952c40e149203f0045ce8 to your computer and use it in GitHub Desktop.  
    Script to update WAProto on baileys module
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* | |
| Script to update WAProto on baileys module (ESM Only) | |
| Created by github.com/MuhammadRestu999 | |
| */ | |
| import fs from "fs"; | |
| const text = async (url) => { | |
| const res = await fetch(url); | |
| const text = await res.text(); | |
| return text; | |
| }; | |
| const base = "https://raw.githubusercontent.com/wppconnect-team/wa-proto/refs/heads/main"; | |
| const path = "./node_modules/baileys/WAProto"; | |
| const proto = x => x.replaceAll("waproto", "proto"); | |
| let index_js = proto(await text(`${base}/dist/index.js`)); | |
| const index_d_ts = proto(await text(`${base}/dist/index.d.ts`)); | |
| const WAProto = proto(await text(`${base}/WAProto.proto`)); | |
| index_js = index_js | |
| .replace(/var (\$protobuf) = require\((["']protobufjs\/minimal["'])\)/, "import $1 from $2") | |
| .replace(/(protobufjs\/minimal)/, "$1.js") | |
| .replace(/(Message.HistorySyncType) = /, "$1 = Message.HistorySyncNotification.HistorySyncType = ") | |
| .replace(/(\$root\.proto = )/, "export const proto = $1") | |
| .replace(/module\.exports = (\$root)/, "export default $1"); | |
| fs.writeFileSync(`${path}/index.js`, index_js); | |
| fs.writeFileSync(`${path}/index.d.ts`, index_d_ts); | |
| fs.writeFileSync(`${path}/WAProto.proto`, WAProto); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment