Whats / memory.md
hsoneabadi's picture
Switch from Baileys to whatsapp-web.js (wwebjs)
912167b
|
Raw
History Blame Contribute Delete
1.85 kB

Session Context

Current State

  • Telegram connected via MTProto (DC 1) — working
  • WhatsApp Connection — using whatsapp-web.js (Puppeteer + Chrome)
  • Bot forwards WhatsApp messages to Telegram admin (when connected)
  • Bot responds to /start, /toggle, button presses from Telegram

Key Fixes Applied

  1. messages.getDialogsupdates.getDifference: Bots can't use getDialogs (BOT_METHOD_INVALID). Replaced with getState + getDifference polling every 15s.

  2. defaultDcId string bug: Storage saves defaultDcId as string "1" but library expects number 1. All mtproto.call() calls now pass { dcId: 1 } explicitly.

  3. Keyboard format: replyKeyboardMarkup requires { _: 'keyboardButtonRow', buttons: [...] } format. Using one_time instead of single_use causes errors.

  4. Migrated from @whiskeysockets/baileys to whatsapp-web.js: Uses Puppeteer + Chrome instead of raw WebSocket. Requires Chromium installed in Docker.

  5. Markdown parsing: Custom parseMarkdown() converts *bold*, _italic_, `code` to Telegram message entities.

  6. QR auto-send: QR image sent to Telegram via upload.saveFilePart + messages.sendMedia when generated.

Pending Issues

  • wwebjs requires Chrome — Chrome must be installed in Docker (added to Dockerfile)
  • /data/ storage for session persistence

API Credentials

  • API_ID: 1344311
  • API_HASH: 95778042101cb549a4ca6235d7cf87e1
  • BOT_TOKEN: 903567266:AAFS-juBV5QYL_kKNkc7ovqp-i6eVwTOX-U
  • Fallback from env vars if set

User Preferences

  • Arabic language
  • No automatic startup messages (removed "✅ البوت جاهز" and "✅ واتساب متصل وجاهز")
  • QR code sent to Telegram automatically when generated
  • Keyboard buttons preferred over text commands
  • No emojis in code
  • No comments in code unless asked