soropy 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
soropy-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SoroPy Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ include setup.py
5
+ recursive-include soropy *.py
6
+ recursive-include examples *.py
7
+ global-exclude __pycache__
8
+ global-exclude *.py[co]
9
+ global-exclude *.egg-info
soropy-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: soropy
3
+ Version: 1.0.0
4
+ Summary: کتابخانه حرفه‌ای سروش پلاس برای پایتون - Professional Soroush Plus Web Client Library
5
+ Home-page: https://github.com/soropy/soropy
6
+ Author: SoroPy Team
7
+ Author-email: SoroPy Team <soropy@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/soropy/soropy
10
+ Project-URL: Documentation, https://soropy.readthedocs.io
11
+ Project-URL: Repository, https://github.com/soropy/soropy
12
+ Project-URL: Issues, https://github.com/soropy/soropy/issues
13
+ Keywords: soroush,splus,messenger,automation,bot,soroush-plus
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Communications :: Chat
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Operating System :: OS Independent
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: selenium>=4.10.0
30
+ Dynamic: author
31
+ Dynamic: home-page
32
+ Dynamic: license-file
33
+ Dynamic: requires-python
34
+
35
+ # SoroPy 🚀
36
+
37
+ **حرفه‌ای‌ترین کتابخانه پایتون برای سروش پلاس**
38
+
39
+ [![PyPI](https://img.shields.io/pypi/v/soropy)](https://pypi.org/project/soropy/)
40
+ [![Python](https://img.shields.io/pypi/pyversions/soropy)](https://pypi.org/project/soropy/)
41
+ [![License](https://img.shields.io/pypi/l/soropy)](https://opensource.org/licenses/MIT)
42
+
43
+ ---
44
+
45
+ ## ✨ امکانات
46
+
47
+ | قابلیت | توضیح |
48
+ |--------|-------|
49
+ | 🔐 **لاگین خودکار** | ورود با شماره + کد تأیید، ذخیره سشن |
50
+ | 💬 **استخراج چت‌ها** | لیست همه / شخصی / گروه / کانال |
51
+ | 📨 **ارسال پیام** | تکی و دسته‌ای به چت‌های شخصی |
52
+ | 📢 **ارسال در کانال** | پست گذاشتن (نیاز به ادمین بودن) |
53
+ | 📇 **مدیریت مخاطبین** | مشاهده، اضافه کردن، جستجو |
54
+ | 🤖 **پاسخ خودکار** | موتور قوانین + جلوگیری از پاسخ تکراری |
55
+ | 👁️ **مانیتور مداوم** | بررسی و پاسخ خودکار هر X ثانیه |
56
+ | 👥 **چند اکانت** | مدیریت همزمان چندین حساب |
57
+ | 🖥️ **بدون پنجره** | حالت headless - بدون نمایش مرورگر |
58
+ | 🧵 **Thread-safe** | طراحی ایمن برای چند نخی |
59
+ | 💾 **ذخیره سشن** | بدون نیاز به لاگین مجدد |
60
+
61
+ ---
62
+
63
+ ## 📦 نصب
64
+
65
+ ```bash
66
+ pip install soropy
soropy-1.0.0/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # SoroPy 🚀
2
+
3
+ **حرفه‌ای‌ترین کتابخانه پایتون برای سروش پلاس**
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/soropy)](https://pypi.org/project/soropy/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/soropy)](https://pypi.org/project/soropy/)
7
+ [![License](https://img.shields.io/pypi/l/soropy)](https://opensource.org/licenses/MIT)
8
+
9
+ ---
10
+
11
+ ## ✨ امکانات
12
+
13
+ | قابلیت | توضیح |
14
+ |--------|-------|
15
+ | 🔐 **لاگین خودکار** | ورود با شماره + کد تأیید، ذخیره سشن |
16
+ | 💬 **استخراج چت‌ها** | لیست همه / شخصی / گروه / کانال |
17
+ | 📨 **ارسال پیام** | تکی و دسته‌ای به چت‌های شخصی |
18
+ | 📢 **ارسال در کانال** | پست گذاشتن (نیاز به ادمین بودن) |
19
+ | 📇 **مدیریت مخاطبین** | مشاهده، اضافه کردن، جستجو |
20
+ | 🤖 **پاسخ خودکار** | موتور قوانین + جلوگیری از پاسخ تکراری |
21
+ | 👁️ **مانیتور مداوم** | بررسی و پاسخ خودکار هر X ثانیه |
22
+ | 👥 **چند اکانت** | مدیریت همزمان چندین حساب |
23
+ | 🖥️ **بدون پنجره** | حالت headless - بدون نمایش مرورگر |
24
+ | 🧵 **Thread-safe** | طراحی ایمن برای چند نخی |
25
+ | 💾 **ذخیره سشن** | بدون نیاز به لاگین مجدد |
26
+
27
+ ---
28
+
29
+ ## 📦 نصب
30
+
31
+ ```bash
32
+ pip install soropy
@@ -0,0 +1,41 @@
1
+ """
2
+ Auto-reply with custom rules.
3
+ """
4
+
5
+ from soropy import SoroushClient
6
+
7
+ client = SoroushClient("09123456789", headless=True)
8
+
9
+ try:
10
+ client.login()
11
+
12
+ # ── Configure rules ────────────────────────────────
13
+ client.add_reply_rule("سلام", "علیک سلام! 👋")
14
+ client.add_reply_rule("چطوری", "خوبم ممنون، تو چطوری؟")
15
+ client.add_reply_rule("خوبی", "ممنون خوبم! 😊")
16
+ client.add_reply_rule("خداحافظ", "بای بای! 🙏", priority=10)
17
+
18
+ # Or bulk-load from dict:
19
+ client.load_reply_rules({
20
+ "قیمت": "لطفاً به سایت مراجعه کنید",
21
+ "آدرس": "تهران، خیابان ولیعصر",
22
+ })
23
+
24
+ # Set the fallback reply
25
+ client.set_default_reply("پیامت دریافت شد، به زودی پاسخ میدم ✅")
26
+
27
+ # ── Single pass ────────────────────────────────────
28
+ results = client.check_and_reply()
29
+ for chat, sends in results.items():
30
+ for s in sends:
31
+ print(s)
32
+
33
+ # ── Or continuous monitor ──────────────────────────
34
+ def on_reply(chat_name, original, reply):
35
+ print(f"📨 {chat_name}: replied '{reply}'")
36
+
37
+ # Blocking (Ctrl+C to stop):
38
+ client.start_monitor(interval=30, blocking=True, on_reply=on_reply)
39
+
40
+ finally:
41
+ client.close()
@@ -0,0 +1,51 @@
1
+ """
2
+ Basic SoroPy usage example.
3
+ """
4
+
5
+ from soropy import SoroushClient
6
+
7
+ # ── Single account ────────────────────────────────────
8
+
9
+ client = SoroushClient(
10
+ phone="09123456789",
11
+ headless=False, # Set True for invisible browser
12
+ session_dir="my_sessions",
13
+ )
14
+
15
+ try:
16
+ # Login (will prompt for SMS code if needed)
17
+ status = client.login()
18
+ print(f"Login status: {status}")
19
+
20
+ # Extract chat list
21
+ chats = client.get_chats(save_to="chats.json")
22
+ print(f"Total chats: {chats.total_count}")
23
+ print(f"Personal: {len(chats.personal)}")
24
+ print(f"Groups: {len(chats.groups)}")
25
+ print(f"Channels: {len(chats.channels)}")
26
+
27
+ # Send a message to a specific chat
28
+ result = client.send_message("علی", "سلام! حالت خوبه؟")
29
+ print(result)
30
+
31
+ # Send bulk messages to first 5 personal chats
32
+ results = client.send_to_personal(message="سلام!", max_count=5)
33
+ for r in results:
34
+ print(r)
35
+
36
+ # Get contacts
37
+ contacts = client.get_contacts()
38
+ print(f"Contacts: {len(contacts)}")
39
+
40
+ # Add a contact
41
+ client.add_contact("09187654321", "محمد", "احمدی")
42
+
43
+ # Search contacts
44
+ found = client.search_contacts("محمد")
45
+ print(f"Found: {found}")
46
+
47
+ # Send to channel (admin required)
48
+ client.send_to_channel("@my_channel", "سلام از SoroPy!")
49
+
50
+ finally:
51
+ client.close()
@@ -0,0 +1,40 @@
1
+ """
2
+ Headless (no visible window) operation.
3
+ """
4
+
5
+ from soropy import SoroushClient
6
+
7
+ # The browser runs invisibly
8
+ client = SoroushClient(
9
+ phone="09123456789",
10
+ headless=True,
11
+ session_dir="headless_sessions",
12
+ )
13
+
14
+ try:
15
+ # If session exists, no code needed
16
+ if client.has_session:
17
+ print("Session found – auto-login")
18
+ status = client.login()
19
+ else:
20
+ # First time: need code
21
+ def get_code():
22
+ return input("Enter SMS code: ")
23
+ status = client.login(code_callback=get_code)
24
+
25
+ print(f"Status: {status}")
26
+
27
+ # Do work...
28
+ chats = client.get_chats()
29
+ print(f"Chats: {chats.total_count}")
30
+
31
+ # Single auto-reply pass
32
+ results = client.check_and_reply()
33
+ total_ok = sum(
34
+ 1 for sends in results.values()
35
+ for s in sends if s.success
36
+ )
37
+ print(f"Replied to {total_ok} messages")
38
+
39
+ finally:
40
+ client.close()
@@ -0,0 +1,48 @@
1
+ """
2
+ نمونه کاربردی ساده - لاگین و ارسال به ۳ نفر
3
+ اجرا:
4
+ pip install soropy
5
+ python send_three.py
6
+ """
7
+
8
+ from soropy import SoroushClient
9
+
10
+ # ─── مرحله ۱: شماره و لاگین ───────────────────────────
11
+ raw_phone = input("📱 شماره تلفن (مثلاً 09123456789): ").strip()
12
+
13
+ client = SoroushClient(phone=raw_phone, headless=True)
14
+
15
+ try:
16
+ # لاگین - اگه اولین باره کد SMS میخواد
17
+ status = client.login()
18
+ print(f"✅ وضعیت: {status.value}")
19
+
20
+ # ─── مرحله ۲: گرفتن نام ۳ نفر ─────────────────────
21
+ targets = []
22
+ for i in range(1, 4):
23
+ name = input(f"👤 نام شخص {i}: ").strip()
24
+ targets.append(name)
25
+
26
+ # ─── مرحله ۳: ارسال پیام ──────────────────────────
27
+ msg = "سلام خوبی؟ 😊"
28
+ print(f"\n📨 ارسال: '{msg}' به {len(targets)} نفر\n")
29
+
30
+ results = client.send_bulk_messages(
31
+ chat_names=targets,
32
+ message=msg,
33
+ delay=3.0,
34
+ )
35
+
36
+ # ─── نتیجه ─────────────────────────────────────────
37
+ ok = sum(1 for r in results if r.success)
38
+ fail = len(results) - ok
39
+
40
+ print("\n" + "=" * 40)
41
+ print(f"📊 نتیجه: ✅ {ok} | ❌ {fail}")
42
+ for r in results:
43
+ print(f" {r}")
44
+ print("=" * 40)
45
+
46
+ finally:
47
+ input("\n⏎ Enter بزن تا بسته بشه...")
48
+ client.close()
@@ -0,0 +1,52 @@
1
+ """
2
+ Multi-account management example.
3
+ """
4
+
5
+ from soropy import MultiAccountManager
6
+
7
+ manager = MultiAccountManager(
8
+ headless=True,
9
+ session_dir="multi_sessions",
10
+ )
11
+
12
+ try:
13
+ # Register accounts
14
+ c1 = manager.add_account("09123456789")
15
+ c2 = manager.add_account("09187654321")
16
+
17
+ # Configure rules per-account
18
+ c1.add_reply_rule("سلام", "سلام از اکانت ۱")
19
+ c2.add_reply_rule("سلام", "سلام از اکانت ۲")
20
+
21
+ # Login all (sequential, will prompt for codes)
22
+ statuses = manager.login_all()
23
+ for phone, status in statuses.items():
24
+ print(f"{phone}: {status.value}")
25
+
26
+ # Extract chats for account 1
27
+ chats = manager.get_client("09123456789").get_chats()
28
+ print(f"Account 1 chats: {chats.total_count}")
29
+
30
+ # Send message from account 2
31
+ result = manager.get_client("09187654321").send_message("علی", "سلام!")
32
+ print(result)
33
+
34
+ # Start monitors for all accounts
35
+ def on_any_reply(phone, chat, orig, reply):
36
+ print(f"[{phone}] {chat} → {reply}")
37
+
38
+ threads = manager.start_all_monitors(interval=30, on_reply=on_any_reply)
39
+ print(f"Monitors running: {len(threads)}")
40
+
41
+ # Keep running
42
+ import time
43
+ try:
44
+ while True:
45
+ time.sleep(1)
46
+ except KeyboardInterrupt:
47
+ pass
48
+
49
+ manager.stop_all_monitors()
50
+
51
+ finally:
52
+ manager.close_all()
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "soropy"
7
+ version = "1.0.0"
8
+ description = "کتابخانه حرفه‌ای سروش پلاس برای پایتون - Professional Soroush Plus Web Client Library"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ {name = "SoroPy Team", email = "soropy@example.com"}
14
+ ]
15
+ keywords = ["soroush", "splus", "messenger", "automation", "bot", "soroush-plus"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Topic :: Communications :: Chat",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ "Operating System :: OS Independent",
29
+ ]
30
+ dependencies = [
31
+ "selenium>=4.10.0",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/soropy/soropy"
36
+ Documentation = "https://soropy.readthedocs.io"
37
+ Repository = "https://github.com/soropy/soropy"
38
+ Issues = "https://github.com/soropy/soropy/issues"
39
+
40
+ [tool.setuptools.packages.find]
41
+ include = ["soropy*"]
soropy-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
soropy-1.0.0/setup.py ADDED
@@ -0,0 +1,21 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="soropy",
5
+ version="1.0.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "selenium>=4.10.0",
9
+ ],
10
+ python_requires=">=3.8",
11
+ author="SoroPy Team",
12
+ description="Professional Soroush Plus Web Client Library for Python",
13
+ long_description=open("README.md", encoding="utf-8").read(),
14
+ long_description_content_type="text/markdown",
15
+ url="https://github.com/soropy/soropy",
16
+ classifiers=[
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ],
21
+ )
@@ -0,0 +1,86 @@
1
+ """
2
+ SoroPy - Professional Soroush Plus Web Client Library
3
+ =====================================================
4
+
5
+ A comprehensive, production-grade Python library for automating
6
+ Soroush Plus (splus.ir) web messenger.
7
+
8
+ Features:
9
+ - Multi-account simultaneous sessions
10
+ - Headless browser support
11
+ - Auto-reply with rule engine and duplicate prevention
12
+ - Chat extraction, messaging, channel posting
13
+ - Contact management
14
+ - Persistent session management
15
+ - Thread-safe design
16
+
17
+ Basic Usage:
18
+ >>> from soropy import SoroushClient
19
+ >>> client = SoroushClient("+989123456789")
20
+ >>> client.login()
21
+ >>> chats = client.get_chats()
22
+ >>> client.send_message("علی", "سلام!")
23
+ >>> client.close()
24
+
25
+ Multi-Account:
26
+ >>> from soropy import MultiAccountManager
27
+ >>> manager = MultiAccountManager()
28
+ >>> manager.add_account("+989123456789")
29
+ >>> manager.add_account("+989187654321")
30
+ >>> manager.login_all()
31
+ """
32
+
33
+ __version__ = "1.0.0"
34
+ __author__ = "SoroPy Team"
35
+ __license__ = "MIT"
36
+
37
+ from soropy.client import SoroushClient
38
+ from soropy.auto_reply import AutoReplyEngine, ReplyRule
39
+ from soropy.types import (
40
+ ChatInfo,
41
+ ContactInfo,
42
+ MessageInfo,
43
+ UnreadChat,
44
+ SendResult,
45
+ LoginStatus,
46
+ )
47
+ from soropy.exceptions import (
48
+ SoroPyError,
49
+ LoginError,
50
+ SessionError,
51
+ ChatError,
52
+ MessageError,
53
+ ContactError,
54
+ ChannelError,
55
+ BrowserError,
56
+ TimeoutError as SoroPyTimeoutError,
57
+ )
58
+ from soropy.session import SessionManager
59
+ from soropy.message_tracker import MessageTracker
60
+
61
+ # Multi-account manager
62
+ from soropy.multi import MultiAccountManager
63
+
64
+ __all__ = [
65
+ "SoroushClient",
66
+ "MultiAccountManager",
67
+ "AutoReplyEngine",
68
+ "ReplyRule",
69
+ "ChatInfo",
70
+ "ContactInfo",
71
+ "MessageInfo",
72
+ "UnreadChat",
73
+ "SendResult",
74
+ "LoginStatus",
75
+ "SessionManager",
76
+ "MessageTracker",
77
+ "SoroPyError",
78
+ "LoginError",
79
+ "SessionError",
80
+ "ChatError",
81
+ "MessageError",
82
+ "ContactError",
83
+ "ChannelError",
84
+ "BrowserError",
85
+ "SoroPyTimeoutError",
86
+ ]