zarpa 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 (94) hide show
  1. zarpa-0.1.0/LICENSE +22 -0
  2. zarpa-0.1.0/PKG-INFO +118 -0
  3. zarpa-0.1.0/README.md +76 -0
  4. zarpa-0.1.0/pyproject.toml +60 -0
  5. zarpa-0.1.0/setup.cfg +4 -0
  6. zarpa-0.1.0/tests/test_blogs.py +37 -0
  7. zarpa-0.1.0/tests/test_generadores.py +47 -0
  8. zarpa-0.1.0/tests/test_paquete.py +34 -0
  9. zarpa-0.1.0/zarpa/__init__.py +58 -0
  10. zarpa-0.1.0/zarpa/api/_async/__init__.py +5 -0
  11. zarpa-0.1.0/zarpa/api/_async/altteam.py +42 -0
  12. zarpa-0.1.0/zarpa/api/_async/auth.py +74 -0
  13. zarpa-0.1.0/zarpa/api/_async/chats.py +129 -0
  14. zarpa-0.1.0/zarpa/api/_async/communities.py +60 -0
  15. zarpa-0.1.0/zarpa/api/_async/sub/__init__.py +6 -0
  16. zarpa-0.1.0/zarpa/api/_async/sub/adm.py +403 -0
  17. zarpa-0.1.0/zarpa/api/_async/sub/altacm.py +73 -0
  18. zarpa-0.1.0/zarpa/api/_async/sub/blogs.py +99 -0
  19. zarpa-0.1.0/zarpa/api/_async/sub/chats.py +273 -0
  20. zarpa-0.1.0/zarpa/api/_async/sub/community.py +64 -0
  21. zarpa-0.1.0/zarpa/api/_async/sub/users.py +144 -0
  22. zarpa-0.1.0/zarpa/api/_async/users.py +37 -0
  23. zarpa-0.1.0/zarpa/api/_sync/__init__.py +4 -0
  24. zarpa-0.1.0/zarpa/api/_sync/auth.py +76 -0
  25. zarpa-0.1.0/zarpa/api/_sync/chats.py +78 -0
  26. zarpa-0.1.0/zarpa/api/_sync/sub/__init__.py +1 -0
  27. zarpa-0.1.0/zarpa/api/_sync/sub/chats.py +44 -0
  28. zarpa-0.1.0/zarpa/api/base.py +68 -0
  29. zarpa-0.1.0/zarpa/clients/__init__.py +0 -0
  30. zarpa-0.1.0/zarpa/clients/_async/__init__.py +0 -0
  31. zarpa-0.1.0/zarpa/clients/_async/client.py +114 -0
  32. zarpa-0.1.0/zarpa/clients/_async/sub_client.py +26 -0
  33. zarpa-0.1.0/zarpa/clients/client.py +105 -0
  34. zarpa-0.1.0/zarpa/clients/sub_client.py +22 -0
  35. zarpa-0.1.0/zarpa/objects/__init__.py +0 -0
  36. zarpa-0.1.0/zarpa/objects/args/__init__.py +35 -0
  37. zarpa-0.1.0/zarpa/objects/args/administrators_rank.py +24 -0
  38. zarpa-0.1.0/zarpa/objects/args/chat_types.py +8 -0
  39. zarpa-0.1.0/zarpa/objects/args/client_types.py +13 -0
  40. zarpa-0.1.0/zarpa/objects/args/community_join_types.py +15 -0
  41. zarpa-0.1.0/zarpa/objects/args/community_modules.py +50 -0
  42. zarpa-0.1.0/zarpa/objects/args/embed_types.py +29 -0
  43. zarpa-0.1.0/zarpa/objects/args/feature_days.py +14 -0
  44. zarpa-0.1.0/zarpa/objects/args/gender.py +18 -0
  45. zarpa-0.1.0/zarpa/objects/args/leaderboard_types.py +23 -0
  46. zarpa-0.1.0/zarpa/objects/args/message_type.py +22 -0
  47. zarpa-0.1.0/zarpa/objects/args/object_types.py +9 -0
  48. zarpa-0.1.0/zarpa/objects/args/promotion_types.py +13 -0
  49. zarpa-0.1.0/zarpa/objects/args/proxy.py +117 -0
  50. zarpa-0.1.0/zarpa/objects/args/purchase_types.py +13 -0
  51. zarpa-0.1.0/zarpa/objects/args/qmode.py +14 -0
  52. zarpa-0.1.0/zarpa/objects/args/repair_method.py +17 -0
  53. zarpa-0.1.0/zarpa/objects/args/sorting.py +19 -0
  54. zarpa-0.1.0/zarpa/objects/args/sorting2.py +14 -0
  55. zarpa-0.1.0/zarpa/objects/args/strike_time.py +9 -0
  56. zarpa-0.1.0/zarpa/objects/args/upload_type.py +21 -0
  57. zarpa-0.1.0/zarpa/objects/args/users_types.py +23 -0
  58. zarpa-0.1.0/zarpa/objects/args/vc_join_permissions.py +19 -0
  59. zarpa-0.1.0/zarpa/objects/args/ws_event_types.py +136 -0
  60. zarpa-0.1.0/zarpa/objects/resp/__init__.py +19 -0
  61. zarpa-0.1.0/zarpa/objects/resp/account.py +34 -0
  62. zarpa-0.1.0/zarpa/objects/resp/auth.py +11 -0
  63. zarpa-0.1.0/zarpa/objects/resp/base_object.py +15 -0
  64. zarpa-0.1.0/zarpa/objects/resp/blogs.py +148 -0
  65. zarpa-0.1.0/zarpa/objects/resp/chat.py +178 -0
  66. zarpa-0.1.0/zarpa/objects/resp/comments.py +23 -0
  67. zarpa-0.1.0/zarpa/objects/resp/communities.py +75 -0
  68. zarpa-0.1.0/zarpa/objects/resp/event.py +60 -0
  69. zarpa-0.1.0/zarpa/objects/resp/from_code.py +32 -0
  70. zarpa-0.1.0/zarpa/objects/resp/media.py +11 -0
  71. zarpa-0.1.0/zarpa/objects/resp/store.py +82 -0
  72. zarpa-0.1.0/zarpa/objects/resp/user.py +42 -0
  73. zarpa-0.1.0/zarpa/utils/__init__.py +2 -0
  74. zarpa-0.1.0/zarpa/utils/constants.py +116 -0
  75. zarpa-0.1.0/zarpa/utils/exceptions.py +985 -0
  76. zarpa-0.1.0/zarpa/utils/generators.py +196 -0
  77. zarpa-0.1.0/zarpa/utils/logger.py +92 -0
  78. zarpa-0.1.0/zarpa/utils/requester.py +307 -0
  79. zarpa-0.1.0/zarpa/utils/state.py +555 -0
  80. zarpa-0.1.0/zarpa/ws/__init__.py +3 -0
  81. zarpa-0.1.0/zarpa/ws/_async/__init__.py +0 -0
  82. zarpa-0.1.0/zarpa/ws/_async/actions.py +224 -0
  83. zarpa-0.1.0/zarpa/ws/_async/handler.py +80 -0
  84. zarpa-0.1.0/zarpa/ws/_async/router.py +25 -0
  85. zarpa-0.1.0/zarpa/ws/_async/socket.py +322 -0
  86. zarpa-0.1.0/zarpa/ws/actions.py +204 -0
  87. zarpa-0.1.0/zarpa/ws/handler.py +72 -0
  88. zarpa-0.1.0/zarpa/ws/router.py +118 -0
  89. zarpa-0.1.0/zarpa/ws/socket.py +166 -0
  90. zarpa-0.1.0/zarpa.egg-info/PKG-INFO +118 -0
  91. zarpa-0.1.0/zarpa.egg-info/SOURCES.txt +92 -0
  92. zarpa-0.1.0/zarpa.egg-info/dependency_links.txt +1 -0
  93. zarpa-0.1.0/zarpa.egg-info/requires.txt +13 -0
  94. zarpa-0.1.0/zarpa.egg-info/top_level.txt +1 -0
zarpa-0.1.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 alx0rr (altamino.py, the library zarpa is based on)
4
+ Copyright (c) 2026 mihzuk
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
zarpa-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.4
2
+ Name: zarpa
3
+ Version: 0.1.0
4
+ Summary: Librería de Python para crear bots de AltAmino: API, chat y websocket, síncrona y asíncrona.
5
+ Author: mihzuk
6
+ Maintainer: mihzuk
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/mihzuk/zarpa
9
+ Project-URL: Repository, https://github.com/mihzuk/zarpa
10
+ Project-URL: Issues, https://github.com/mihzuk/zarpa/issues
11
+ Project-URL: Changelog, https://github.com/mihzuk/zarpa/blob/main/CHANGELOG.md
12
+ Keywords: altamino,amino,bot,chatbot,api,websocket,async
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: Spanish
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Communications :: Chat
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.11
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: aiofiles>=24.1
30
+ Requires-Dist: aiohttp>=3.10
31
+ Requires-Dist: aiohttp-socks>=0.9
32
+ Requires-Dist: colorama>=0.4.6
33
+ Requires-Dist: httpx[socks]>=0.27
34
+ Requires-Dist: orjson>=3.10
35
+ Requires-Dist: websocket-client>=1.8
36
+ Provides-Extra: dev
37
+ Requires-Dist: ruff; extra == "dev"
38
+ Requires-Dist: build; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Requires-Dist: pip-audit; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # zarpa
44
+
45
+ **Librería de Python para crear bots de [AltAmino](https://altamino.top/)**: inicia sesión, lee y manda mensajes, escucha el chat en tiempo real por websocket y usa la API de comunidades, blogs, chats y moderación. Tiene versión asíncrona (`asyncio`) y síncrona.
46
+
47
+ [![Pruebas](https://github.com/mihzuk/zarpa/actions/workflows/pruebas.yml/badge.svg)](https://github.com/mihzuk/zarpa/actions/workflows/pruebas.yml)
48
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
49
+ ![Licencia MIT](https://img.shields.io/badge/licencia-MIT-green)
50
+
51
+ > zarpa nace del fork de [altamino.py](https://github.com/altamino/altamino.py) de alx0rr, que dejó de mantenerse. Conserva su historial y su licencia, con arreglos y funciones nuevas probadas en vivo. Es la librería con la que funciona [Bigotes](https://github.com/mihzuk/bigotes-bot).
52
+
53
+ ## Instalación
54
+
55
+ Por ahora se instala desde GitHub (pronto estará en PyPI):
56
+
57
+ ```bash
58
+ pip install "zarpa @ git+https://github.com/mihzuk/zarpa@v0.1.0"
59
+ ```
60
+
61
+ Necesita Python 3.11 o más nuevo.
62
+
63
+ ## Un bot en 15 líneas
64
+
65
+ ```python
66
+ import asyncio
67
+
68
+ from zarpa import AsyncClient
69
+ from zarpa.objects.args import wsEvent
70
+
71
+ #guarda el Device ID la primera vez y úsalo siempre: así AltAmino reconoce al bot
72
+ client = AsyncClient(deviceId="TU_DEVICE_ID")
73
+
74
+
75
+ @client.event(wsEvent.on_text_message)
76
+ async def al_recibir(event):
77
+ if event.message.content == "!hola":
78
+ await event.sub_client.send_message(event.message.chatId, "¡Hola! ᓚᘏᗢ")
79
+
80
+
81
+ async def main():
82
+ await client.login("correo@ejemplo.com", "contraseña")
83
+ await client.socket_wait()
84
+
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ Nunca escribas el correo ni la contraseña en el código que subas: léelos de variables de entorno o de un archivo `.env` que no esté en el repositorio.
90
+
91
+ ## Qué trae
92
+
93
+ - **Cuenta:** inicio de sesión con correo o SID, perfil, monedero, check-in y lotería.
94
+ - **Chat:** mensajes de texto e imágenes, menciones, respuestas, historial, miembros y solo lectura.
95
+ - **Tiempo real:** websocket con reconexión, eventos (`wsEvent`) y comandos con su enrutador.
96
+ - **Comunidades:** blogs (leer, publicar, editar, borrar, destacados, likes), muros, usuarios y avisos del staff.
97
+ - **Moderación:** borrar mensajes con motivo, expulsar, solo lectura y herramientas de curador.
98
+ - **Salas:** sala de proyección con lista de vídeos sincronizada.
99
+ - **Proxys:** HTTP y SOCKS, también por grupos.
100
+
101
+ ## Diferencias con altamino.py
102
+
103
+ - Nombre propio: se importa como `zarpa`, así que puede convivir con `altamino`.
104
+ - Importarla no hace peticiones a internet (antes consultaba PyPI en cada `import`).
105
+ - Funciones nuevas probadas en vivo: publicar y editar blogs, blogs destacados, leer un blog, sala de proyección y más.
106
+ - Pruebas automáticas, versiones con changelog y comprobaciones de seguridad en cada cambio.
107
+
108
+ Para pasar de `altamino` a `zarpa`, cambia los imports: `from altamino import ...` pasa a `from zarpa import ...`.
109
+
110
+ ## Contribuir
111
+
112
+ Las ideas, los avisos de errores y los pull requests son bienvenidos. Mira [CONTRIBUTING.md](CONTRIBUTING.md) para saber cómo montarla en local, cómo escribir los commits y cómo pasar las pruebas.
113
+
114
+ ## Licencia y créditos
115
+
116
+ [MIT](LICENSE). zarpa se basa en altamino.py de **alx0rr** (MIT, 2025): su aviso de copyright se conserva en la licencia.
117
+
118
+ No es un proyecto oficial de AltAmino.
zarpa-0.1.0/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # zarpa
2
+
3
+ **Librería de Python para crear bots de [AltAmino](https://altamino.top/)**: inicia sesión, lee y manda mensajes, escucha el chat en tiempo real por websocket y usa la API de comunidades, blogs, chats y moderación. Tiene versión asíncrona (`asyncio`) y síncrona.
4
+
5
+ [![Pruebas](https://github.com/mihzuk/zarpa/actions/workflows/pruebas.yml/badge.svg)](https://github.com/mihzuk/zarpa/actions/workflows/pruebas.yml)
6
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
7
+ ![Licencia MIT](https://img.shields.io/badge/licencia-MIT-green)
8
+
9
+ > zarpa nace del fork de [altamino.py](https://github.com/altamino/altamino.py) de alx0rr, que dejó de mantenerse. Conserva su historial y su licencia, con arreglos y funciones nuevas probadas en vivo. Es la librería con la que funciona [Bigotes](https://github.com/mihzuk/bigotes-bot).
10
+
11
+ ## Instalación
12
+
13
+ Por ahora se instala desde GitHub (pronto estará en PyPI):
14
+
15
+ ```bash
16
+ pip install "zarpa @ git+https://github.com/mihzuk/zarpa@v0.1.0"
17
+ ```
18
+
19
+ Necesita Python 3.11 o más nuevo.
20
+
21
+ ## Un bot en 15 líneas
22
+
23
+ ```python
24
+ import asyncio
25
+
26
+ from zarpa import AsyncClient
27
+ from zarpa.objects.args import wsEvent
28
+
29
+ #guarda el Device ID la primera vez y úsalo siempre: así AltAmino reconoce al bot
30
+ client = AsyncClient(deviceId="TU_DEVICE_ID")
31
+
32
+
33
+ @client.event(wsEvent.on_text_message)
34
+ async def al_recibir(event):
35
+ if event.message.content == "!hola":
36
+ await event.sub_client.send_message(event.message.chatId, "¡Hola! ᓚᘏᗢ")
37
+
38
+
39
+ async def main():
40
+ await client.login("correo@ejemplo.com", "contraseña")
41
+ await client.socket_wait()
42
+
43
+
44
+ asyncio.run(main())
45
+ ```
46
+
47
+ Nunca escribas el correo ni la contraseña en el código que subas: léelos de variables de entorno o de un archivo `.env` que no esté en el repositorio.
48
+
49
+ ## Qué trae
50
+
51
+ - **Cuenta:** inicio de sesión con correo o SID, perfil, monedero, check-in y lotería.
52
+ - **Chat:** mensajes de texto e imágenes, menciones, respuestas, historial, miembros y solo lectura.
53
+ - **Tiempo real:** websocket con reconexión, eventos (`wsEvent`) y comandos con su enrutador.
54
+ - **Comunidades:** blogs (leer, publicar, editar, borrar, destacados, likes), muros, usuarios y avisos del staff.
55
+ - **Moderación:** borrar mensajes con motivo, expulsar, solo lectura y herramientas de curador.
56
+ - **Salas:** sala de proyección con lista de vídeos sincronizada.
57
+ - **Proxys:** HTTP y SOCKS, también por grupos.
58
+
59
+ ## Diferencias con altamino.py
60
+
61
+ - Nombre propio: se importa como `zarpa`, así que puede convivir con `altamino`.
62
+ - Importarla no hace peticiones a internet (antes consultaba PyPI en cada `import`).
63
+ - Funciones nuevas probadas en vivo: publicar y editar blogs, blogs destacados, leer un blog, sala de proyección y más.
64
+ - Pruebas automáticas, versiones con changelog y comprobaciones de seguridad en cada cambio.
65
+
66
+ Para pasar de `altamino` a `zarpa`, cambia los imports: `from altamino import ...` pasa a `from zarpa import ...`.
67
+
68
+ ## Contribuir
69
+
70
+ Las ideas, los avisos de errores y los pull requests son bienvenidos. Mira [CONTRIBUTING.md](CONTRIBUTING.md) para saber cómo montarla en local, cómo escribir los commits y cómo pasar las pruebas.
71
+
72
+ ## Licencia y créditos
73
+
74
+ [MIT](LICENSE). zarpa se basa en altamino.py de **alx0rr** (MIT, 2025): su aviso de copyright se conserva en la licencia.
75
+
76
+ No es un proyecto oficial de AltAmino.
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "zarpa"
7
+ version = "0.1.0"
8
+ description = "Librería de Python para crear bots de AltAmino: API, chat y websocket, síncrona y asíncrona."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "mihzuk" }]
13
+ maintainers = [{ name = "mihzuk" }]
14
+ requires-python = ">=3.11"
15
+ keywords = ["altamino", "amino", "bot", "chatbot", "api", "websocket", "async"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Framework :: AsyncIO",
19
+ "Intended Audience :: Developers",
20
+ "Natural Language :: Spanish",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Topic :: Communications :: Chat",
29
+ "Topic :: Software Development :: Libraries :: Python Modules",
30
+ ]
31
+ dependencies = [
32
+ "aiofiles>=24.1",
33
+ "aiohttp>=3.10",
34
+ "aiohttp-socks>=0.9",
35
+ "colorama>=0.4.6",
36
+ "httpx[socks]>=0.27",
37
+ "orjson>=3.10",
38
+ "websocket-client>=1.8",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ dev = ["ruff", "build", "twine", "pip-audit"]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/mihzuk/zarpa"
46
+ Repository = "https://github.com/mihzuk/zarpa"
47
+ Issues = "https://github.com/mihzuk/zarpa/issues"
48
+ Changelog = "https://github.com/mihzuk/zarpa/blob/main/CHANGELOG.md"
49
+
50
+ [tool.setuptools.packages.find]
51
+ include = ["zarpa*"]
52
+
53
+ [tool.ruff]
54
+ line-length = 200
55
+ target-version = "py311"
56
+
57
+ [tool.ruff.lint]
58
+ #de momento, lo que rompe de verdad: errores de sintaxis, nombres sin definir e imports que no existen.
59
+ #Se irá endureciendo a medida que se ordene el código heredado
60
+ select = ["E9", "F63", "F7", "F82"]
zarpa-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,37 @@
1
+ """Las peticiones de blogs: qué ruta y qué datos manda cada función."""
2
+
3
+ import unittest
4
+
5
+ from tests.ayudantes import modulo
6
+ from zarpa.api._async.sub.blogs import CommunityBlogsModule
7
+
8
+
9
+ class PruebasBlogs(unittest.IsolatedAsyncioTestCase):
10
+ async def test_leer_un_blog_por_su_id(self):
11
+ blogs = modulo(CommunityBlogsModule, {"blog": {"blogId": "blog-1", "content": "Presentación"}})
12
+ blog = await blogs.get_blog_info("blog-1")
13
+ self.assertEqual(blogs.req.llamadas, [("GET", "/x123/s/blog/blog-1", None)])
14
+ self.assertEqual(blog.blogId, "blog-1")
15
+ self.assertEqual(blog.content, "Presentación")
16
+
17
+ async def test_publicar_editar_y_borrar(self):
18
+ blogs = modulo(CommunityBlogsModule)
19
+ await blogs.post_blog("Título", "[C]Texto")
20
+ await blogs.edit_blog("blog-1", "Otro título", "Otro texto")
21
+ await blogs.delete_blog("blog-1")
22
+ (m1, r1, d1), (m2, r2, d2), (m3, r3, _) = blogs.req.llamadas
23
+ self.assertEqual((m1, r1), ("POST", "/x123/s/blog"))
24
+ self.assertEqual((d1["title"], d1["content"], d1["type"]), ("Título", "[C]Texto", 0))
25
+ self.assertEqual((m2, r2, d2["title"], d2["content"]), ("POST", "/x123/s/blog/blog-1", "Otro título", "Otro texto"))
26
+ self.assertEqual((m3, r3), ("DELETE", "/x123/s/blog/blog-1"))
27
+
28
+ async def test_listas_de_blogs(self):
29
+ blogs = modulo(CommunityBlogsModule, {"blogList": [{"blogId": "a"}, {"blogId": "b"}],
30
+ "featuredList": [{"refObject": {"blogId": "c"}}]})
31
+ recientes = await blogs.get_recent_blogs(2)
32
+ self.assertEqual([b.blogId for b in recientes], ["a", "b"])
33
+ self.assertIn("size=2", blogs.req.llamadas[0][1])
34
+
35
+
36
+ if __name__ == "__main__":
37
+ unittest.main()
@@ -0,0 +1,47 @@
1
+ """Las utilidades que no tocan la red: SID, dispositivo, firmas y base64."""
2
+
3
+ import base64
4
+ import json
5
+ import unittest
6
+
7
+ from zarpa.utils.generators import Generator, WSIdGenerator
8
+
9
+
10
+ def sid_de_prueba(datos: dict) -> str:
11
+ """Un SID con la forma de los de AltAmino: 1 byte, el JSON y 20 bytes de firma, en base64 sin relleno."""
12
+ crudo = b"\x02" + json.dumps(datos).encode() + b"\x00" * 20
13
+ return base64.urlsafe_b64encode(crudo).decode().rstrip("=")
14
+
15
+
16
+ class PruebasGenerador(unittest.TestCase):
17
+ def test_datos_del_sid(self):
18
+ sid = sid_de_prueba({"2": "uid-1", "4": "1.2.3.4", "5": 1700000000, "6": 100})
19
+ self.assertEqual(Generator.sid_to_uid(sid), "uid-1")
20
+ self.assertEqual(Generator.sid_to_ip_address(sid), "1.2.3.4")
21
+ self.assertEqual(Generator.sid_to_created_time(sid), 1700000000)
22
+ self.assertEqual(Generator.sid_to_client_type(sid), 100)
23
+
24
+ def test_device_id_es_estable_con_los_mismos_datos(self):
25
+ uno = Generator.gen_deviceId(b"x" * 20)
26
+ self.assertEqual(uno, Generator.gen_deviceId(b"x" * 20))
27
+ self.assertEqual(len(uno), 82)
28
+ self.assertEqual(uno, uno.upper())
29
+ self.assertNotEqual(Generator.gen_deviceId(), Generator.gen_deviceId())
30
+ #actualizar un device id conserva su parte de datos
31
+ self.assertEqual(Generator.update_deviceId(uno), uno)
32
+
33
+ def test_firma_igual_para_lo_mismo(self):
34
+ self.assertEqual(Generator.signature("hola"), Generator.signature(b"hola"))
35
+ self.assertNotEqual(Generator.signature("hola"), Generator.signature("adiós"))
36
+ self.assertEqual(Generator.signature({"a": 1}), Generator.signature({"a": 1}))
37
+
38
+ def test_base64_ida_y_vuelta(self):
39
+ self.assertEqual(Generator.b64_to_bytes(Generator.bytes_to_b64(b"miau")), "miau")
40
+
41
+ def test_ids_del_websocket_no_se_repiten(self):
42
+ ids = WSIdGenerator()
43
+ self.assertNotEqual(ids.next(), ids.next())
44
+
45
+
46
+ if __name__ == "__main__":
47
+ unittest.main()
@@ -0,0 +1,34 @@
1
+ """El paquete en sí: lo que se puede importar y que importarlo no sale a la red."""
2
+
3
+ import subprocess
4
+ import sys
5
+ import unittest
6
+ from importlib.metadata import version
7
+
8
+ import zarpa
9
+
10
+
11
+ class PruebasPaquete(unittest.TestCase):
12
+ def test_version_del_paquete_instalado(self):
13
+ self.assertEqual(zarpa.__version__, version("zarpa"))
14
+
15
+ def test_lo_publico(self):
16
+ for nombre in ("Client", "SubClient", "AsyncClient", "AsyncSubClient", "exceptions", "args",
17
+ "respObject", "set_log_level", "enable_file_logging", "disable_file_logging"):
18
+ self.assertTrue(hasattr(zarpa, nombre), nombre)
19
+
20
+ def test_importar_no_sale_a_la_red(self):
21
+ #con la red cortada, importar tiene que funcionar igual y sin intentar conectar
22
+ codigo = (
23
+ "import socket\n"
24
+ "def corta(*a, **k): raise SystemExit('intentó conectar al importar')\n"
25
+ "socket.socket.connect = corta\n"
26
+ "socket.create_connection = corta\n"
27
+ "import zarpa\n"
28
+ )
29
+ resultado = subprocess.run([sys.executable, "-c", codigo], capture_output=True, text=True)
30
+ self.assertEqual(resultado.returncode, 0, resultado.stderr or resultado.stdout)
31
+
32
+
33
+ if __name__ == "__main__":
34
+ unittest.main()
@@ -0,0 +1,58 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib.metadata import PackageNotFoundError
4
+ from importlib.metadata import version as _version
5
+
6
+ from zarpa.utils import log, loglevel
7
+
8
+ from zarpa.utils.generators import Generator
9
+ import zarpa.utils.exceptions as exceptions
10
+ import zarpa.objects.resp as respObject
11
+ import zarpa.objects.args as args
12
+
13
+
14
+ from zarpa.clients.client import Client
15
+ from zarpa.clients.sub_client import SubClient
16
+
17
+ from zarpa.clients._async.client import Client as AsyncClient
18
+ from zarpa.clients._async.sub_client import SubClient as AsyncSubClient
19
+
20
+
21
+
22
+
23
+ def set_log_level(level: int | str = loglevel.INFO):
24
+ """
25
+ Sets the logging level.
26
+
27
+ :param level: The new logging level (loglevel.DISABLE, loglevel.INFO ...).
28
+ """
29
+ log.set_level(level)
30
+
31
+
32
+ def enable_file_logging(log_file: str = 'zarpa.log'):
33
+ """
34
+ Enables logging to a file.
35
+
36
+ :param log_file: The file where logs will be written.
37
+ """
38
+ log.enable_file_logging(log_file)
39
+
40
+
41
+ def disable_file_logging():
42
+ """
43
+ Disables logging to a file.
44
+ """
45
+ if log.log_to_file:
46
+ log.log_to_file = False
47
+ log.logger.removeHandler(log.logger.handlers[-1])
48
+
49
+
50
+ try:
51
+ __version__ = _version("zarpa")
52
+ except PackageNotFoundError:
53
+ #sin instalar (por ejemplo, ejecutando desde el código fuente)
54
+ __version__ = "0.1.0"
55
+ __title__ = "zarpa"
56
+ __license__ = "MIT"
57
+ __copyright__ = "Copyright 2025 alx0rr; Copyright 2026 mihzuk"
58
+ __project_link__ = "https://github.com/mihzuk/zarpa"
@@ -0,0 +1,5 @@
1
+ from .auth import AuthModule
2
+ from .chats import GlobalChatsModule
3
+ from .altteam import AltTeamModule
4
+ from .communities import GlobalCommunitiesModule
5
+ from .users import GlobalUsersModule
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+ from zarpa.api.base import AsyncBaseClass
3
+ from zarpa.objects import args, resp
4
+
5
+
6
+ class AltTeamModule(AsyncBaseClass):
7
+
8
+ async def reset_password_by_support(self, email: str) -> dict:
9
+ """
10
+ Reset password by support.
11
+
12
+ **Parameters**
13
+ - email : Email of the account for sending new password.
14
+ """
15
+
16
+ result = await self.req.make_async_request("POST", "/g/s/altteam/reset-password", {
17
+ "email": email,
18
+ })
19
+
20
+ return await result.json()
21
+
22
+ async def link_telegram(self, telegram_id: int, amino_id: str | None = None) -> dict:
23
+ """
24
+ Link Telegram ID to AltAmino account.
25
+ """
26
+ payload = {"telegramId": telegram_id}
27
+ if amino_id:
28
+ payload["aminoId"] = amino_id
29
+
30
+ result = await self.req.make_async_request("POST", "/g/s/altteam/telegram/link", payload)
31
+ return await result.json()
32
+
33
+ async def unlink_telegram(self, amino_id: str | None = None) -> dict:
34
+ """
35
+ Unlink Telegram ID from AltAmino account.
36
+ """
37
+ payload = {}
38
+ if amino_id:
39
+ payload["aminoId"] = amino_id
40
+
41
+ result = await self.req.make_async_request("POST", "/g/s/altteam/telegram/unlink", payload)
42
+ return await result.json()
@@ -0,0 +1,74 @@
1
+ from __future__ import annotations
2
+
3
+ from zarpa.api.base import AsyncBaseClass
4
+ from zarpa.utils.generators import Generator
5
+
6
+ from zarpa import args, respObject
7
+ from zarpa.utils import exceptions
8
+
9
+
10
+ class AuthModule(AsyncBaseClass):
11
+
12
+
13
+ async def login(self, email: str, password: str | None = None, secret: str | None = None, client_type: int = args.ClientTypes.User) -> respObject.AuthData:
14
+ """
15
+ Login into an account.
16
+
17
+ **Parameters**
18
+ - email : Email of the account.
19
+ - password : Password of the account.
20
+ - secret : secret of the account
21
+ - client_type: Type of Client.
22
+ """
23
+ if password is None and secret is None: raise exceptions.SpecifyType("Either password or secret must be provided.")
24
+ result = await self.req.make_async_request("POST", "/g/s/auth/login", {
25
+ "email": email,
26
+ "v": 2,
27
+ "secret": secret if secret else f"0 {password}",
28
+ "deviceID": self.deviceId,
29
+ "clientType": client_type,
30
+ "action": "normal",
31
+ })
32
+
33
+ data = await result.json()
34
+ self.me = respObject.AuthData(data)
35
+
36
+ self.set_sid(self.me.sid)
37
+ self.set_userId(self.me.auid)
38
+ await self.ws_connect()
39
+ return self.me
40
+
41
+ async def get_account_info(self) -> respObject.UserProfile:
42
+ """
43
+ Getting account info about you.
44
+ """
45
+ return respObject.UserProfile(await (await self.req.make_async_request("GET", "/g/s/account")).json())
46
+
47
+
48
+ async def login_sid(self, sid: str) -> respObject.AuthData:
49
+ """
50
+ Login into an account.
51
+
52
+ **Parameters**
53
+ - sid : auth sid
54
+ """
55
+ self.set_sid(sid)
56
+ self.set_userId(Generator.sid_to_uid(sid))
57
+ await self.ws_connect()
58
+ self.me = respObject.AuthData({"auid": self.userId, "sid": self.sid})
59
+ return self.me
60
+
61
+
62
+ async def logout(self, client_type: int = args.ClientTypes.User) -> respObject.BaseObject:
63
+ """
64
+ Logout from an account.
65
+ """
66
+ result = await (await self.req.make_async_request("POST", "/g/s/auth/logout", {
67
+ "deviceID": self.deviceId,
68
+ "clientType": client_type#Generator.sid_to_client_type(self.sid),
69
+ })).json()
70
+ self.set_sid(None)
71
+ self.set_userId(None)
72
+ self.me = respObject.AuthData({})
73
+ await self.ws_disconnect()
74
+ return respObject.BaseObject(result)