tweakio-sdk 0.1.5__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.
Files changed (48) hide show
  1. tweakio_sdk-0.1.5/Custom_logger.py +54 -0
  2. tweakio_sdk-0.1.5/LICENSE +21 -0
  3. tweakio_sdk-0.1.5/MANIFEST.in +5 -0
  4. tweakio_sdk-0.1.5/PKG-INFO +342 -0
  5. tweakio_sdk-0.1.5/README.md +301 -0
  6. tweakio_sdk-0.1.5/directory.py +42 -0
  7. tweakio_sdk-0.1.5/pyproject.toml +99 -0
  8. tweakio_sdk-0.1.5/requirements.txt +132 -0
  9. tweakio_sdk-0.1.5/setup.cfg +4 -0
  10. tweakio_sdk-0.1.5/setup.py +32 -0
  11. tweakio_sdk-0.1.5/src/BrowserManager/__init__.py +302 -0
  12. tweakio_sdk-0.1.5/src/Decorators/Chat_Click_decorator.py +28 -0
  13. tweakio_sdk-0.1.5/src/Decorators/__init__.py +0 -0
  14. tweakio_sdk-0.1.5/src/Exceptions/__init__.py +44 -0
  15. tweakio_sdk-0.1.5/src/Exceptions/base.py +44 -0
  16. tweakio_sdk-0.1.5/src/Exceptions/whatsapp.py +100 -0
  17. tweakio_sdk-0.1.5/src/FIlter/__init__.py +0 -0
  18. tweakio_sdk-0.1.5/src/FIlter/message_filter.py +120 -0
  19. tweakio_sdk-0.1.5/src/Interfaces/__init__.py +0 -0
  20. tweakio_sdk-0.1.5/src/Interfaces/chat_interface.py +20 -0
  21. tweakio_sdk-0.1.5/src/Interfaces/chat_processor_interface.py +37 -0
  22. tweakio_sdk-0.1.5/src/Interfaces/humanize_operation_interface.py +21 -0
  23. tweakio_sdk-0.1.5/src/Interfaces/login_interface.py +29 -0
  24. tweakio_sdk-0.1.5/src/Interfaces/media_capable_interface.py +43 -0
  25. tweakio_sdk-0.1.5/src/Interfaces/message_interface.py +20 -0
  26. tweakio_sdk-0.1.5/src/Interfaces/message_processor_interface.py +42 -0
  27. tweakio_sdk-0.1.5/src/Interfaces/reply_capable_interface.py +30 -0
  28. tweakio_sdk-0.1.5/src/Interfaces/storage_interface.py +96 -0
  29. tweakio_sdk-0.1.5/src/Interfaces/web_ui_selector.py +20 -0
  30. tweakio_sdk-0.1.5/src/StorageDB/__init__.py +0 -0
  31. tweakio_sdk-0.1.5/src/StorageDB/sqlite_db.py +323 -0
  32. tweakio_sdk-0.1.5/src/WhatsApp/DerivedTypes/Chat.py +28 -0
  33. tweakio_sdk-0.1.5/src/WhatsApp/DerivedTypes/Message.py +43 -0
  34. tweakio_sdk-0.1.5/src/WhatsApp/DerivedTypes/__init__.py +0 -0
  35. tweakio_sdk-0.1.5/src/WhatsApp/__init__.py +0 -0
  36. tweakio_sdk-0.1.5/src/WhatsApp/chat_processor.py +144 -0
  37. tweakio_sdk-0.1.5/src/WhatsApp/humanized_operations.py +77 -0
  38. tweakio_sdk-0.1.5/src/WhatsApp/login.py +191 -0
  39. tweakio_sdk-0.1.5/src/WhatsApp/media_capable.py +75 -0
  40. tweakio_sdk-0.1.5/src/WhatsApp/message_processor.py +117 -0
  41. tweakio_sdk-0.1.5/src/WhatsApp/reply_capable.py +84 -0
  42. tweakio_sdk-0.1.5/src/WhatsApp/web_ui_config.py +430 -0
  43. tweakio_sdk-0.1.5/src/tweakio_sdk.egg-info/PKG-INFO +342 -0
  44. tweakio_sdk-0.1.5/src/tweakio_sdk.egg-info/SOURCES.txt +46 -0
  45. tweakio_sdk-0.1.5/src/tweakio_sdk.egg-info/dependency_links.txt +1 -0
  46. tweakio_sdk-0.1.5/src/tweakio_sdk.egg-info/requires.txt +12 -0
  47. tweakio_sdk-0.1.5/src/tweakio_sdk.egg-info/top_level.txt +20 -0
  48. tweakio_sdk-0.1.5/test/testmodule.py +74 -0
@@ -0,0 +1,54 @@
1
+ """
2
+ Shared Resources Module for tweakio-sdk library
3
+ """
4
+ import logging
5
+ from logging.handlers import RotatingFileHandler
6
+
7
+ from colorlog import ColoredFormatter
8
+
9
+ import directory as dirs
10
+
11
+ # ------ Logger Configs ---------
12
+ logger = logging.getLogger("tweakio")
13
+ logger.setLevel(logging.INFO)
14
+
15
+ # -------------------------------
16
+ # Console handler
17
+ # -------------------------------
18
+
19
+ console_formatter = ColoredFormatter(
20
+ "%(log_color)s%(asctime)s | %(levelname)s | %(message)s",
21
+ log_colors={
22
+ 'DEBUG': 'cyan',
23
+ 'INFO': 'green',
24
+ 'WARNING': 'yellow',
25
+ 'ERROR': 'red',
26
+ 'CRITICAL': 'bold_red'
27
+ }
28
+ )
29
+
30
+ console_handler = logging.StreamHandler()
31
+ console_handler.setFormatter(console_formatter)
32
+ logger.addHandler(console_handler)
33
+
34
+ console_formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(message)s")
35
+ console_handler.setFormatter(console_formatter)
36
+ logger.addHandler(console_handler)
37
+
38
+ # -------------------------------
39
+ # File handler with rotation
40
+ # -------------------------------
41
+ file_handler = RotatingFileHandler(
42
+ dirs.ErrorTrace_file, # file path
43
+ maxBytes=20 * 1024 * 1024, # 20 MB per file
44
+ backupCount=3 # keep last 3 files
45
+ )
46
+ file_formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(message)s")
47
+ file_handler.setFormatter(file_formatter)
48
+ logger.addHandler(file_handler)
49
+
50
+ # -------------------------------
51
+ # General settings
52
+ # -------------------------------
53
+ logger.propagate = False
54
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 [BITS-Rohit]
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,5 @@
1
+ include README.md
2
+ include LICENSE
3
+ include *.py
4
+ include requirements.txt
5
+ recursive-include BrowserManager *.py
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: tweakio-sdk
3
+ Version: 0.1.5
4
+ Summary: Tweakio-SDK: WhatsApp automation Python library with anti-detection, async storage, and production-grade architecture
5
+ Author: Rohit
6
+ Author-email: BITS-Rohit <rohit@tweakio.dev>
7
+ Maintainer-email: BITS-Rohit <rohit@tweakio.dev>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/BITS-Rohit/tweakio-sdk
10
+ Project-URL: Repository, https://github.com/BITS-Rohit/tweakio-sdk
11
+ Project-URL: Documentation, https://github.com/BITS-Rohit/tweakio-sdk#readme
12
+ Project-URL: Issues, https://github.com/BITS-Rohit/tweakio-sdk/issues
13
+ Project-URL: Changelog, https://github.com/BITS-Rohit/tweakio-sdk/releases
14
+ Keywords: tweakio,tweakio-sdk,whatsapp,whatsapp-automation,whatsapp-bot,automation,playwright,web-automation,browser-automation,chatbot,messaging,anti-detection,camoufox
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Communications :: Chat
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: playwright>=1.40.0
28
+ Requires-Dist: camoufox>=0.3.0
29
+ Requires-Dist: pyperclip>=1.8.2
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
32
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
33
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
34
+ Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
35
+ Requires-Dist: black>=23.0.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.0.290; extra == "dev"
38
+ Dynamic: author
39
+ Dynamic: license-file
40
+ Dynamic: requires-python
41
+
42
+ # Tweakio-SDK
43
+
44
+ > **Production-Grade WhatsApp Web Automation for Python**
45
+ > _Anti-detection browser automation built on Playwright + Camoufox._
46
+
47
+ [![PyPI - Version](https://img.shields.io/pypi/v/tweakio-sdk?label=tweakio-sdk)](https://pypi.org/project/tweakio-sdk/)
48
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tweakio-sdk)](https://pypi.org/project/tweakio-sdk/)
49
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
50
+ [![Test Coverage](https://img.shields.io/badge/coverage-%3E90%25-brightgreen)](https://github.com/BITS-Rohit/tweakio-sdk)
51
+
52
+ **[Documentation](https://github.com/BITS-Rohit/tweakio-sdk#readme)** · **[PyPI](https://pypi.org/project/tweakio-sdk/)** · **[Issues](https://github.com/BITS-Rohit/tweakio-sdk/issues)** · **[Contributing](#contributing)**
53
+
54
+ ---
55
+
56
+ ## 🔴 The Problem
57
+
58
+ WhatsApp automation is broken:
59
+
60
+ 1. **Detection & Bans** — Standard Selenium/Playwright scripts are fingerprinted and banned within hours
61
+ 2. **Fragile Scripts** — When WhatsApp updates its UI, your selectors break. You spend weeks patching instead of building
62
+ 3. **No Production Patterns** — Most automation tools are throwaway scripts, not production software with proper architecture
63
+ 4. **Platform Lock-In** — Want to add Telegram later? Start from scratch
64
+
65
+ **The industry treats automation as disposable code. We don't.**
66
+
67
+ ---
68
+
69
+ ## 💡 The Solution
70
+
71
+ **Tweakio-SDK** is a WhatsApp automation framework built with production-grade patterns:
72
+
73
+ | Problem | Tweakio Solution |
74
+ |---------|------------------|
75
+ | Detection | **Camoufox + BrowserForge** fingerprinting (indistinguishable from humans) |
76
+ | Fragile selectors | **Interface-driven architecture** — when WhatsApp breaks, only `src/WhatsApp/` needs updates |
77
+ | No persistence | **Async SQLite storage** with background queue workers |
78
+ | No typing | **Type-safe dataclasses** for Chat and Message objects |
79
+
80
+ **Current**: WhatsApp Web (v0.1.5)
81
+ **Roadmap**: Telegram (Q2 2026), Instagram (Q3 2026)
82
+
83
+ ---
84
+
85
+ ## 📦 Installation
86
+
87
+ ```bash
88
+ pip install tweakio-sdk
89
+ ```
90
+
91
+ **Requirements**: Python 3.10+, Playwright browsers
92
+
93
+ ```bash
94
+ # Install Playwright browsers (one-time)
95
+ playwright install chromium
96
+ ```
97
+
98
+ ---
99
+
100
+ ## ⚡ Quick Start
101
+
102
+ ### Basic: Fetch Chats
103
+
104
+ ```python
105
+ import asyncio
106
+ from BrowserManager import BrowserManager
107
+ from src.WhatsApp.login import Login
108
+ from src.WhatsApp.chat_processor import ChatProcessor
109
+ from src.WhatsApp.web_ui_config import WebSelectorConfig
110
+ from Custom_logger import logger
111
+
112
+ async def main():
113
+ # 1. Launch anti-detect browser
114
+ browser = BrowserManager(headless=False)
115
+ page = await browser.getPage()
116
+
117
+ # 2. Initialize UI config and Login
118
+ ui_config = WebSelectorConfig(page=page, log=logger)
119
+ login = Login(page=page, UIConfig=ui_config, log=logger)
120
+
121
+ # 3. Login (scan QR code on first run)
122
+ await login.login(save_path="./session.json")
123
+
124
+ # 4. Fetch chats
125
+ chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
126
+ async for chat, name in chat_processor.Fetcher(MaxChat=5):
127
+ print(f"📂 Chat: {name}")
128
+
129
+ asyncio.run(main())
130
+ ```
131
+
132
+ ### Advanced: Message Processing with Storage
133
+
134
+ ```python
135
+ import asyncio
136
+ from BrowserManager import BrowserManager
137
+ from src.WhatsApp.login import Login
138
+ from src.WhatsApp.chat_processor import ChatProcessor
139
+ from src.WhatsApp.message_processor import MessageProcessor
140
+ from src.WhatsApp.web_ui_config import WebSelectorConfig
141
+ from src.StorageDB.sqlite_db import SQLITE_DB
142
+ from Custom_logger import logger
143
+
144
+ async def main():
145
+ # Browser + Login setup (same as above)
146
+ browser = BrowserManager(headless=False)
147
+ page = await browser.getPage()
148
+ ui_config = WebSelectorConfig(page=page, log=logger)
149
+ login = Login(page=page, UIConfig=ui_config, log=logger)
150
+ await login.login(save_path="./session.json")
151
+
152
+ # Initialize async storage
153
+ queue = asyncio.Queue()
154
+ async with SQLITE_DB(queue=queue, log=logger, db_path="messages.db") as storage:
155
+
156
+ # Initialize processors
157
+ chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
158
+ msg_processor = MessageProcessor(
159
+ page=page,
160
+ UIConfig=ui_config,
161
+ chat_processor=chat_processor,
162
+ log=logger,
163
+ storage=storage # Messages auto-saved to SQLite
164
+ )
165
+
166
+ # Fetch and process messages
167
+ async for chat, name in chat_processor.Fetcher(MaxChat=3):
168
+ print(f"📂 Processing: {name}")
169
+
170
+ # Fetcher returns wrapped Message objects with deduplication
171
+ messages = await msg_processor.Fetcher(chat=chat, retry=3)
172
+
173
+ for msg in messages:
174
+ print(f" 💬 {msg.data_type}: {msg.raw_data[:50]}...")
175
+ print(f" ID: {msg.message_id}")
176
+ print(f" Direction: {msg.direction}")
177
+
178
+ asyncio.run(main())
179
+ ```
180
+
181
+ ---
182
+
183
+ ## 🏗️ Architecture
184
+
185
+ ```
186
+ tweakio-sdk/
187
+ ├── src/
188
+ │ ├── BrowserManager/ # Anti-detect Playwright + Camoufox
189
+ │ ├── WhatsApp/ # Platform-specific implementation
190
+ │ │ ├── login.py # QR + Phone authentication
191
+ │ │ ├── chat_processor.py
192
+ │ │ ├── message_processor.py
193
+ │ │ ├── web_ui_config.py # Selector definitions
194
+ │ │ └── DerivedTypes/ # Chat, Message dataclasses
195
+ │ ├── Interfaces/ # Abstract contracts (for future platforms)
196
+ │ ├── StorageDB/ # Async SQLite with queue workers
197
+ │ └── Exceptions/ # Custom exception hierarchy
198
+ └── tests/ # >90% coverage on core modules
199
+ ```
200
+
201
+ ### Key Design Decisions
202
+
203
+ - **Interface-Driven**: Every platform implements `ChatProcessorInterface`, `MessageProcessorInterface`, etc.
204
+ - **Dependency Injection**: All classes accept `log` parameter for testability
205
+ - **Async-First**: Non-blocking SQLite writes, background queue workers
206
+ - **Anti-Detection**: Camoufox fingerprints + human-like typing delays
207
+
208
+ ---
209
+
210
+ ## 📊 Modules
211
+
212
+ | Module | Description |
213
+ |--------|-------------|
214
+ | **BrowserManager** | Anti-detect browser with fingerprint rotation |
215
+ | **Login** | QR code + phone number authentication |
216
+ | **ChatProcessor** | Fetch chats, handle unread status, click navigation |
217
+ | **MessageProcessor** | Extract messages, deduplicate, filter, store |
218
+ | **SQLITE_DB** | Async queue-powered storage with batch inserts |
219
+ | **WebSelectorConfig** | Platform-specific DOM selectors |
220
+
221
+ ---
222
+
223
+ ## 🛠️ How It Works
224
+
225
+ ### Message Processing Flow
226
+
227
+ ```
228
+ 1. ChatProcessor.Fetcher() → yields Chat objects
229
+ 2. MessageProcessor.Fetcher(chat) → clicks chat, extracts messages
230
+ 3. Messages wrapped as whatsapp_message dataclass
231
+ 4. New messages enqueued to SQLITE_DB async queue
232
+ 5. Background writer batches inserts every N seconds
233
+ ```
234
+
235
+ ### Anti-Detection Stack
236
+
237
+ ```
238
+ Playwright (base) → Camoufox (fingerprint) → BrowserForge (realistic profiles)
239
+ ```
240
+
241
+ ---
242
+
243
+ ## 🤝 Contributing
244
+
245
+ We welcome contributions! **Vibe coding accepted** — if it works and is clean, we'll merge it.
246
+
247
+ ### Contribution Rules
248
+
249
+ 1. **Fork → Branch → PR** workflow required
250
+ 2. **AI-Assisted code is welcome** — just mention it in your PR description for transparency
251
+ 3. **Tests required** for new features (we maintain >90% coverage on core modules)
252
+ 4. **Type hints required** — we use `mypy` for static analysis
253
+
254
+ ### Quick Start for Contributors
255
+
256
+ ```bash
257
+ # Clone and setup
258
+ git clone https://github.com/BITS-Rohit/tweakio-sdk.git
259
+ cd tweakio-sdk
260
+ python -m venv .venv && source .venv/bin/activate
261
+ pip install -e ".[dev]"
262
+
263
+ # Run tests
264
+ pytest --cov=src
265
+
266
+ # Your feature branch
267
+ git checkout -b feature/your-feature
268
+ ```
269
+
270
+ ### PR Template
271
+
272
+ ```markdown
273
+ ## What does this PR do?
274
+ [Description]
275
+
276
+ ## AI Disclosure
277
+ - [ ] This PR includes AI-generated code (Claude/GPT/Copilot)
278
+ - [ ] This PR is fully human-written
279
+
280
+ ## Testing
281
+ - [ ] Added/updated tests
282
+ - [ ] All tests pass locally
283
+ ```
284
+
285
+ ---
286
+
287
+ ## 🗺️ Roadmap
288
+
289
+ ### v0.1.6 — Core Infrastructure
290
+ - [ ] Custom Logger improvements
291
+ - [ ] Multi-Account Handling
292
+ - [ ] BrowserManager enhancements
293
+ - [ ] Dependency Injection & Interface renewal
294
+ - [ ] Directory structure improvements
295
+ - [ ] Separate Browser Logging
296
+
297
+ ### v0.1.7 — Security & Stability
298
+ - [ ] Encryption & Decryption module
299
+ - [ ] KeyBox integration
300
+ - [ ] Stability & Decryptor additions
301
+ - [ ] Stability increase → 60-70% reliability
302
+
303
+ ### v0.1.8 — Quality Assurance
304
+ - [ ] Test coverage increase & logic improvements
305
+ - [ ] Web-UI tinkering & refinements
306
+
307
+ ### v0.2.0 — Multi-Platform (Coming Soon)
308
+ - [ ] Another Platform integration (Telegram/Instagram)
309
+ - [ ] Platform-agnostic architecture
310
+
311
+ ---
312
+
313
+ ## ❓ FAQ
314
+
315
+ **Q: Will I get banned?**
316
+ A: Tweakio uses Camoufox anti-detection. With reasonable rate limiting, bans are rare. Always test on disposable accounts first.
317
+
318
+ **Q: Can I use this for spam?**
319
+ A: No. This SDK is for legitimate automation (customer support, archiving, notifications). Spam violates WhatsApp ToS and is not supported.
320
+
321
+ **Q: Why not just use the WhatsApp Business API?**
322
+ A: Business API has message template restrictions and approval processes. Tweakio is for developers who need full control.
323
+
324
+ ---
325
+
326
+ ## 📄 License
327
+
328
+ MIT License — see [LICENSE](LICENSE)
329
+
330
+ ---
331
+
332
+ ## 🔗 Links
333
+
334
+ - **PyPI**: [pypi.org/project/tweakio-sdk](https://pypi.org/project/tweakio-sdk/)
335
+ - **GitHub**: [github.com/BITS-Rohit/tweakio-sdk](https://github.com/BITS-Rohit/tweakio-sdk)
336
+ - **Issues**: [Report bugs](https://github.com/BITS-Rohit/tweakio-sdk/issues)
337
+
338
+ ---
339
+
340
+ **Keywords**: tweakio, tweakio-sdk, whatsapp automation, whatsapp bot python, whatsapp api, web automation, playwright, browser automation, chatbot, messaging, anti-detection, camoufox
341
+
342
+ _Built with ❤️ by BITS-Rohit and the Tweakio community_