astra-engine 0.0.1b1__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.
- astra_engine-0.0.1b1/ERROR_CODES.md +153 -0
- astra_engine-0.0.1b1/LICENSE +201 -0
- astra_engine-0.0.1b1/MANIFEST.in +30 -0
- astra_engine-0.0.1b1/PKG-INFO +179 -0
- astra_engine-0.0.1b1/README.md +135 -0
- astra_engine-0.0.1b1/astra/__init__.py +16 -0
- astra_engine-0.0.1b1/astra/client/__init__.py +12 -0
- astra_engine-0.0.1b1/astra/client/authenticator.py +256 -0
- astra_engine-0.0.1b1/astra/client/client.py +661 -0
- astra_engine-0.0.1b1/astra/client/conversation.py +95 -0
- astra_engine-0.0.1b1/astra/client/lifecycle.py +49 -0
- astra_engine-0.0.1b1/astra/client/methods/__init__.py +0 -0
- astra_engine-0.0.1b1/astra/client/methods/account.py +140 -0
- astra_engine-0.0.1b1/astra/client/methods/chat.py +183 -0
- astra_engine-0.0.1b1/astra/client/methods/group.py +112 -0
- astra_engine-0.0.1b1/astra/client/methods/media.py +69 -0
- astra_engine-0.0.1b1/astra/client/session_store.py +279 -0
- astra_engine-0.0.1b1/astra/client/sync_engine.py +538 -0
- astra_engine-0.0.1b1/astra/connection/__init__.py +12 -0
- astra_engine-0.0.1b1/astra/connection/browser_manager.py +318 -0
- astra_engine-0.0.1b1/astra/connection/page_controller.py +68 -0
- astra_engine-0.0.1b1/astra/connection/reconnect_policy.py +65 -0
- astra_engine-0.0.1b1/astra/constants.py +48 -0
- astra_engine-0.0.1b1/astra/core/bridge/account.py +251 -0
- astra_engine-0.0.1b1/astra/core/bridge/base.py +948 -0
- astra_engine-0.0.1b1/astra/core/bridge/chat.py +536 -0
- astra_engine-0.0.1b1/astra/core/bridge/contact.py +120 -0
- astra_engine-0.0.1b1/astra/core/bridge/diagnostic.py +43 -0
- astra_engine-0.0.1b1/astra/core/bridge/dom.py +91 -0
- astra_engine-0.0.1b1/astra/core/bridge/firefox_dom.py +149 -0
- astra_engine-0.0.1b1/astra/core/bridge/group.py +267 -0
- astra_engine-0.0.1b1/astra/core/bridge/idb_cache.py +211 -0
- astra_engine-0.0.1b1/astra/core/bridge/media.py +391 -0
- astra_engine-0.0.1b1/astra/core/bridge/privacy.py +228 -0
- astra_engine-0.0.1b1/astra/core/bridge/profile_bridge.py +102 -0
- astra_engine-0.0.1b1/astra/core/bridge/status.py +175 -0
- astra_engine-0.0.1b1/astra/errors/__init__.py +119 -0
- astra_engine-0.0.1b1/astra/errors/base.py +94 -0
- astra_engine-0.0.1b1/astra/errors/codes.py +503 -0
- astra_engine-0.0.1b1/astra/errors/exceptions.py +340 -0
- astra_engine-0.0.1b1/astra/errors/validation_errors.py +10 -0
- astra_engine-0.0.1b1/astra/events/__init__.py +15 -0
- astra_engine-0.0.1b1/astra/events/context.py +149 -0
- astra_engine-0.0.1b1/astra/events/dispatcher.py +213 -0
- astra_engine-0.0.1b1/astra/events/emitter.py +116 -0
- astra_engine-0.0.1b1/astra/events/filters.py +234 -0
- astra_engine-0.0.1b1/astra/models/__init__.py +24 -0
- astra_engine-0.0.1b1/astra/models/chat.py +100 -0
- astra_engine-0.0.1b1/astra/models/enums.py +77 -0
- astra_engine-0.0.1b1/astra/models/message.py +181 -0
- astra_engine-0.0.1b1/astra/models/user.py +108 -0
- astra_engine-0.0.1b1/astra/protocol/__init__.py +13 -0
- astra_engine-0.0.1b1/astra/protocol/actions.py +204 -0
- astra_engine-0.0.1b1/astra/protocol/gateway.py +238 -0
- astra_engine-0.0.1b1/astra/protocol/js_engine.py +138 -0
- astra_engine-0.0.1b1/astra/protocol/serializers.py +56 -0
- astra_engine-0.0.1b1/astra/protocol/validators.py +29 -0
- astra_engine-0.0.1b1/astra/py.typed +0 -0
- astra_engine-0.0.1b1/astra/tasks/__init__.py +0 -0
- astra_engine-0.0.1b1/astra/tasks/scheduler.py +40 -0
- astra_engine-0.0.1b1/astra/tasks/supervisor.py +103 -0
- astra_engine-0.0.1b1/astra/utils/__init__.py +14 -0
- astra_engine-0.0.1b1/astra/utils/health.py +42 -0
- astra_engine-0.0.1b1/astra/utils/media.py +62 -0
- astra_engine-0.0.1b1/astra/utils/retry.py +42 -0
- astra_engine-0.0.1b1/astra/utils/retry_handler.py +47 -0
- astra_engine-0.0.1b1/astra/utils/task_supervisor.py +58 -0
- astra_engine-0.0.1b1/astra_engine.egg-info/PKG-INFO +179 -0
- astra_engine-0.0.1b1/astra_engine.egg-info/SOURCES.txt +110 -0
- astra_engine-0.0.1b1/astra_engine.egg-info/dependency_links.txt +1 -0
- astra_engine-0.0.1b1/astra_engine.egg-info/requires.txt +14 -0
- astra_engine-0.0.1b1/astra_engine.egg-info/top_level.txt +1 -0
- astra_engine-0.0.1b1/docs/source/_static/AstraClient.png +0 -0
- astra_engine-0.0.1b1/docs/source/api_reference/client.rst +40 -0
- astra_engine-0.0.1b1/docs/source/api_reference/connection.rst +38 -0
- astra_engine-0.0.1b1/docs/source/api_reference/errors.rst +34 -0
- astra_engine-0.0.1b1/docs/source/api_reference/events.rst +41 -0
- astra_engine-0.0.1b1/docs/source/api_reference/index.rst +17 -0
- astra_engine-0.0.1b1/docs/source/api_reference/models.rst +41 -0
- astra_engine-0.0.1b1/docs/source/api_reference/protocol.rst +37 -0
- astra_engine-0.0.1b1/docs/source/api_reference/utils.rst +72 -0
- astra_engine-0.0.1b1/docs/source/author.rst +35 -0
- astra_engine-0.0.1b1/docs/source/commands_and_handlers.rst +135 -0
- astra_engine-0.0.1b1/docs/source/conf.py +56 -0
- astra_engine-0.0.1b1/docs/source/core_concepts.rst +146 -0
- astra_engine-0.0.1b1/docs/source/deployment.rst +108 -0
- astra_engine-0.0.1b1/docs/source/design_and_architecture.rst +142 -0
- astra_engine-0.0.1b1/docs/source/developer_guide.rst +94 -0
- astra_engine-0.0.1b1/docs/source/error_codes.rst +219 -0
- astra_engine-0.0.1b1/docs/source/event_system.rst +106 -0
- astra_engine-0.0.1b1/docs/source/examples.rst +133 -0
- astra_engine-0.0.1b1/docs/source/faq.rst +47 -0
- astra_engine-0.0.1b1/docs/source/filters.rst +119 -0
- astra_engine-0.0.1b1/docs/source/index.rst +94 -0
- astra_engine-0.0.1b1/docs/source/installation.rst +110 -0
- astra_engine-0.0.1b1/docs/source/license.rst +25 -0
- astra_engine-0.0.1b1/docs/source/migration.rst +62 -0
- astra_engine-0.0.1b1/docs/source/performance.rst +76 -0
- astra_engine-0.0.1b1/docs/source/quickstart.rst +106 -0
- astra_engine-0.0.1b1/docs/source/readthedocs.rst +44 -0
- astra_engine-0.0.1b1/docs/source/security.rst +66 -0
- astra_engine-0.0.1b1/docs/source/testing.rst +84 -0
- astra_engine-0.0.1b1/docs/source/usage.rst +212 -0
- astra_engine-0.0.1b1/examples/background_example.py +21 -0
- astra_engine-0.0.1b1/examples/command_example.py +29 -0
- astra_engine-0.0.1b1/examples/detailed_example.py +28 -0
- astra_engine-0.0.1b1/examples/echo_example.py +17 -0
- astra_engine-0.0.1b1/examples/group_example.py +27 -0
- astra_engine-0.0.1b1/examples/media_example.py +33 -0
- astra_engine-0.0.1b1/pyproject.toml +96 -0
- astra_engine-0.0.1b1/requirements.txt +4 -0
- astra_engine-0.0.1b1/setup.cfg +4 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Astra Error Codes Reference
|
|
2
|
+
|
|
3
|
+
Every error in Astra carries a structured code, a human-readable message, and a recovery hint. Catch specific exceptions to handle failures gracefully.
|
|
4
|
+
|
|
5
|
+
## Quick Example
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from astra.errors import MessageSendError, RateLimitedError
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
await client.chat.send_message(jid, text)
|
|
12
|
+
except RateLimitedError as e:
|
|
13
|
+
print(f"{e.code}: {e.hint}") # E8001: You are sending too many requests...
|
|
14
|
+
if e.retryable:
|
|
15
|
+
await asyncio.sleep(60)
|
|
16
|
+
except MessageSendError as e:
|
|
17
|
+
print(e) # [E3001] Failed to send message to ...
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## E1xxx — Authentication
|
|
23
|
+
|
|
24
|
+
| Code | Exception | Description | Retryable |
|
|
25
|
+
|------|-----------|-------------|-----------|
|
|
26
|
+
| E1001 | `LoginFailedError` | Authentication failed | ✅ |
|
|
27
|
+
| E1002 | `QRTimeoutError` | QR code scan timed out | ✅ |
|
|
28
|
+
| E1003 | `PairingError` | Phone pairing failed | ✅ |
|
|
29
|
+
| E1004 | `SessionExpiredError` | Session has expired | ✅ |
|
|
30
|
+
| E1005 | `AuthRateLimitError` | Too many login attempts | ❌ |
|
|
31
|
+
| E1006 | `PhoneDisconnectedError` | Primary phone lost connection | ✅ |
|
|
32
|
+
|
|
33
|
+
## E2xxx — Connection & Browser
|
|
34
|
+
|
|
35
|
+
| Code | Exception | Description | Retryable |
|
|
36
|
+
|------|-----------|-------------|-----------|
|
|
37
|
+
| E2001 | `BrowserStartError` | Failed to launch browser | ❌ |
|
|
38
|
+
| E2002 | `BrowserCrashError` | Browser process crashed | ✅ |
|
|
39
|
+
| E2003 | `BrowserLimitError` | Another instance using this session | ❌ |
|
|
40
|
+
| E2004 | `PageUnresponsiveError` | Browser page frozen | ✅ |
|
|
41
|
+
| E2005 | `ConnectionLostError` | Lost connection to browser | ✅ |
|
|
42
|
+
| E2006 | `WebSocketDisconnectError` | WS connection to WA dropped | ✅ |
|
|
43
|
+
| E2007 | `NavigationError` | Failed to navigate to WA Web | ✅ |
|
|
44
|
+
| E2008 | `StartupError` | Client startup failed | ✅ |
|
|
45
|
+
|
|
46
|
+
## E3xxx — Messaging & Chat
|
|
47
|
+
|
|
48
|
+
| Code | Exception | Description | Retryable |
|
|
49
|
+
|------|-----------|-------------|-----------|
|
|
50
|
+
| E3001 | `MessageSendError` | Message failed to send | ✅ |
|
|
51
|
+
| E3002 | `MessageTimeoutError` | Message send timed out | ✅ |
|
|
52
|
+
| E3003 | `InvalidRecipientError` | Invalid recipient JID | ❌ |
|
|
53
|
+
| E3004 | `MediaUploadError` | Media upload failed | ✅ |
|
|
54
|
+
| E3005 | `MediaDownloadError` | Media download failed | ✅ |
|
|
55
|
+
| E3006 | `MessageEditError` | Failed to edit message | ❌ |
|
|
56
|
+
| E3007 | `MessageDeleteError` | Failed to delete message | ❌ |
|
|
57
|
+
| E3008 | `ReactionError` | Failed to react | ❌ |
|
|
58
|
+
| E3010 | `PollError` | Failed to create poll | ❌ |
|
|
59
|
+
| E3011 | `PollVoteError` | Failed to vote on poll | ❌ |
|
|
60
|
+
| E3012 | — | Failed to forward message | ❌ |
|
|
61
|
+
| E3020 | `ChatNotFoundError` | Chat not found | ❌ |
|
|
62
|
+
| E3021 | `ChatOperationError` | Archive/unarchive failed | ❌ |
|
|
63
|
+
| E3022 | `ChatOperationError` | Mute/unmute failed | ❌ |
|
|
64
|
+
| E3023 | `ChatOperationError` | Pin/unpin failed | ❌ |
|
|
65
|
+
| E3024 | — | Mark as seen failed | ❌ |
|
|
66
|
+
| E3025 | `SyncError` | Chat history sync failed | ✅ |
|
|
67
|
+
|
|
68
|
+
## E4xxx — Groups
|
|
69
|
+
|
|
70
|
+
| Code | Exception | Description | Retryable |
|
|
71
|
+
|------|-----------|-------------|-----------|
|
|
72
|
+
| E4001 | `GroupCreateError` | Failed to create group | ❌ |
|
|
73
|
+
| E4002 | `GroupMemberError` | Failed to add member(s) | ❌ |
|
|
74
|
+
| E4003 | `GroupMemberError` | Failed to remove member(s) | ❌ |
|
|
75
|
+
| E4004 | — | Failed to promote to admin | ❌ |
|
|
76
|
+
| E4005 | — | Failed to demote admin | ❌ |
|
|
77
|
+
| E4006 | `GroupJoinError` | Failed to join via invite | ❌ |
|
|
78
|
+
| E4007 | `GroupInfoError` | Failed to get group info | ❌ |
|
|
79
|
+
| E4008 | — | Failed to leave group | ✅ |
|
|
80
|
+
| E4010 | `GroupSettingsError` | Failed to update settings | ❌ |
|
|
81
|
+
| E4020 | `GroupPermissionError` | Permission denied | ❌ |
|
|
82
|
+
|
|
83
|
+
## E5xxx — Account & Profile
|
|
84
|
+
|
|
85
|
+
| Code | Exception | Description | Retryable |
|
|
86
|
+
|------|-----------|-------------|-----------|
|
|
87
|
+
| E5001 | `ProfileReadError` | Failed to read profile | ✅ |
|
|
88
|
+
| E5002 | `ProfileUpdateError` | Failed to update profile | ❌ |
|
|
89
|
+
| E5010 | `StatusPostError` | Failed to post status | ✅ |
|
|
90
|
+
| E5011 | — | Failed to post media status | ✅ |
|
|
91
|
+
| E5020 | `PrivacyError` | Failed to update privacy | ✅ |
|
|
92
|
+
| E5030 | `BlockError` | Failed to block/unblock | ❌ |
|
|
93
|
+
| E5040 | — | Failed to get/set profile pic | ❌ |
|
|
94
|
+
| E5050 | — | Logout failed | ❌ |
|
|
95
|
+
|
|
96
|
+
## E6xxx — Bridge & Engine
|
|
97
|
+
|
|
98
|
+
| Code | Exception | Description | Retryable |
|
|
99
|
+
|------|-----------|-------------|-----------|
|
|
100
|
+
| E6001 | `BridgeMethodNotFoundError` | JS method not found | ❌ |
|
|
101
|
+
| E6002 | `BridgeCallError` | Bridge call failed | ✅ |
|
|
102
|
+
| E6003 | — | JS evaluation failed | ✅ |
|
|
103
|
+
| E6004 | — | Bridge not connected | ✅ |
|
|
104
|
+
| E6005 | `EngineStallError` | Engine stall detected | ✅ |
|
|
105
|
+
| E6006 | `ModuleMissingError` | Required WA module missing | ❌ |
|
|
106
|
+
| E6007 | — | Script injection failed | ✅ |
|
|
107
|
+
| E6008 | — | WA Store unavailable | ✅ |
|
|
108
|
+
|
|
109
|
+
## E7xxx — Validation
|
|
110
|
+
|
|
111
|
+
| Code | Exception | Description | Retryable |
|
|
112
|
+
|------|-----------|-------------|-----------|
|
|
113
|
+
| E7001 | `InvalidJIDError` | Invalid JID format | ❌ |
|
|
114
|
+
| E7002 | — | Empty text content | ❌ |
|
|
115
|
+
| E7003 | `InvalidInputError` | Missing required params | ❌ |
|
|
116
|
+
| E7004 | `InvalidPhoneError` | Invalid phone number | ❌ |
|
|
117
|
+
| E7005 | — | Invalid media input | ❌ |
|
|
118
|
+
| E7006 | — | Payload too large | ❌ |
|
|
119
|
+
|
|
120
|
+
## E8xxx — WhatsApp-Side
|
|
121
|
+
|
|
122
|
+
| Code | Exception | Description | Retryable |
|
|
123
|
+
|------|-----------|-------------|-----------|
|
|
124
|
+
| E8001 | `RateLimitedError` | Rate limited by WA | ✅ |
|
|
125
|
+
| E8002 | `EcosystemBlockError` | Blocked for ecosystem protection | ❌ |
|
|
126
|
+
| E8003 | `AccountBannedError` | Account banned | ❌ |
|
|
127
|
+
| E8004 | `WAServerError` | WA servers down | ✅ |
|
|
128
|
+
| E8005 | `VersionMismatchError` | WA Web version mismatch | ✅ |
|
|
129
|
+
| E8006 | `MultiDeviceLimitError` | Max linked devices reached | ❌ |
|
|
130
|
+
| E8007 | — | Encryption error | ✅ |
|
|
131
|
+
| E8008 | — | Contact not on WhatsApp | ❌ |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Error Inheritance
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Exception
|
|
139
|
+
└── AstraError (base — has .code, .hint, .retryable, .severity, .to_dict())
|
|
140
|
+
├── LoginFailedError (E1001)
|
|
141
|
+
├── QRTimeoutError (E1002)
|
|
142
|
+
├── PairingError (E1003)
|
|
143
|
+
├── ...
|
|
144
|
+
├── MessageSendError (E3001)
|
|
145
|
+
├── PollError (E3010)
|
|
146
|
+
├── GroupCreateError (E4001)
|
|
147
|
+
├── BridgeCallError (E6002)
|
|
148
|
+
├── InvalidInputError (E7xxx)
|
|
149
|
+
│ ├── InvalidJIDError (E7001)
|
|
150
|
+
│ └── InvalidPhoneError (E7004)
|
|
151
|
+
├── RateLimitedError (E8001)
|
|
152
|
+
└── AccountBannedError (E8003)
|
|
153
|
+
```
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019 Pedro S Lopez
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Include in source distribution
|
|
2
|
+
include LICENSE
|
|
3
|
+
include README.md
|
|
4
|
+
include ERROR_CODES.md
|
|
5
|
+
include requirements.txt
|
|
6
|
+
include pyproject.toml
|
|
7
|
+
|
|
8
|
+
# Include documentation source and static assets
|
|
9
|
+
recursive-include docs/source *.rst *.py *.png *.jpg *.jpeg *.svg
|
|
10
|
+
recursive-include docs/source/_static *
|
|
11
|
+
|
|
12
|
+
# Include examples
|
|
13
|
+
recursive-include examples *.py
|
|
14
|
+
|
|
15
|
+
# Include type stub marker
|
|
16
|
+
include astra/py.typed
|
|
17
|
+
|
|
18
|
+
# Exclude development / draft directories
|
|
19
|
+
prune corastra
|
|
20
|
+
prune nnew
|
|
21
|
+
prune x
|
|
22
|
+
prune wwaa
|
|
23
|
+
prune docs/_build
|
|
24
|
+
prune .astra_sessions
|
|
25
|
+
prune plugins
|
|
26
|
+
|
|
27
|
+
# Exclude caches
|
|
28
|
+
global-exclude __pycache__
|
|
29
|
+
global-exclude *.py[cod]
|
|
30
|
+
global-exclude .DS_Store
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: astra-engine
|
|
3
|
+
Version: 0.0.1b1
|
|
4
|
+
Summary: A professional, high-performance WhatsApp Web automation library for Python.
|
|
5
|
+
Author: Aman Kumar Pandey
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/paman7647/Astra
|
|
8
|
+
Project-URL: Documentation, https://astra-engine.readthedocs.io
|
|
9
|
+
Project-URL: Source, https://github.com/paman7647/Astra
|
|
10
|
+
Project-URL: Issues, https://github.com/paman7647/Astra/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/paman7647/Astra/blob/dev/CHANGELOG.md
|
|
12
|
+
Keywords: whatsapp,whatsapp-web,automation,bot,playwright,async,messaging,chat
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Communications :: Chat
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Framework :: AsyncIO
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: playwright>=1.40.0
|
|
31
|
+
Requires-Dist: qrcode>=7.4
|
|
32
|
+
Requires-Dist: Pillow>=10.0
|
|
33
|
+
Requires-Dist: requests>=2.31
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
37
|
+
Requires-Dist: sphinx>=7.0; extra == "dev"
|
|
38
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
41
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
42
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
<div align="center">
|
|
46
|
+
|
|
47
|
+
<img src="AstraClient.png" alt="Astra Engine Logo" width="600" />
|
|
48
|
+
|
|
49
|
+
# Astra Engine
|
|
50
|
+
|
|
51
|
+
**The Professional WhatsApp Web Automation Library for Python**
|
|
52
|
+
|
|
53
|
+
[](https://www.python.org/)
|
|
54
|
+
[](LICENSE)
|
|
55
|
+
[](https://www.python.org/)
|
|
56
|
+
[](https://astra-engine.readthedocs.io/)
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
Astra Engine is a Python library that lets you automate WhatsApp Web. It uses Playwright to run a real browser instance, which means it works exactly like a real user. No hidden APIs, no ban risks from modified protocols—just meaningful automation.
|
|
63
|
+
|
|
64
|
+
We built this because existing libraries were either too slow, too brittle, or abandoned. Astra is designed to be the tool we wanted to use ourselves: **written from scratch**, typed, documented, and reliable.
|
|
65
|
+
|
|
66
|
+
## ⚡ What makes it different?
|
|
67
|
+
|
|
68
|
+
* **It's a Real Browser**: We don't try to reverse-engineer the encrypted WebSocket protocol. We drive the official WhatsApp Web client, so if it works in Chrome, it works in Astra.
|
|
69
|
+
* **Privacy Focused**: The engine automatically strips telemetry and tracking metrics. Your bot looks just like a normal user to WhatsApp's servers.
|
|
70
|
+
* **Developer Friendly**: Full type hints, proper documentation, and sensible error messages. You won't have to guess what methods do.
|
|
71
|
+
* **Stays Connected**: The connection manager handles QR code refreshes, internet dropouts, and browser crashes without you needing to write retry loops.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 🚀 Features
|
|
76
|
+
|
|
77
|
+
| Feature | Status | Notes |
|
|
78
|
+
| :--- | :---: | :--- |
|
|
79
|
+
| **Multi-Device** | ✅ | Works with the latest MD (Multi-Device) beta and stable. |
|
|
80
|
+
| **Messaging** | ✅ | Send text, reply to messages, mention users, edit sent messages. |
|
|
81
|
+
| **Media** | ✅ | Send and receive Images, Videos, Audio, Documents, and Stickers. |
|
|
82
|
+
| **Interaction** | ✅ | Create Polls, react to messages with emojis, delete messages. |
|
|
83
|
+
| **Groups** | ✅ | Extensive admin controls: promote/demote, change settings, manage participants. |
|
|
84
|
+
| **Privacy** | ✅ | Detailed control over who sees your profile, status, and last seen. |
|
|
85
|
+
| **Events** | ✅ | Real-time event loop to listen for new messages, status updates, and more. |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📦 Installation
|
|
90
|
+
|
|
91
|
+
You need Python 3.9 or newer.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1. Install Astra Engine
|
|
95
|
+
pip install astra-engine
|
|
96
|
+
|
|
97
|
+
# 2. Install the browser binaries (Chromium)
|
|
98
|
+
python -m playwright install chromium
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 🛠️ Quick Start
|
|
104
|
+
|
|
105
|
+
Here is the shortest way to get a bot running. This will print a QR code in your terminal—scan it with WhatsApp on your phone to log in.
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import asyncio
|
|
109
|
+
from astra import Client, Filters
|
|
110
|
+
|
|
111
|
+
async def main():
|
|
112
|
+
# session_id saves your login so you don't have to scan every time
|
|
113
|
+
async with Client(session_id="my_bot") as client:
|
|
114
|
+
|
|
115
|
+
# Respond to "!ping"
|
|
116
|
+
@client.on_message(Filters.command("ping"))
|
|
117
|
+
async def ping(msg):
|
|
118
|
+
await msg.respond("Pong! 🚀")
|
|
119
|
+
|
|
120
|
+
# React to any message containing "hello"
|
|
121
|
+
@client.on_message(Filters.text_contains("hello"))
|
|
122
|
+
async def greet(msg):
|
|
123
|
+
await msg.react("👋")
|
|
124
|
+
|
|
125
|
+
print("Bot is running... Press Ctrl+C to stop.")
|
|
126
|
+
await client.run_forever()
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
asyncio.run(main())
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
👉 **[Check out the examples folder](examples/)** for more scripts like Group Management, Media Sending, and Background Tasks.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 🤝 Want to Contribute?
|
|
137
|
+
|
|
138
|
+
We'd love your help! Astra is an open project. Whether you want to fix a bug, add a new feature, or just improve the docs, here is how you can get started.
|
|
139
|
+
|
|
140
|
+
1. **Fork the repo** on GitHub.
|
|
141
|
+
2. **Clone it** to your machine.
|
|
142
|
+
3. **Set up your environment**:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Create a virtual environment
|
|
146
|
+
python -m venv .venv
|
|
147
|
+
source .venv/bin/activate # or .venv\Scripts\activate on Windows
|
|
148
|
+
|
|
149
|
+
# Install in editable mode with dev dependencies
|
|
150
|
+
pip install -e ".[dev]"
|
|
151
|
+
python -m playwright install chromium
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
4. **Make your changes**.
|
|
155
|
+
5. **Run the checks** to make sure everything is clean:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# format code
|
|
159
|
+
ruff check . --fix
|
|
160
|
+
|
|
161
|
+
# check types
|
|
162
|
+
mypy astra
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
6. **Submit a Pull Request**! We'll review it and get it merged.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## ⚖️ Disclaimer
|
|
170
|
+
|
|
171
|
+
This project is **not** affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://www.whatsapp.com.
|
|
172
|
+
|
|
173
|
+
**This software is for educational purposes only.** Automating user accounts may violate WhatsApp's Terms of Service. Use it responsibly and at your own risk.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
<div align="center">
|
|
178
|
+
<sub>Built with ❤️ by Aman Kumar Pandey</sub>
|
|
179
|
+
</div>
|