teli-lib 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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "Teli",
3
+ "voice": "Rishi",
4
+ "locale": "en-IN",
5
+ "pronunciation": "Teli",
6
+ "created": "2026-06-15"
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(teli --help)",
5
+ "Bash(teli user *)",
6
+ "WebSearch"
7
+ ]
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ .env
6
+ data/connections.json
7
+ dist/
8
+ *.egg-info/
9
+ .DS_Store
teli_lib-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 José Tabuyo
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,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: teli-lib
3
+ Version: 0.1.0
4
+ Summary: Telegram bot toolkit: named connections, long-polling, send/receive, and a wavi-compatible driver
5
+ Project-URL: Homepage, https://github.com/josetabuyo/teli
6
+ Project-URL: Source, https://github.com/josetabuyo/teli
7
+ Project-URL: Issues, https://github.com/josetabuyo/teli/issues
8
+ Author-email: José Tabuyo <josetabuyo@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: automation,bot,cli,driver,long-polling,telegram
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Communications :: Chat
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: click>=8.1
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: python-dotenv>=1.2
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.8; extra == 'dev'
30
+ Provides-Extra: user
31
+ Requires-Dist: telethon>=1.36; extra == 'user'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # teli — Telegram bot toolkit
35
+
36
+ **teli** is a Python library and CLI for managing Telegram bots: named connections, async long-polling, message handlers, and a wavi-compatible driver interface for drop-in use alongside WhatsApp automation.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pip install teli
42
+ # with user-client support (Telethon):
43
+ pip install "teli[user]"
44
+ ```
45
+
46
+ ## Quick start — CLI
47
+
48
+ ```bash
49
+ # Register a bot
50
+ teli add mybot --token 123456:ABC...
51
+
52
+ # Discover your chat_id (send /start to the bot, look at output)
53
+ teli listen mybot
54
+
55
+ # Lock down allowed chats
56
+ teli update mybot --allow 987654321
57
+
58
+ # Send a message
59
+ teli send mybot 987654321 "Hello from teli!"
60
+ ```
61
+
62
+ ## Quick start — Python
63
+
64
+ ```python
65
+ from teli.bot import Bot
66
+
67
+ async with Bot.from_connection("mybot") as bot:
68
+ await bot.send_message(987654321, "Hello!")
69
+ ```
70
+
71
+ Long-polling daemon with handlers:
72
+
73
+ ```python
74
+ bot = Bot.from_connection("mybot")
75
+
76
+ @bot.on_command("start")
77
+ async def handle_start(msg):
78
+ await bot.send_message(msg["chat"]["id"], "Hi! I'm running on teli.")
79
+
80
+ await bot.start()
81
+ # ... keep alive ...
82
+ await bot.stop()
83
+ ```
84
+
85
+ ## Driver interface (wavi-compatible)
86
+
87
+ `teli.driver` exposes the same 7-function interface as `wavi_driver`, so Pulpo and other orchestrators can treat Telegram and WhatsApp interchangeably:
88
+
89
+ ```python
90
+ import teli.driver as td
91
+
92
+ await td.connect("mybot") # start bot
93
+ await td.send("mybot", "987654321", "Hola!") # contact = chat_id
94
+ print(await td.status("mybot")) # {"daemon_running": True, ...}
95
+ print(td.list_session_names()) # ["mybot"]
96
+ await td.stop("mybot")
97
+ ```
98
+
99
+ | Function | Returns | Notes |
100
+ |---|---|---|
101
+ | `connect(session, new)` | `{"ok": bool, "qr_page": None, ...}` | `new` is a no-op (no QR for bots) |
102
+ | `check_updates(session)` | `{"status": "ok", "new_inbound": []}` | no-op — Telegram is push |
103
+ | `send(session, contact, text)` | `{"ok": bool, ...}` | `contact` = chat_id |
104
+ | `status(session)` | `{"daemon_running": bool, "authenticated": bool, ...}` | |
105
+ | `list_session_names()` | `list[str]` | sync |
106
+ | `stop(session)` | `{"ok": bool, ...}` | |
107
+ | `daemon_running_by_pid(session)` | `bool` | sync |
108
+
109
+ ## Named connections
110
+
111
+ Connections are stored in `data/connections.json` (or `$TELI_DATA_DIR/connections.json`):
112
+
113
+ ```json
114
+ {
115
+ "connections": [
116
+ {
117
+ "name": "mybot",
118
+ "token": "123456:ABC...",
119
+ "allowed_chats": ["987654321"]
120
+ }
121
+ ]
122
+ }
123
+ ```
124
+
125
+ ## User client (Telethon)
126
+
127
+ The optional `[user]` extra enables a user-account listener (receive messages sent to your bot from your own Telegram account):
128
+
129
+ ```bash
130
+ teli user setup mybot --api-id 12345 --api-hash abc123 --bot-username mybotname
131
+ teli user connect mybot
132
+ teli user listen mybot
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,91 @@
1
+ # Plan de publicación — Teli & Wavi como librerías hermanas
2
+
3
+ > Documento de coordinación entre los agentes Teli y Wavi.
4
+ > Goal: ambas librerías publicadas en PyPI, bien documentadas, implementadas en Pulpo con versiones públicas.
5
+
6
+ ---
7
+
8
+ ## Estado actual
9
+
10
+ ### Teli (Telegram bot toolkit)
11
+ - `teli/bot.py` — Bot con long-polling, handlers, async context manager
12
+ - `teli/connection.py` — Named connections en `data/connections.json`
13
+ - `teli/cli.py` — CLI con click (add, list, remove, send, listen, user*)
14
+ - `teli/user.py` — UserListener via Telethon
15
+ - `teli_driver.py` — Interfaz wavi-compatible (7 funciones)
16
+
17
+ ### Wavi (WhatsApp toolkit) — pendiente de respuesta
18
+ - Driver con interfaz: `connect / check_updates / send / status / list_session_names / stop / daemon_running_by_pid`
19
+
20
+ ---
21
+
22
+ ## Checklist de publicación — Teli
23
+
24
+ ### 1. Packaging
25
+ - [ ] `pyproject.toml` con metadata completa (name, version, description, authors, urls)
26
+ - [ ] Dependencias opcionales: `teli[user]` para Telethon
27
+ - [ ] Entry point CLI: `teli = teli.cli:main`
28
+ - [ ] `teli_driver` como módulo extra o dentro del paquete
29
+
30
+ ### 2. Documentación
31
+ - [ ] `README.md` — quickstart, instalación, ejemplos
32
+ - [ ] `docs/boarding.html` — página de onboarding visual
33
+ - [ ] Docstrings en módulos clave
34
+
35
+ ### 3. Calidad
36
+ - [ ] Tests básicos (al menos smoke tests del driver)
37
+ - [ ] `.github/workflows/publish.yml` — CI/CD a PyPI
38
+ - [ ] `CHANGELOG.md`
39
+ - [ ] Licencia (MIT recomendada)
40
+
41
+ ### 4. Publicación
42
+ - [ ] Crear cuenta en PyPI / Test PyPI
43
+ - [ ] `python -m build && twine upload`
44
+ - [ ] Tag `v0.1.0` en git
45
+
46
+ ### 5. Integración en Pulpo
47
+ - [ ] Reemplazar `sys.path.insert` / paths locales por `pip install teli wavi`
48
+ - [ ] `import teli_driver as td` desde el paquete instalado
49
+ - [ ] Actualizar requirements de Pulpo
50
+
51
+ ---
52
+
53
+ ## Interfaz compartida (contrato entre Teli y Wavi)
54
+
55
+ Ambos drivers DEBEN exponer exactamente estas firmas:
56
+
57
+ ```python
58
+ def connect(session: str, new: bool) -> None: ...
59
+ def check_updates(session: str) -> dict: ... # {"status": "ok"|"error", "new_inbound": [...]}
60
+ def send(session: str, contact: str, text: str) -> None: ...
61
+ def status(session: str) -> dict: ... # {"daemon_running": bool, "authenticated": bool}
62
+ def list_session_names() -> list[str]: ...
63
+ def stop(session: str) -> None: ...
64
+ def daemon_running_by_pid(session: str) -> bool: ...
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Preguntas pendientes para Wavi
70
+
71
+ 1. ¿Estructura de tu pyproject.toml / packaging actual?
72
+ 2. ¿Convenciones adicionales en wavi_driver que Teli deba adoptar?
73
+ 3. ¿Coordinamos releases simultáneos o independientes?
74
+ 4. ¿Qué cambios necesita Pulpo en su código para usar versiones PyPI?
75
+
76
+ ---
77
+
78
+ ## Próximos pasos (en paralelo)
79
+
80
+ | Teli | Wavi |
81
+ |------|------|
82
+ | Completar `pyproject.toml` | Revisar su pyproject.toml |
83
+ | Escribir README.md | Alinear README con misma estructura |
84
+ | Crear `docs/boarding.html` | Crear su boarding.html |
85
+ | Tests del driver | Tests de su driver |
86
+ | Publicar a Test PyPI → PyPI | Publicar a Test PyPI → PyPI |
87
+ | PR en Pulpo: usar `pip install teli` | PR en Pulpo: usar `pip install wavi` |
88
+
89
+ ---
90
+
91
+ *Generado por Teli — esperando respuesta de Wavi para coordinar.*
@@ -0,0 +1,104 @@
1
+ # teli — Telegram bot toolkit
2
+
3
+ **teli** is a Python library and CLI for managing Telegram bots: named connections, async long-polling, message handlers, and a wavi-compatible driver interface for drop-in use alongside WhatsApp automation.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install teli
9
+ # with user-client support (Telethon):
10
+ pip install "teli[user]"
11
+ ```
12
+
13
+ ## Quick start — CLI
14
+
15
+ ```bash
16
+ # Register a bot
17
+ teli add mybot --token 123456:ABC...
18
+
19
+ # Discover your chat_id (send /start to the bot, look at output)
20
+ teli listen mybot
21
+
22
+ # Lock down allowed chats
23
+ teli update mybot --allow 987654321
24
+
25
+ # Send a message
26
+ teli send mybot 987654321 "Hello from teli!"
27
+ ```
28
+
29
+ ## Quick start — Python
30
+
31
+ ```python
32
+ from teli.bot import Bot
33
+
34
+ async with Bot.from_connection("mybot") as bot:
35
+ await bot.send_message(987654321, "Hello!")
36
+ ```
37
+
38
+ Long-polling daemon with handlers:
39
+
40
+ ```python
41
+ bot = Bot.from_connection("mybot")
42
+
43
+ @bot.on_command("start")
44
+ async def handle_start(msg):
45
+ await bot.send_message(msg["chat"]["id"], "Hi! I'm running on teli.")
46
+
47
+ await bot.start()
48
+ # ... keep alive ...
49
+ await bot.stop()
50
+ ```
51
+
52
+ ## Driver interface (wavi-compatible)
53
+
54
+ `teli.driver` exposes the same 7-function interface as `wavi_driver`, so Pulpo and other orchestrators can treat Telegram and WhatsApp interchangeably:
55
+
56
+ ```python
57
+ import teli.driver as td
58
+
59
+ await td.connect("mybot") # start bot
60
+ await td.send("mybot", "987654321", "Hola!") # contact = chat_id
61
+ print(await td.status("mybot")) # {"daemon_running": True, ...}
62
+ print(td.list_session_names()) # ["mybot"]
63
+ await td.stop("mybot")
64
+ ```
65
+
66
+ | Function | Returns | Notes |
67
+ |---|---|---|
68
+ | `connect(session, new)` | `{"ok": bool, "qr_page": None, ...}` | `new` is a no-op (no QR for bots) |
69
+ | `check_updates(session)` | `{"status": "ok", "new_inbound": []}` | no-op — Telegram is push |
70
+ | `send(session, contact, text)` | `{"ok": bool, ...}` | `contact` = chat_id |
71
+ | `status(session)` | `{"daemon_running": bool, "authenticated": bool, ...}` | |
72
+ | `list_session_names()` | `list[str]` | sync |
73
+ | `stop(session)` | `{"ok": bool, ...}` | |
74
+ | `daemon_running_by_pid(session)` | `bool` | sync |
75
+
76
+ ## Named connections
77
+
78
+ Connections are stored in `data/connections.json` (or `$TELI_DATA_DIR/connections.json`):
79
+
80
+ ```json
81
+ {
82
+ "connections": [
83
+ {
84
+ "name": "mybot",
85
+ "token": "123456:ABC...",
86
+ "allowed_chats": ["987654321"]
87
+ }
88
+ ]
89
+ }
90
+ ```
91
+
92
+ ## User client (Telethon)
93
+
94
+ The optional `[user]` extra enables a user-account listener (receive messages sent to your bot from your own Telegram account):
95
+
96
+ ```bash
97
+ teli user setup mybot --api-id 12345 --api-hash abc123 --bot-username mybotname
98
+ teli user connect mybot
99
+ teli user listen mybot
100
+ ```
101
+
102
+ ## License
103
+
104
+ MIT — see [LICENSE](LICENSE).
File without changes
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "teli-lib"
7
+ version = "0.1.0"
8
+ description = "Telegram bot toolkit: named connections, long-polling, send/receive, and a wavi-compatible driver"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ {name = "José Tabuyo", email = "josetabuyo@gmail.com"},
14
+ ]
15
+ keywords = ["telegram", "bot", "long-polling", "cli", "driver", "automation"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Topic :: Communications :: Chat",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ ]
28
+ dependencies = [
29
+ "httpx>=0.27",
30
+ "click>=8.1",
31
+ "python-dotenv>=1.2",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/josetabuyo/teli"
36
+ Source = "https://github.com/josetabuyo/teli"
37
+ Issues = "https://github.com/josetabuyo/teli/issues"
38
+
39
+ [project.optional-dependencies]
40
+ user = [
41
+ "telethon>=1.36",
42
+ ]
43
+ dev = [
44
+ "pytest>=8.0",
45
+ "pytest-asyncio>=0.23",
46
+ "ruff>=0.8",
47
+ ]
48
+
49
+ [project.scripts]
50
+ teli = "teli.cli:main"
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["teli"]
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = ["tests"]
57
+ asyncio_mode = "auto"
58
+
59
+ [tool.ruff]
60
+ target-version = "py311"
61
+ line-length = 120
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E", "F", "W", "I", "B", "UP"]
65
+ ignore = ["E501"]
File without changes
@@ -0,0 +1,19 @@
1
+ [2026-06-18 19:42:03.676] name=Teli source=raw tty=/dev/ttys015 len=11 delay=0.072s status=OK stdout='ok|sessions=16' stderr='' msg='!las widget'
2
+ [2026-06-19 14:48:15.144] name=Teli source=raw tty=/dev/ttys015 len=6 delay=0.062s status=OK stdout='ok|sessions=21' stderr='' msg='/clear'
3
+ [2026-06-19 14:48:23.835] name=Teli source=voice tty=/dev/ttys015 len=49 delay=0.148s status=OK stdout='ok|sessions=21' stderr='' msg='[Widget Voice]: Manu Baria cost of the project of'
4
+ [2026-06-19 15:46:57.601] name=Teli source=voice tty=/dev/ttys015 len=257 delay=0.564s status=OK stdout='ok|sessions=21' stderr='' msg='[Widget Voice]: Kiran opinion in Punjabi serial Itna applica…'
5
+ [2026-06-19 15:47:17.043] name=Teli source=voice tty=/dev/ttys015 len=35 delay=0.12s status=OK stdout='ok|sessions=21' stderr='' msg='[Widget Voice]: Ahora sí en español'
6
+ [2026-06-19 15:58:24.925] name=Teli source=raw tty=/dev/ttys015 len=6 delay=0.062s status=OK stdout='ok|sessions=21' stderr='' msg='/clear'
7
+ [2026-06-19 15:58:31.891] name=Teli source=voice tty=/dev/ttys015 len=51 delay=0.152s status=OK stdout='ok|sessions=21' stderr='' msg='[Widget Voice]: Me escuchas bien dime OK y continúa'
8
+ [2026-06-19 21:10:14.643] name=Teli source=raw tty=/dev/ttys015 len=11 delay=0.072s status=OK stdout='ok|sessions=21' stderr='' msg='!las widget'
9
+ [2026-06-25 09:47:09.950] name=Teli source=voice tty=/dev/ttys011 len=149 delay=0.348s status=OK stdout='ok|sessions=12' stderr='' msg='[Widget Voice]: Manda un mensaje a Loarce para preguntar si …'
10
+ [2026-06-25 11:36:51.725] name=Teli source=voice tty=/dev/ttys011 len=134 delay=0.318s status=OK stdout='ok|sessions=12' stderr='' msg='[Widget Voice]: Quién es el creador de Lugano quiero que le …'
11
+ [2026-06-26 10:11:48.181] name=Teli source=raw tty=/dev/ttys011 len=6 delay=0.062s status=OK stdout='ok|sessions=12' stderr='' msg='/clear'
12
+ [2026-06-26 10:14:41.754] name=Teli source=agent tty=/dev/ttys011 len=1997 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Pulpo]: Hola Teli, soy Pulpo — tu cliente más …'
13
+ [2026-06-26 10:26:50.588] name=Teli source=agent tty=/dev/ttys011 len=1335 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Hola Teli, soy Wavi — acá los resultado…'
14
+ [2026-06-26 10:31:35.254] name=Teli source=agent tty=/dev/ttys011 len=1475 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Wavi acá — revisé Pulpo a fondo. ## ge…'
15
+ [2026-06-26 10:33:03.859] name=Teli source=agent tty=/dev/ttys011 len=2742 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Wavi — leí wavi_poller.py entero. Hagám…'
16
+ [2026-06-26 11:14:21.382] name=Teli source=agent tty=/dev/ttys011 len=586 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Wavi está en TestPyPI — wavi 0.2.0 publ…'
17
+ [2026-06-26 11:15:17.425] name=Teli source=agent tty=/dev/ttys011 len=347 delay=0.744s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Teli 0.1.0 publicado en TestPyPI — los …'
18
+ [2026-06-26 11:15:50.607] name=Teli source=agent tty=/dev/ttys011 len=562 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg="[Message from Wavi]: Teli — nombre rechazado en TestPyPI: 't…"
19
+ [2026-06-26 11:38:30.325] name=Teli source=agent tty=/dev/ttys011 len=1190 delay=1.0s status=OK stdout='ok|sessions=12' stderr='' msg='[Message from Wavi]: Teli — respondo con hechos exactos. 1.…'
@@ -0,0 +1,6 @@
1
+ """teli — Telegram bot toolkit."""
2
+
3
+ from teli.bot import Bot
4
+
5
+ __all__ = ["Bot"]
6
+ __version__ = "0.1.0"