xyz-bale 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.
- xyz_bale-0.1.0/LICENSE +21 -0
- xyz_bale-0.1.0/PKG-INFO +115 -0
- xyz_bale-0.1.0/README.md +92 -0
- xyz_bale-0.1.0/pyproject.toml +31 -0
- xyz_bale-0.1.0/setup.cfg +4 -0
- xyz_bale-0.1.0/setup.py +30 -0
- xyz_bale-0.1.0/xyz_bale/__init__.py +171 -0
- xyz_bale-0.1.0/xyz_bale/api.py +95 -0
- xyz_bale-0.1.0/xyz_bale/client.py +4846 -0
- xyz_bale-0.1.0/xyz_bale/dispatcher.py +145 -0
- xyz_bale-0.1.0/xyz_bale/enums.py +137 -0
- xyz_bale-0.1.0/xyz_bale/errors.py +125 -0
- xyz_bale-0.1.0/xyz_bale/events.py +409 -0
- xyz_bale-0.1.0/xyz_bale/extended_methods.py +12679 -0
- xyz_bale-0.1.0/xyz_bale/filters.py +395 -0
- xyz_bale-0.1.0/xyz_bale/formatting.py +62 -0
- xyz_bale-0.1.0/xyz_bale/fsm.py +133 -0
- xyz_bale-0.1.0/xyz_bale/keyboards.py +151 -0
- xyz_bale-0.1.0/xyz_bale/methods.py +631 -0
- xyz_bale-0.1.0/xyz_bale/models.py +382 -0
- xyz_bale-0.1.0/xyz_bale/proto/__init__.py +39 -0
- xyz_bale-0.1.0/xyz_bale/proto/codec.py +105 -0
- xyz_bale-0.1.0/xyz_bale/proto/recovered_pb2.py +572 -0
- xyz_bale-0.1.0/xyz_bale/proto/request_pb2.py +1537 -0
- xyz_bale-0.1.0/xyz_bale/proto/response_pb2.py +1178 -0
- xyz_bale-0.1.0/xyz_bale/proto/struct_pb2.py +1852 -0
- xyz_bale-0.1.0/xyz_bale/protocol.py +254 -0
- xyz_bale-0.1.0/xyz_bale/py.typed +1 -0
- xyz_bale-0.1.0/xyz_bale/recovered.py +164 -0
- xyz_bale-0.1.0/xyz_bale/recovered_methods.py +574 -0
- xyz_bale-0.1.0/xyz_bale/rpc.py +227 -0
- xyz_bale-0.1.0/xyz_bale/rtc.py +320 -0
- xyz_bale-0.1.0/xyz_bale/services.py +3403 -0
- xyz_bale-0.1.0/xyz_bale/session.py +449 -0
- xyz_bale-0.1.0/xyz_bale/transports/__init__.py +8 -0
- xyz_bale-0.1.0/xyz_bale/transports/grpc.py +349 -0
- xyz_bale-0.1.0/xyz_bale/transports/websocket.py +330 -0
- xyz_bale-0.1.0/xyz_bale/types/__init__.py +119 -0
- xyz_bale-0.1.0/xyz_bale/types/base.py +81 -0
- xyz_bale-0.1.0/xyz_bale/types/chat.py +166 -0
- xyz_bale-0.1.0/xyz_bale/types/dialog.py +73 -0
- xyz_bale-0.1.0/xyz_bale/types/entities.py +40 -0
- xyz_bale-0.1.0/xyz_bale/types/events.py +305 -0
- xyz_bale-0.1.0/xyz_bale/types/keyboard.py +19 -0
- xyz_bale-0.1.0/xyz_bale/types/media.py +185 -0
- xyz_bale-0.1.0/xyz_bale/types/message.py +620 -0
- xyz_bale-0.1.0/xyz_bale/types/permissions.py +66 -0
- xyz_bale-0.1.0/xyz_bale/types/user.py +112 -0
- xyz_bale-0.1.0/xyz_bale/types/wallet.py +77 -0
- xyz_bale-0.1.0/xyz_bale.egg-info/PKG-INFO +115 -0
- xyz_bale-0.1.0/xyz_bale.egg-info/SOURCES.txt +52 -0
- xyz_bale-0.1.0/xyz_bale.egg-info/dependency_links.txt +1 -0
- xyz_bale-0.1.0/xyz_bale.egg-info/requires.txt +6 -0
- xyz_bale-0.1.0/xyz_bale.egg-info/top_level.txt +1 -0
xyz_bale-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xyz-bale
|
|
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.
|
xyz_bale-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xyz-bale
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A friendly Python client for Bale accounts (xyz-bale rebrand of BaleNova)
|
|
5
|
+
Author: xyz-bale
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: bale,bale-bot,bale-userbot,xyz-bale,telegram,messaging
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Communications :: Chat
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
18
|
+
Requires-Dist: black; extra == "dev"
|
|
19
|
+
Requires-Dist: isort; extra == "dev"
|
|
20
|
+
Requires-Dist: mypy; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
|
|
24
|
+
# xyz-bale
|
|
25
|
+
|
|
26
|
+
A friendly Python client for Bale accounts. This is a full rebrand of BaleNova
|
|
27
|
+
(`balenova`) under the name **xyz-bale**, re-exporting the complete `bale`
|
|
28
|
+
client with every feature: messaging, groups, calls/meet links, FSM, keyboards,
|
|
29
|
+
LiveKit RTC, recovered RPCs, session extraction from browsers, and more.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install xyz-bale
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or from source:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import asyncio
|
|
47
|
+
from xyz_bale import Client
|
|
48
|
+
|
|
49
|
+
async def main():
|
|
50
|
+
# ورود با شماره موبايل (سشن خودکار در پوشه sessions ذخیره میشود)
|
|
51
|
+
async with Client("98991234567") as client:
|
|
52
|
+
result = await client.generate_call_link(
|
|
53
|
+
is_public=True,
|
|
54
|
+
title="جلسهxyz",
|
|
55
|
+
)
|
|
56
|
+
print(result)
|
|
57
|
+
|
|
58
|
+
asyncio.run(main())
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
- User-session client (Bale account / userbot)
|
|
64
|
+
- Send/receive messages, media, files
|
|
65
|
+
- Group management and invite links
|
|
66
|
+
- Calls / meet links (`generate_call_link`, `start_group_call`, ...)
|
|
67
|
+
- FSM (finite state machine) for conversation states
|
|
68
|
+
- Keyboards (reply / inline)
|
|
69
|
+
- LiveKit RTC for group calls
|
|
70
|
+
- Recovered RPCs and protocol API
|
|
71
|
+
- Session extraction from Firefox / Chromium browsers
|
|
72
|
+
- 610+ typed RPCs across 52 services
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
See `examples/`:
|
|
77
|
+
- `examples/make_meet.py` — generate a public meet link with a custom title
|
|
78
|
+
|
|
79
|
+
## Project structure
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
xyz_bale/ # complete Bale client source (rebranded)
|
|
83
|
+
api.py # ProtocolAPI namespace
|
|
84
|
+
client.py # Client (user session)
|
|
85
|
+
dispatcher.py # event dispatcher
|
|
86
|
+
enums.py # enums (ChatType, CallMode, ...)
|
|
87
|
+
errors.py # BaleError, AuthenticationError, BaleRpcError, ...
|
|
88
|
+
events.py # NewMessage, Update, RawUpdate, build_updates
|
|
89
|
+
extended_methods.py# 690+ typed RPC wrapper methods
|
|
90
|
+
filters.py # composable message filters
|
|
91
|
+
formatting.py # bold, italic, code, link, spoiler, ...
|
|
92
|
+
fsm.py # StatesGroup, MemoryStorage, FSMContext
|
|
93
|
+
keyboards.py # inline / reply keyboard builders
|
|
94
|
+
methods.py # METHODS registry (service -> request/response)
|
|
95
|
+
models.py # Chat, User, Message, Wallet, helpers
|
|
96
|
+
protocol.py # ProtocolRecorder (diagnostic trace)
|
|
97
|
+
recovered.py # RecoveredAPI / RecoveredService
|
|
98
|
+
recovered_methods.py# recovered RPC registry
|
|
99
|
+
rpc.py # ServiceBase, populate, build_request
|
|
100
|
+
rtc.py # CallRtcConnection, LiveKit join-request decode
|
|
101
|
+
services.py # generated service classes (610 RPCs, 52 services)
|
|
102
|
+
session.py # Session, SessionStorage, browser extraction
|
|
103
|
+
transports/ # GrpcTransport, WebSocketTransport
|
|
104
|
+
types/ # Serializable, Chat, Message, User, Wallet, ...
|
|
105
|
+
proto/ # protobuf definitions and generated code
|
|
106
|
+
pyproject.toml
|
|
107
|
+
setup.py
|
|
108
|
+
README.md
|
|
109
|
+
LICENSE
|
|
110
|
+
examples/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT — see `LICENSE`.
|
xyz_bale-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# xyz-bale
|
|
2
|
+
|
|
3
|
+
A friendly Python client for Bale accounts. This is a full rebrand of BaleNova
|
|
4
|
+
(`balenova`) under the name **xyz-bale**, re-exporting the complete `bale`
|
|
5
|
+
client with every feature: messaging, groups, calls/meet links, FSM, keyboards,
|
|
6
|
+
LiveKit RTC, recovered RPCs, session extraction from browsers, and more.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install xyz-bale
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or from source:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install -e .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import asyncio
|
|
24
|
+
from xyz_bale import Client
|
|
25
|
+
|
|
26
|
+
async def main():
|
|
27
|
+
# ورود با شماره موبايل (سشن خودکار در پوشه sessions ذخیره میشود)
|
|
28
|
+
async with Client("98991234567") as client:
|
|
29
|
+
result = await client.generate_call_link(
|
|
30
|
+
is_public=True,
|
|
31
|
+
title="جلسهxyz",
|
|
32
|
+
)
|
|
33
|
+
print(result)
|
|
34
|
+
|
|
35
|
+
asyncio.run(main())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- User-session client (Bale account / userbot)
|
|
41
|
+
- Send/receive messages, media, files
|
|
42
|
+
- Group management and invite links
|
|
43
|
+
- Calls / meet links (`generate_call_link`, `start_group_call`, ...)
|
|
44
|
+
- FSM (finite state machine) for conversation states
|
|
45
|
+
- Keyboards (reply / inline)
|
|
46
|
+
- LiveKit RTC for group calls
|
|
47
|
+
- Recovered RPCs and protocol API
|
|
48
|
+
- Session extraction from Firefox / Chromium browsers
|
|
49
|
+
- 610+ typed RPCs across 52 services
|
|
50
|
+
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
53
|
+
See `examples/`:
|
|
54
|
+
- `examples/make_meet.py` — generate a public meet link with a custom title
|
|
55
|
+
|
|
56
|
+
## Project structure
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
xyz_bale/ # complete Bale client source (rebranded)
|
|
60
|
+
api.py # ProtocolAPI namespace
|
|
61
|
+
client.py # Client (user session)
|
|
62
|
+
dispatcher.py # event dispatcher
|
|
63
|
+
enums.py # enums (ChatType, CallMode, ...)
|
|
64
|
+
errors.py # BaleError, AuthenticationError, BaleRpcError, ...
|
|
65
|
+
events.py # NewMessage, Update, RawUpdate, build_updates
|
|
66
|
+
extended_methods.py# 690+ typed RPC wrapper methods
|
|
67
|
+
filters.py # composable message filters
|
|
68
|
+
formatting.py # bold, italic, code, link, spoiler, ...
|
|
69
|
+
fsm.py # StatesGroup, MemoryStorage, FSMContext
|
|
70
|
+
keyboards.py # inline / reply keyboard builders
|
|
71
|
+
methods.py # METHODS registry (service -> request/response)
|
|
72
|
+
models.py # Chat, User, Message, Wallet, helpers
|
|
73
|
+
protocol.py # ProtocolRecorder (diagnostic trace)
|
|
74
|
+
recovered.py # RecoveredAPI / RecoveredService
|
|
75
|
+
recovered_methods.py# recovered RPC registry
|
|
76
|
+
rpc.py # ServiceBase, populate, build_request
|
|
77
|
+
rtc.py # CallRtcConnection, LiveKit join-request decode
|
|
78
|
+
services.py # generated service classes (610 RPCs, 52 services)
|
|
79
|
+
session.py # Session, SessionStorage, browser extraction
|
|
80
|
+
transports/ # GrpcTransport, WebSocketTransport
|
|
81
|
+
types/ # Serializable, Chat, Message, User, Wallet, ...
|
|
82
|
+
proto/ # protobuf definitions and generated code
|
|
83
|
+
pyproject.toml
|
|
84
|
+
setup.py
|
|
85
|
+
README.md
|
|
86
|
+
LICENSE
|
|
87
|
+
examples/
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT — see `LICENSE`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xyz-bale"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A friendly Python client for Bale accounts (xyz-bale rebrand of BaleNova)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "xyz-bale"}]
|
|
13
|
+
keywords = ["bale", "bale-bot", "bale-userbot", "xyz-bale", "telegram", "messaging"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Topic :: Communications :: Chat",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = [
|
|
24
|
+
"pytest>=7.0",
|
|
25
|
+
"black",
|
|
26
|
+
"isort",
|
|
27
|
+
"mypy",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
include = ["xyz_bale*"]
|
xyz_bale-0.1.0/setup.cfg
ADDED
xyz_bale-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="xyz-bale",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
description="A friendly Python client for Bale accounts (xyz-bale rebrand of BaleNova)",
|
|
7
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
|
8
|
+
long_description_content_type="text/markdown",
|
|
9
|
+
packages=find_packages(include=["xyz_bale*"]),
|
|
10
|
+
python_requires=">=3.9",
|
|
11
|
+
install_requires=[
|
|
12
|
+
"httpx",
|
|
13
|
+
"protobuf",
|
|
14
|
+
"websockets",
|
|
15
|
+
],
|
|
16
|
+
extras_require={
|
|
17
|
+
"voice": ["livekit"],
|
|
18
|
+
"dev": ["pytest>=7.0", "black", "isort", "mypy"],
|
|
19
|
+
},
|
|
20
|
+
classifiers=[
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
"Topic :: Communications :: Chat",
|
|
26
|
+
],
|
|
27
|
+
project_urls={
|
|
28
|
+
"Source": "https://github.com/xyz-bale/xyz-bale",
|
|
29
|
+
},
|
|
30
|
+
)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""xyz-bale: a friendly Python client for Bale accounts."""
|
|
2
|
+
|
|
3
|
+
from xyz_bale import enums, events, filters, formatting, types
|
|
4
|
+
from xyz_bale.api import ProtocolAPI
|
|
5
|
+
from xyz_bale.client import Client
|
|
6
|
+
from xyz_bale.errors import (
|
|
7
|
+
AuthenticationError,
|
|
8
|
+
BaleError,
|
|
9
|
+
BaleRpcError,
|
|
10
|
+
ClientStateError,
|
|
11
|
+
RpcStatus,
|
|
12
|
+
)
|
|
13
|
+
from xyz_bale.events import MessageEdited, MessageSent, NewMessage, RawUpdate, Update
|
|
14
|
+
from xyz_bale.filters import Filter
|
|
15
|
+
from xyz_bale.formatting import (
|
|
16
|
+
bold,
|
|
17
|
+
code,
|
|
18
|
+
code_block,
|
|
19
|
+
escape_markdown,
|
|
20
|
+
italic,
|
|
21
|
+
link,
|
|
22
|
+
pre,
|
|
23
|
+
spoiler,
|
|
24
|
+
)
|
|
25
|
+
from xyz_bale.fsm import FSMContext, MemoryStorage, State, StatesGroup
|
|
26
|
+
from xyz_bale.keyboards import (
|
|
27
|
+
InlineKeyboardButton,
|
|
28
|
+
InlineKeyboardMarkup,
|
|
29
|
+
KeyboardButton,
|
|
30
|
+
ReplyKeyboardMarkup,
|
|
31
|
+
ReplyKeyboardRemove,
|
|
32
|
+
)
|
|
33
|
+
from xyz_bale.methods import METHODS
|
|
34
|
+
from xyz_bale.models import (
|
|
35
|
+
CallMode,
|
|
36
|
+
CallRecordQuality,
|
|
37
|
+
Chat,
|
|
38
|
+
ChatType,
|
|
39
|
+
DefaultResponse,
|
|
40
|
+
GiftOpening,
|
|
41
|
+
GiftPacket,
|
|
42
|
+
GivingType,
|
|
43
|
+
Message,
|
|
44
|
+
MessageEntity,
|
|
45
|
+
MessageEntityType,
|
|
46
|
+
OtherMessage,
|
|
47
|
+
PacketResponse,
|
|
48
|
+
PeerSource,
|
|
49
|
+
PrivacyStatus,
|
|
50
|
+
PrivacyType,
|
|
51
|
+
ReportKind,
|
|
52
|
+
User,
|
|
53
|
+
Wallet,
|
|
54
|
+
WalletResponse,
|
|
55
|
+
Winner,
|
|
56
|
+
chat_id_to_peer_id,
|
|
57
|
+
chat_type_to_peer_type,
|
|
58
|
+
convert_chat_id,
|
|
59
|
+
model_to_dict,
|
|
60
|
+
model_to_json,
|
|
61
|
+
parse_chat_id,
|
|
62
|
+
peer_id_to_chat_id,
|
|
63
|
+
toggle_chat_id,
|
|
64
|
+
)
|
|
65
|
+
from xyz_bale.proto import schema as pb
|
|
66
|
+
from xyz_bale.recovered import (
|
|
67
|
+
RECOVERED_METHODS,
|
|
68
|
+
RECOVERED_RPCS,
|
|
69
|
+
RecoveredAPI,
|
|
70
|
+
RecoveredService,
|
|
71
|
+
)
|
|
72
|
+
from xyz_bale.rtc import (
|
|
73
|
+
CallRtcConnection,
|
|
74
|
+
CallRtcPermissions,
|
|
75
|
+
LiveKitJoinRequest,
|
|
76
|
+
call_rtc_connection_from_group_call,
|
|
77
|
+
decode_livekit_join_request,
|
|
78
|
+
parse_call_wss_url,
|
|
79
|
+
)
|
|
80
|
+
from xyz_bale.services import ALL_RPCS, SERVICE_CLASSES
|
|
81
|
+
from xyz_bale.session import Session
|
|
82
|
+
|
|
83
|
+
__version__ = "0.1.0"
|
|
84
|
+
XyzBaleClient = Client
|
|
85
|
+
BaleClient = Client
|
|
86
|
+
|
|
87
|
+
__all__ = [
|
|
88
|
+
"ALL_RPCS",
|
|
89
|
+
"METHODS",
|
|
90
|
+
"RECOVERED_METHODS",
|
|
91
|
+
"RECOVERED_RPCS",
|
|
92
|
+
"SERVICE_CLASSES",
|
|
93
|
+
"AuthenticationError",
|
|
94
|
+
"BaleClient",
|
|
95
|
+
"XyzBaleClient",
|
|
96
|
+
"BaleError",
|
|
97
|
+
"BaleRpcError",
|
|
98
|
+
"CallMode",
|
|
99
|
+
"CallRecordQuality",
|
|
100
|
+
"CallRtcConnection",
|
|
101
|
+
"CallRtcPermissions",
|
|
102
|
+
"Chat",
|
|
103
|
+
"ChatType",
|
|
104
|
+
"Client",
|
|
105
|
+
"ClientStateError",
|
|
106
|
+
"DefaultResponse",
|
|
107
|
+
"FSMContext",
|
|
108
|
+
"Filter",
|
|
109
|
+
"GiftOpening",
|
|
110
|
+
"GiftPacket",
|
|
111
|
+
"GivingType",
|
|
112
|
+
"InlineKeyboardButton",
|
|
113
|
+
"InlineKeyboardMarkup",
|
|
114
|
+
"KeyboardButton",
|
|
115
|
+
"LiveKitJoinRequest",
|
|
116
|
+
"MemoryStorage",
|
|
117
|
+
"Message",
|
|
118
|
+
"MessageEdited",
|
|
119
|
+
"MessageEntity",
|
|
120
|
+
"MessageEntityType",
|
|
121
|
+
"MessageSent",
|
|
122
|
+
"NewMessage",
|
|
123
|
+
"OtherMessage",
|
|
124
|
+
"PacketResponse",
|
|
125
|
+
"PeerSource",
|
|
126
|
+
"PrivacyStatus",
|
|
127
|
+
"PrivacyType",
|
|
128
|
+
"ProtocolAPI",
|
|
129
|
+
"RawUpdate",
|
|
130
|
+
"RecoveredAPI",
|
|
131
|
+
"RecoveredService",
|
|
132
|
+
"ReplyKeyboardMarkup",
|
|
133
|
+
"ReplyKeyboardRemove",
|
|
134
|
+
"ReportKind",
|
|
135
|
+
"RpcStatus",
|
|
136
|
+
"Session",
|
|
137
|
+
"State",
|
|
138
|
+
"StatesGroup",
|
|
139
|
+
"Update",
|
|
140
|
+
"User",
|
|
141
|
+
"Wallet",
|
|
142
|
+
"WalletResponse",
|
|
143
|
+
"Winner",
|
|
144
|
+
"bold",
|
|
145
|
+
"call_rtc_connection_from_group_call",
|
|
146
|
+
"chat_id_to_peer_id",
|
|
147
|
+
"chat_type_to_peer_type",
|
|
148
|
+
"code",
|
|
149
|
+
"code_block",
|
|
150
|
+
"convert_chat_id",
|
|
151
|
+
"decode_livekit_join_request",
|
|
152
|
+
"enums",
|
|
153
|
+
"escape_markdown",
|
|
154
|
+
"events",
|
|
155
|
+
"filters",
|
|
156
|
+
"formatting",
|
|
157
|
+
"italic",
|
|
158
|
+
"link",
|
|
159
|
+
"model_to_dict",
|
|
160
|
+
"model_to_json",
|
|
161
|
+
"parse_call_wss_url",
|
|
162
|
+
"parse_chat_id",
|
|
163
|
+
"pb",
|
|
164
|
+
"peer_id_to_chat_id",
|
|
165
|
+
"pre",
|
|
166
|
+
"spoiler",
|
|
167
|
+
"toggle_chat_id",
|
|
168
|
+
"types",
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Complete typed Bale Web RPC namespace backed by the main protobuf module."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from xyz_bale.recovered import RECOVERED_RPCS, RecoveredAPI
|
|
8
|
+
from xyz_bale.rpc import _snake_case
|
|
9
|
+
from xyz_bale.services import ALL_RPCS, SERVICE_CLASSES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ProtocolAPI:
|
|
13
|
+
"""Expose every known Bale service and RPC on one client-bound namespace."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, client: Any) -> None:
|
|
16
|
+
self._client = client
|
|
17
|
+
for name, service_class in SERVICE_CLASSES.items():
|
|
18
|
+
setattr(self, name, service_class(client))
|
|
19
|
+
self.recovered = RecoveredAPI(client)
|
|
20
|
+
|
|
21
|
+
def __getattr__(self, name: str) -> Any:
|
|
22
|
+
try:
|
|
23
|
+
return self.__dict__[name]
|
|
24
|
+
except KeyError:
|
|
25
|
+
raise AttributeError(
|
|
26
|
+
f"{self.__class__.__name__!r} object has no attribute {name!r}"
|
|
27
|
+
) from None
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def services(self) -> tuple[str, ...]:
|
|
31
|
+
return tuple(SERVICE_CLASSES)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def rpcs(self) -> tuple[tuple[str, str], ...]:
|
|
35
|
+
return tuple(ALL_RPCS)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def all_rpcs(self) -> tuple[tuple[str, str], ...]:
|
|
39
|
+
"""Return primary and recovered RPCs in one discoverable collection."""
|
|
40
|
+
return tuple(dict.fromkeys((*ALL_RPCS, *RECOVERED_RPCS)))
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def all_services(self) -> tuple[str, ...]:
|
|
44
|
+
"""Return every fully-qualified primary and recovered service name."""
|
|
45
|
+
return tuple(dict.fromkeys(service for service, _method in self.all_rpcs))
|
|
46
|
+
|
|
47
|
+
def has_rpc(self, service: str, method: str) -> bool:
|
|
48
|
+
for candidate_service, candidate_method in self.all_rpcs:
|
|
49
|
+
short_service = _snake_case(candidate_service.rsplit(".", 1)[-1])
|
|
50
|
+
if service not in {candidate_service, short_service}:
|
|
51
|
+
continue
|
|
52
|
+
if method in {candidate_method, _snake_case(candidate_method)}:
|
|
53
|
+
return True
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
async def call(
|
|
57
|
+
self,
|
|
58
|
+
service: str,
|
|
59
|
+
method: str,
|
|
60
|
+
request: Any | None = None,
|
|
61
|
+
/,
|
|
62
|
+
*,
|
|
63
|
+
timeout: float = 10.0,
|
|
64
|
+
**fields: Any,
|
|
65
|
+
) -> Any:
|
|
66
|
+
"""Call a primary or recovered RPC using a short, uniform API.
|
|
67
|
+
|
|
68
|
+
``service`` accepts either a namespace (``"groups"``) or a fully
|
|
69
|
+
qualified service name. Generated CamelCase method names and their
|
|
70
|
+
snake_case aliases are both accepted.
|
|
71
|
+
"""
|
|
72
|
+
namespace = None
|
|
73
|
+
for key, service_class in SERVICE_CLASSES.items():
|
|
74
|
+
if service == key or service == service_class.SERVICE:
|
|
75
|
+
namespace = getattr(self, key)
|
|
76
|
+
break
|
|
77
|
+
if namespace is not None:
|
|
78
|
+
try:
|
|
79
|
+
operation = getattr(namespace, method)
|
|
80
|
+
except AttributeError:
|
|
81
|
+
operation = None
|
|
82
|
+
if operation is not None:
|
|
83
|
+
return await operation(request, _timeout=timeout, **fields)
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
return await self.recovered.call(
|
|
87
|
+
service, method, request, timeout=timeout, **fields
|
|
88
|
+
)
|
|
89
|
+
except LookupError as error:
|
|
90
|
+
raise LookupError(f"unknown Bale RPC {service}.{method}") from error
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
__all__ = ["ALL_RPCS", "SERVICE_CLASSES", "ProtocolAPI"]
|
|
94
|
+
|
|
95
|
+
|