eitaagram-py 0.1.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.
Files changed (51) hide show
  1. eitaagram_py-0.1.0/LICENSE +21 -0
  2. eitaagram_py-0.1.0/NOTICE.md +8 -0
  3. eitaagram_py-0.1.0/PKG-INFO +115 -0
  4. eitaagram_py-0.1.0/README.md +96 -0
  5. eitaagram_py-0.1.0/pyproject.toml +26 -0
  6. eitaagram_py-0.1.0/setup.cfg +4 -0
  7. eitaagram_py-0.1.0/src/eitaagram/__init__.py +46 -0
  8. eitaagram_py-0.1.0/src/eitaagram/__main__.py +116 -0
  9. eitaagram_py-0.1.0/src/eitaagram/client.py +371 -0
  10. eitaagram_py-0.1.0/src/eitaagram/data/eitaa-schema.json +1 -0
  11. eitaagram_py-0.1.0/src/eitaagram/dispatcher.py +127 -0
  12. eitaagram_py-0.1.0/src/eitaagram/errors.py +375 -0
  13. eitaagram_py-0.1.0/src/eitaagram/filters.py +167 -0
  14. eitaagram_py-0.1.0/src/eitaagram/methods/__init__.py +7 -0
  15. eitaagram_py-0.1.0/src/eitaagram/methods/account.py +36 -0
  16. eitaagram_py-0.1.0/src/eitaagram/methods/auth.py +189 -0
  17. eitaagram_py-0.1.0/src/eitaagram/methods/chats.py +140 -0
  18. eitaagram_py-0.1.0/src/eitaagram/methods/files.py +256 -0
  19. eitaagram_py-0.1.0/src/eitaagram/methods/messages.py +294 -0
  20. eitaagram_py-0.1.0/src/eitaagram/parsing.py +80 -0
  21. eitaagram_py-0.1.0/src/eitaagram/peers.py +138 -0
  22. eitaagram_py-0.1.0/src/eitaagram/pool.py +471 -0
  23. eitaagram_py-0.1.0/src/eitaagram/profile.py +105 -0
  24. eitaagram_py-0.1.0/src/eitaagram/py.typed +0 -0
  25. eitaagram_py-0.1.0/src/eitaagram/ratelimit.py +35 -0
  26. eitaagram_py-0.1.0/src/eitaagram/rpc.py +228 -0
  27. eitaagram_py-0.1.0/src/eitaagram/session/__init__.py +18 -0
  28. eitaagram_py-0.1.0/src/eitaagram/session/base.py +186 -0
  29. eitaagram_py-0.1.0/src/eitaagram/session/crypto.py +26 -0
  30. eitaagram_py-0.1.0/src/eitaagram/session/file.py +60 -0
  31. eitaagram_py-0.1.0/src/eitaagram/session/memory.py +22 -0
  32. eitaagram_py-0.1.0/src/eitaagram/session/sqlite.py +112 -0
  33. eitaagram_py-0.1.0/src/eitaagram/session/string.py +55 -0
  34. eitaagram_py-0.1.0/src/eitaagram/tl/__init__.py +4 -0
  35. eitaagram_py-0.1.0/src/eitaagram/tl/codec.py +377 -0
  36. eitaagram_py-0.1.0/src/eitaagram/tl/schema.py +127 -0
  37. eitaagram_py-0.1.0/src/eitaagram/transport.py +154 -0
  38. eitaagram_py-0.1.0/src/eitaagram/types.py +311 -0
  39. eitaagram_py-0.1.0/src/eitaagram/updates.py +244 -0
  40. eitaagram_py-0.1.0/src/eitaagram/utils.py +73 -0
  41. eitaagram_py-0.1.0/src/eitaagram_py.egg-info/PKG-INFO +115 -0
  42. eitaagram_py-0.1.0/src/eitaagram_py.egg-info/SOURCES.txt +49 -0
  43. eitaagram_py-0.1.0/src/eitaagram_py.egg-info/dependency_links.txt +1 -0
  44. eitaagram_py-0.1.0/src/eitaagram_py.egg-info/requires.txt +10 -0
  45. eitaagram_py-0.1.0/src/eitaagram_py.egg-info/top_level.txt +1 -0
  46. eitaagram_py-0.1.0/tests/test_client.py +279 -0
  47. eitaagram_py-0.1.0/tests/test_codec.py +132 -0
  48. eitaagram_py-0.1.0/tests/test_pool.py +199 -0
  49. eitaagram_py-0.1.0/tests/test_rpc.py +159 -0
  50. eitaagram_py-0.1.0/tests/test_transport_session.py +164 -0
  51. eitaagram_py-0.1.0/tests/test_updates.py +236 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 eitaagram authors
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,8 @@
1
+ # Third-party notices
2
+
3
+ * `src/eitaagram/data/eitaa-schema.json` is derived from the layer-135 TL schema
4
+ shipped with **eitaa-cli** (MIT) and merged with three constructors
5
+ (`botMenuButton`, `updateBotMenuButton`, `updateWebViewResultSent`) from
6
+ **eitaa-serializer-laravel** (MIT).
7
+ * **EitaaSharp** is GPL-3.0. No code or data was copied from it; it was read only
8
+ as protocol documentation (envelope layout, token-refresh and expiry behaviour).
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: eitaagram-py
3
+ Version: 0.1.0
4
+ Summary: Async, typed, multi-account Eitaa client library (Telethon/Pyrogram-style API).
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ License-File: NOTICE.md
10
+ Requires-Dist: httpx[http2]<1.0,>=0.27
11
+ Provides-Extra: crypto
12
+ Requires-Dist: cryptography>=42; extra == "crypto"
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8; extra == "dev"
15
+ Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
16
+ Requires-Dist: mypy>=1.11; extra == "dev"
17
+ Requires-Dist: ruff>=0.6; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+ # eitaagram
21
+
22
+ Async, typed, **multi-account** Eitaa client library for Python 3.11+ with a Telethon / Pyrogram-style API.
23
+ Built from the protocol knowledge in **eitaa-cli**, **eitaa-serializer-laravel** and **EitaaSharp** (see `NOTICE.md`).
24
+
25
+ > **Status: 0.1 – beta.** 74 offline tests pass against an in-process fake gateway that speaks the real binary
26
+ > protocol. It has **not** been run against the live Eitaa servers. Run `examples/smoke_test.py` on a throw-away
27
+ > account and `python -m eitaagram doctor` before using it on accounts you care about.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install -e . # needs httpx[http2]
33
+ pip install -e .[crypto] # optional: encrypted sessions (Fernet)
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ import asyncio
40
+ from eitaagram import Client, filters
41
+
42
+ async def main():
43
+ async with Client("alice", phone="+989121234567") as app: # asks for the code on first run
44
+ await app.send_message("me", "<b>hello</b>", parse_mode="html")
45
+
46
+ @app.on_message(filters.private & filters.command("ping"))
47
+ async def ping(client, message):
48
+ await message.reply("pong")
49
+
50
+ await app.idle()
51
+
52
+ asyncio.run(main())
53
+ ```
54
+
55
+ ## Many accounts (tabchi / self-bot farms)
56
+
57
+ ```bash
58
+ python -m eitaagram login --db accounts.db --name acc1 --phone +98912...
59
+ python -m eitaagram login --db accounts.db --name acc2 --phone +98935...
60
+ python -m eitaagram list --db accounts.db
61
+ ```
62
+
63
+ ```python
64
+ pool = AccountPool("accounts.db", global_rate=20, account_rate=3,
65
+ proxies={"acc2": "socks5://user:pass@host:1080"})
66
+ pool.load_stored()
67
+
68
+ @pool.on_message(filters.private & filters.incoming) # registered on every account
69
+ async def handler(client, message): ...
70
+
71
+ states = await pool.start() # one bad account never blocks the rest
72
+ results = await pool.map(lambda c: c.get_me(), concurrency=3) # errors come back per account
73
+ await pool.run()
74
+ ```
75
+
76
+ Pool features: per-account health state (`ready / flood / unauthorized / banned / error`), shared + per-account
77
+ rate limiting, FloodWait-aware fan-out (flooded accounts are skipped, not hammered), per-account proxy, pool-wide
78
+ handlers, listeners (`flood`, `unauthorized`, `token_refreshed`, `state`), `status()` snapshots without secrets,
79
+ session export/import as strings.
80
+
81
+ ## What is inside
82
+
83
+ | Area | Notes |
84
+ |---|---|
85
+ | TL codec | Schema-driven (layer 135, 1008 constructors / 431 methods), strict decoding, gzip/rpc_result unwrapping, verified against a golden fixture |
86
+ | RPC engine | Envelope handling, **single-flight token refresh**, FloodWait sleep/fail-fast with a per-method guard, backoff for transport/5xx, `INVALID_CONSTRUCTOR` learning |
87
+ | Transport | HTTP/2 via httpx, endpoint health + cooldown + failover, upload host pinning, per-account proxy |
88
+ | Sessions | `MemorySession`, `StringSession` (`eg1:` portable string), `FileSession` (atomic, 0600), `SQLiteSession` (many accounts per file), optional Fernet encryption |
89
+ | Updates | `getDifference` polling with persisted cursor, channel difference, de-duplication, handler groups, `StopPropagation` |
90
+ | API | auth (send/resend/sign-in/sign-up/guided `authorize`), messages (send/edit/delete/forward/history/search/read), chats (dialogs/join/leave/members), files (upload/download, beta), account |
91
+
92
+ Chat ids follow the Pyrogram convention: users `id`, basic groups `-id`, channels/supergroups `-1000000000000 - id`.
93
+ Raw access is always available: `await app.invoke("method.name", {...})`.
94
+
95
+ ## Known limitations (honest list)
96
+
97
+ * **Not validated live.** Wire details the reference projects disagree on (`layer` 133/135/137, envelope `flags`
98
+ 0/32/128, OTP delivery channel) are configurable through `ClientProfile`; `python -m eitaagram doctor` probes
99
+ which combination your server accepts.
100
+ * **Two-step verification (cloud password) is not implemented**; such accounts raise `SessionPasswordNeeded`.
101
+ * **Polling only** (no socket): updates arrive with `poll_interval` latency; typing indicators are unsupported.
102
+ * Channel gap recovery is best-effort when the local channel cursor is unknown.
103
+ * File upload/download follows the reference captures but is marked beta.
104
+ * Typed wrappers cover the common objects; everything else is available as raw dicts (`message.raw`).
105
+
106
+ ## Responsible use
107
+
108
+ Accounts keep one stable device identity each and the library obeys server waits. It ships no stealth or
109
+ anti-detection features; mass unsolicited messaging violates Eitaa's terms and can get accounts banned.
110
+
111
+ ## Development
112
+
113
+ ```bash
114
+ PYTHONPATH=src:tests python -m unittest discover -s tests # or: pytest
115
+ ```
@@ -0,0 +1,96 @@
1
+ # eitaagram
2
+
3
+ Async, typed, **multi-account** Eitaa client library for Python 3.11+ with a Telethon / Pyrogram-style API.
4
+ Built from the protocol knowledge in **eitaa-cli**, **eitaa-serializer-laravel** and **EitaaSharp** (see `NOTICE.md`).
5
+
6
+ > **Status: 0.1 – beta.** 74 offline tests pass against an in-process fake gateway that speaks the real binary
7
+ > protocol. It has **not** been run against the live Eitaa servers. Run `examples/smoke_test.py` on a throw-away
8
+ > account and `python -m eitaagram doctor` before using it on accounts you care about.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install -e . # needs httpx[http2]
14
+ pip install -e .[crypto] # optional: encrypted sessions (Fernet)
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```python
20
+ import asyncio
21
+ from eitaagram import Client, filters
22
+
23
+ async def main():
24
+ async with Client("alice", phone="+989121234567") as app: # asks for the code on first run
25
+ await app.send_message("me", "<b>hello</b>", parse_mode="html")
26
+
27
+ @app.on_message(filters.private & filters.command("ping"))
28
+ async def ping(client, message):
29
+ await message.reply("pong")
30
+
31
+ await app.idle()
32
+
33
+ asyncio.run(main())
34
+ ```
35
+
36
+ ## Many accounts (tabchi / self-bot farms)
37
+
38
+ ```bash
39
+ python -m eitaagram login --db accounts.db --name acc1 --phone +98912...
40
+ python -m eitaagram login --db accounts.db --name acc2 --phone +98935...
41
+ python -m eitaagram list --db accounts.db
42
+ ```
43
+
44
+ ```python
45
+ pool = AccountPool("accounts.db", global_rate=20, account_rate=3,
46
+ proxies={"acc2": "socks5://user:pass@host:1080"})
47
+ pool.load_stored()
48
+
49
+ @pool.on_message(filters.private & filters.incoming) # registered on every account
50
+ async def handler(client, message): ...
51
+
52
+ states = await pool.start() # one bad account never blocks the rest
53
+ results = await pool.map(lambda c: c.get_me(), concurrency=3) # errors come back per account
54
+ await pool.run()
55
+ ```
56
+
57
+ Pool features: per-account health state (`ready / flood / unauthorized / banned / error`), shared + per-account
58
+ rate limiting, FloodWait-aware fan-out (flooded accounts are skipped, not hammered), per-account proxy, pool-wide
59
+ handlers, listeners (`flood`, `unauthorized`, `token_refreshed`, `state`), `status()` snapshots without secrets,
60
+ session export/import as strings.
61
+
62
+ ## What is inside
63
+
64
+ | Area | Notes |
65
+ |---|---|
66
+ | TL codec | Schema-driven (layer 135, 1008 constructors / 431 methods), strict decoding, gzip/rpc_result unwrapping, verified against a golden fixture |
67
+ | RPC engine | Envelope handling, **single-flight token refresh**, FloodWait sleep/fail-fast with a per-method guard, backoff for transport/5xx, `INVALID_CONSTRUCTOR` learning |
68
+ | Transport | HTTP/2 via httpx, endpoint health + cooldown + failover, upload host pinning, per-account proxy |
69
+ | Sessions | `MemorySession`, `StringSession` (`eg1:` portable string), `FileSession` (atomic, 0600), `SQLiteSession` (many accounts per file), optional Fernet encryption |
70
+ | Updates | `getDifference` polling with persisted cursor, channel difference, de-duplication, handler groups, `StopPropagation` |
71
+ | API | auth (send/resend/sign-in/sign-up/guided `authorize`), messages (send/edit/delete/forward/history/search/read), chats (dialogs/join/leave/members), files (upload/download, beta), account |
72
+
73
+ Chat ids follow the Pyrogram convention: users `id`, basic groups `-id`, channels/supergroups `-1000000000000 - id`.
74
+ Raw access is always available: `await app.invoke("method.name", {...})`.
75
+
76
+ ## Known limitations (honest list)
77
+
78
+ * **Not validated live.** Wire details the reference projects disagree on (`layer` 133/135/137, envelope `flags`
79
+ 0/32/128, OTP delivery channel) are configurable through `ClientProfile`; `python -m eitaagram doctor` probes
80
+ which combination your server accepts.
81
+ * **Two-step verification (cloud password) is not implemented**; such accounts raise `SessionPasswordNeeded`.
82
+ * **Polling only** (no socket): updates arrive with `poll_interval` latency; typing indicators are unsupported.
83
+ * Channel gap recovery is best-effort when the local channel cursor is unknown.
84
+ * File upload/download follows the reference captures but is marked beta.
85
+ * Typed wrappers cover the common objects; everything else is available as raw dicts (`message.raw`).
86
+
87
+ ## Responsible use
88
+
89
+ Accounts keep one stable device identity each and the library obeys server waits. It ships no stealth or
90
+ anti-detection features; mass unsolicited messaging violates Eitaa's terms and can get accounts banned.
91
+
92
+ ## Development
93
+
94
+ ```bash
95
+ PYTHONPATH=src:tests python -m unittest discover -s tests # or: pytest
96
+ ```
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "eitaagram-py"
7
+ version = "0.1.0"
8
+ description = "Async, typed, multi-account Eitaa client library (Telethon/Pyrogram-style API)."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["httpx[http2]>=0.27,<1.0"]
13
+
14
+ [project.optional-dependencies]
15
+ crypto = ["cryptography>=42"]
16
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.11", "ruff>=0.6"]
17
+
18
+ [tool.setuptools.packages.find]
19
+ where = ["src"]
20
+
21
+ [tool.setuptools.package-data]
22
+ eitaagram = ["data/*.json", "py.typed"]
23
+
24
+ [tool.pytest.ini_options]
25
+ asyncio_mode = "auto"
26
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,46 @@
1
+ """eitaagram -- async, multi-account Eitaa client library."""
2
+
3
+ from . import filters
4
+ from .client import Client
5
+ from .dispatcher import ContinuePropagation, StopPropagation
6
+ from .errors import * # noqa: F401,F403 - the whole exception hierarchy is public API
7
+ from .errors import __all__ as _errors_all
8
+ from .pool import Account, AccountPool, AccountState
9
+ from .profile import ClientProfile
10
+ from .ratelimit import RateLimiter
11
+ from .session import (
12
+ FernetCipher,
13
+ FileSession,
14
+ MemorySession,
15
+ Session,
16
+ SQLiteSession,
17
+ StringSession,
18
+ )
19
+ from .types import Chat, DeletedMessages, Dialog, Message, SentCode, User
20
+
21
+ __version__ = "0.1.0"
22
+
23
+ __all__ = [
24
+ "Client",
25
+ "AccountPool",
26
+ "Account",
27
+ "AccountState",
28
+ "ClientProfile",
29
+ "RateLimiter",
30
+ "Session",
31
+ "MemorySession",
32
+ "StringSession",
33
+ "FileSession",
34
+ "SQLiteSession",
35
+ "FernetCipher",
36
+ "User",
37
+ "Chat",
38
+ "Message",
39
+ "Dialog",
40
+ "SentCode",
41
+ "DeletedMessages",
42
+ "filters",
43
+ "StopPropagation",
44
+ "ContinuePropagation",
45
+ *_errors_all,
46
+ ]
@@ -0,0 +1,116 @@
1
+ """Command line helper: ``python -m eitaagram <command>``.
2
+
3
+ * ``login`` -- log one account in (interactive) and store it in a SQLite file
4
+ * ``list`` -- show stored accounts (never prints tokens)
5
+ * ``doctor`` -- probe which ``layer`` / ``flags`` / endpoints the server accepts
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import asyncio
12
+ import logging
13
+ import sys
14
+ import time
15
+ from pathlib import Path
16
+
17
+ from . import Client, ClientProfile, EitaaError, SQLiteSession
18
+
19
+ _COMBOS = [(135, 32), (135, 128), (135, 0), (133, 0), (133, 32), (137, 0), (137, 32)]
20
+
21
+
22
+ async def _login(args: argparse.Namespace) -> int:
23
+ client = Client(SQLiteSession(args.db, args.name), phone=args.phone, no_updates=True)
24
+ try:
25
+ await client.start(first_name=args.first_name)
26
+ me = client.me
27
+ print(f"logged in as {me.full_name if me else '?'} (id {client.me_id}), stored in {args.db} as {args.name!r}")
28
+ return 0
29
+ except EitaaError as exc:
30
+ print(f"login failed: {exc}", file=sys.stderr)
31
+ return 1
32
+ finally:
33
+ await client.stop()
34
+
35
+
36
+ async def _list(args: argparse.Namespace) -> int:
37
+ names = SQLiteSession.list_names(args.db)
38
+ if not names:
39
+ print("no accounts stored")
40
+ return 0
41
+ for name in names:
42
+ session = SQLiteSession(args.db, name)
43
+ await session.load()
44
+ d = session.data
45
+ print(f"{name:20} phone={d.phone or '-':14} user_id={d.user_id or '-':<12} authorized={bool(d.token)}")
46
+ return 0
47
+
48
+
49
+ async def _doctor(args: argparse.Namespace) -> int:
50
+ base = ClientProfile()
51
+ print("== endpoint reachability (unauthenticated request, a rejection still proves the host is alive) ==")
52
+ probe = Client(SQLiteSession(args.db, args.name), profile=base, no_updates=True, rate_limit=None, max_retries=0)
53
+ await probe.connect()
54
+ for url in base.client_endpoints:
55
+ started = time.perf_counter()
56
+ try:
57
+ await probe.invoker.invoke("updates.getState", endpoint=url, retries=0) # type: ignore[union-attr]
58
+ verdict = "ok"
59
+ except EitaaError as exc:
60
+ verdict = f"{type(exc).__name__}: {exc}"[:90]
61
+ print(f"{url:42} {(time.perf_counter() - started) * 1000:6.0f} ms {verdict}")
62
+ await probe.stop()
63
+
64
+ session = SQLiteSession(args.db, args.name)
65
+ await session.load()
66
+ if not session.data.token:
67
+ print("\nNo stored login for that name; run `login` first to calibrate layer/flags.")
68
+ return 0
69
+ print("\n== layer / flags calibration (users.getUsers self) ==")
70
+ winners = []
71
+ for layer, flags in _COMBOS:
72
+ client = Client(
73
+ SQLiteSession(args.db, args.name),
74
+ profile=base.with_(layer=layer, flags=flags),
75
+ no_updates=True,
76
+ rate_limit=None,
77
+ max_retries=0,
78
+ auto_refresh_token=False,
79
+ session_flush_interval=0,
80
+ )
81
+ try:
82
+ await client.connect()
83
+ await client.invoke("users.getUsers", {"id": [{"_": "inputUserSelf"}]})
84
+ print(f"layer={layer} flags={flags:<4} OK")
85
+ winners.append((layer, flags))
86
+ except EitaaError as exc:
87
+ print(f"layer={layer} flags={flags:<4} {type(exc).__name__}: {str(exc)[:80]}")
88
+ finally:
89
+ await client.disconnect()
90
+ await asyncio.sleep(0.5)
91
+ print(f"\naccepted combinations: {winners or 'none'}")
92
+ return 0
93
+
94
+
95
+ def main(argv: list[str] | None = None) -> int:
96
+ parser = argparse.ArgumentParser(prog="eitaagram")
97
+ parser.add_argument("-v", "--verbose", action="store_true")
98
+ sub = parser.add_subparsers(dest="cmd", required=True)
99
+ login = sub.add_parser("login", help="log an account in and store it")
100
+ login.add_argument("--db", type=Path, default=Path("accounts.db"))
101
+ login.add_argument("--name", required=True)
102
+ login.add_argument("--phone", required=True)
103
+ login.add_argument("--first-name", default=None, help="needed only if the number is not registered yet")
104
+ ls = sub.add_parser("list", help="list stored accounts")
105
+ ls.add_argument("--db", type=Path, default=Path("accounts.db"))
106
+ doc = sub.add_parser("doctor", help="probe endpoints and accepted layer/flags")
107
+ doc.add_argument("--db", type=Path, default=Path("accounts.db"))
108
+ doc.add_argument("--name", default="default")
109
+ args = parser.parse_args(argv)
110
+ logging.basicConfig(level=logging.DEBUG if args.verbose else logging.WARNING, format="%(levelname)s %(name)s: %(message)s")
111
+ handler = {"login": _login, "list": _list, "doctor": _doctor}[args.cmd]
112
+ return asyncio.run(handler(args))
113
+
114
+
115
+ if __name__ == "__main__":
116
+ raise SystemExit(main())