Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

WAsock

wasock (WhatsApp Socket) — مكتبة بايثون بسيطة للتعامل مع واتساب، مبنية فوق Baileys عن طريق عملية Node.js فرعية بتتواصل مع بايثون عبر TCP socket.

صُنعت بواسطة مطور مصري 🇪🇬 — Ahmed Mohmmed-AM.

الحالة: 0.5.0-Beta — لسه تحت التطوير، ممكن يحصل تغييرات في الـ API قبل النسخة المستقرة.


نظرة عامة (Overview)

wasock بتديك واجهة بايثونية سهلة للتعامل مع واتساب: استقبال رسايل، الرد عليها، بعت رسايل جديدة، حذف رسايل، وعرض QR Code لتسجيل الدخول — من غير ما تحتاج تكتب سطر JavaScript واحد.

wasock is a lightweight Python wrapper around Baileys. It spawns a Node.js subprocess and talks to it over a local TCP socket, so you can send, receive, reply to, and delete WhatsApp messages entirely from Python.


المتطلبات (Requirements)

  • Python >= 3.8
  • Node.js (>= 18 موصى بيه)
  • اتصال بالإنترنت لتثبيت اعتماديات npm الأولى

التثبيت (Installation)

pip install wasock

بعد التثبيت، لازم تثبت اعتماديات Node مرة واحدة (Baileys وpino) جوه فولدر المكتبة:

After installing, you need to install the Node.js dependencies once:

cd $(python -c "import wasock, os; print(os.path.join(os.path.dirname(wasock.__file__), 'node'))")
npm install

استخدام سريع (Quick Start)

from wasock import WhatsAppSocket, Message, QRCode, Connection

bot = WhatsAppSocket(authName="auth", loggerLevel="silent")

def onQr(data):
    qr = QRCode(data["qr"], size="mid", type="img")
    img = qr.render()
    img.save("qr.png")
    print("امسح qr.png من واتساب على موبايلك")

def onConnection(data):
    conn = Connection(data)
    if conn.connected:
        print("الاتصال فتح!")
    else:
        print(f"الاتصال اتقفل: {conn.reason}")

def onMessage(data):
    message = Message(data, bot.nodeJS)
    if message.fromBot:
        return

    if message.text == "!ping":
        message.reply("pong")

bot.on("qr", onQr)
bot.on("connection", onConnection)
bot.on("message", onMessage)

bot.start()

try:
    input("البوت شغال، دوس Enter للخروج...\n")
finally:
    bot.end()

الـ API

WhatsAppSocket(authName="auth", loggerLevel="silent")

بيبدأ الاتصال بسيرفر Node ويجهز الجلسة.

  • .start() — يبدأ الاتصال الفعلي بواتساب.
  • .on(event, callback) — يسجل event listener ("qr", "connection", "message").
  • .end() — يقفل الاتصال ويوقف عملية Node.

Message

بيتبني تلقائيًا لكل رسالة واردة. من أهم الخصائص:

الخاصية الوصف
.text نص الرسالة
.chat الـ JID بتاع المحادثة
.fromBot True لو الرسالة من البوت نفسه
.quoted / .quotedText / .quotedSender بيانات الرسالة المقتبسة (لو الرسالة ريبلاي)

Methods:

  • .reply(msg, chat=None, quoted=None) — يرد على الرسالة.
  • .send(msg, chat=None) — يبعت رسالة جديدة (من غير quote).
  • .delete() — يمسح الرسالة (Delete for Everyone).

QRCode(data, size="mid", type="terminal")

  • size: "small", "mid", "big"
  • type: "terminal" (يطبع في التيرمينال) أو "img" (يرجع صورة تقدر تعمله .save())

Connection

  • .connectedTrue/False
  • .statusCode — كود الإغلاق (لو موجود)
  • .reason — سبب الإغلاق (لو موجود)
  • .isAuthFailure()True لو السبب كان 401 (محتاج QR جديد)

ملاحظات مهمة (Important Notes)

  • فولدر auth/ بيحتوي على بيانات جلسة واتساب الحساسة — متعملوش commit على GitHub أبدًا.
  • مكان auth/ بيتحدد نسبيًا لمكان تشغيل السكريبت (working directory)، مش لمكان المكتبة.

الترخيص (License)

MIT License — تفاصيل أكتر في ملف LICENSE.


المطور (Author)

Ahmed Mohmmed-AM — مطور مصري 🇪🇬 GitHub: @Ahmed-Mohmmed-AM

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wasock-0.5.0b3.tar.gz (13.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wasock-0.5.0b3-py3-none-any.whl (14.6 MB view details)

Uploaded Python 3

File details

Details for the file wasock-0.5.0b3.tar.gz.

File metadata

  • Download URL: wasock-0.5.0b3.tar.gz
  • Upload date:
  • Size: 13.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for wasock-0.5.0b3.tar.gz
Algorithm Hash digest
SHA256 28254df589c085e4cbb8858d974df0c5b18f6a78d1f634f661f8bd0d4f3fc1bf
MD5 79cb873b28efb9bd9665adea26d4cc05
BLAKE2b-256 b784a678ba0cf4e095863be54f51afdd9b133074f1b0112b2b7123fe9fe025ed

See more details on using hashes here.

File details

Details for the file wasock-0.5.0b3-py3-none-any.whl.

File metadata

  • Download URL: wasock-0.5.0b3-py3-none-any.whl
  • Upload date:
  • Size: 14.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for wasock-0.5.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6160871da61f503d1935d14407e2d2908922e4ce0d9a4dd856dec8cd7716330
MD5 7a00183e10a0bbf6b33c6fe13806c572
BLAKE2b-256 be84260fd887433fa3c157b70cec9131d34ab6a33697c80e55d0b8f247639569

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.1

2 files

This release

0.5.0b3 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page