pyrobale 0.3.5__tar.gz → 0.3.7__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.
- pyrobale-0.3.7/.github/ISSUE_TEMPLATE/issue-template-/342/204/271/357/270/217.md +64 -0
- pyrobale-0.3.7/.github/workflows/docs.yml +38 -0
- pyrobale-0.3.7/PKG-INFO +153 -0
- pyrobale-0.3.7/README.md +117 -0
- pyrobale-0.3.7/examples/echo_bot.py +10 -0
- pyrobale-0.3.7/examples/handler_system.py +11 -0
- pyrobale-0.3.7/examples/inline_keyboard.py +20 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyproject.toml +3 -2
- pyrobale-0.3.7/pyrobale/StateMachine/__init__.py +45 -0
- pyrobale-0.3.7/pyrobale/__init__.py +123 -0
- pyrobale-0.3.7/pyrobale/client/__init__.py +1117 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/__init__.py +3 -0
- pyrobale-0.3.7/pyrobale/objects/callbackquery.py +37 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/chatmember.py +5 -4
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/enums.py +16 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/message.py +27 -8
- pyrobale-0.3.7/pyrobale/objects/user.py +22 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/utils.py +0 -1
- pyrobale-0.3.5/PKG-INFO +0 -176
- pyrobale-0.3.5/README.md +0 -141
- pyrobale-0.3.5/pyrobale/__init__.py +0 -3
- pyrobale-0.3.5/pyrobale/client/__init__.py +0 -574
- pyrobale-0.3.5/pyrobale/objects/callbackquery.py +0 -42
- pyrobale-0.3.5/pyrobale/objects/user.py +0 -20
- {pyrobale-0.3.5 → pyrobale-0.3.7}/LICENSE +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/exceptions/__init__.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/exceptions/common.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/animation.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/audio.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/chat.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/chatphoto.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/contact.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/copytextbutton.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/document.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/file.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/inlinekeyboardbutton.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/inlinekeyboardmarkup.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/inputfile.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/inputmedias.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/invoice.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/keyboardbutton.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/labeledprice.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/location.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/messageid.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/photosize.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/precheckoutquery.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/replykeyboardmarkup.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/sticker.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/stickerset.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/successfulpayment.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/update.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/video.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/voice.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/webappdata.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale/objects/webappinfo.py +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobale.png +0 -0
- {pyrobale-0.3.5 → pyrobale-0.3.7}/pyrobaletext.png +0 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
name: Issue template ℹ️
|
3
|
+
about: Report any issue here
|
4
|
+
title: Issue Title
|
5
|
+
labels: ''
|
6
|
+
assignees: Daradege, Code-Wizaard
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
### 🐞 Issue Type
|
11
|
+
|
12
|
+
Please select one:
|
13
|
+
|
14
|
+
- [ ] Bug Report
|
15
|
+
- [ ] Feature Request
|
16
|
+
- [ ] Documentation Improvement
|
17
|
+
- [ ] Question / Help Needed
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
### 📌 Description
|
22
|
+
|
23
|
+
<!-- Clearly describe the issue, suggestion, or question -->
|
24
|
+
|
25
|
+
Example:
|
26
|
+
When using `send_file` with a relative path, it raises `FileNotFoundError` even though the file exists.
|
27
|
+
|
28
|
+
---
|
29
|
+
|
30
|
+
### 🔁 Steps to Reproduce (For Bugs)
|
31
|
+
|
32
|
+
1. ...
|
33
|
+
2. ...
|
34
|
+
3. ...
|
35
|
+
4. ...
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
### ✅ Expected Behavior
|
40
|
+
|
41
|
+
<!-- What did you expect to happen? -->
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
### 📎 Environment Info
|
46
|
+
|
47
|
+
- Python version: e.g., `3.11`
|
48
|
+
- Operating System: e.g., `Linux Mint 21.3 KDE`
|
49
|
+
- PyroBale version: e.g., `0.2.1`
|
50
|
+
- Internet connection / proxy info: e.g., `Direct, no proxy`
|
51
|
+
|
52
|
+
---
|
53
|
+
|
54
|
+
### 📝 Code Sample (If Applicable)
|
55
|
+
|
56
|
+
```python
|
57
|
+
# Include a minimal reproducible code sample if relevant
|
58
|
+
````
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
### 🙏 Additional Notes
|
63
|
+
|
64
|
+
<!-- Any extra notes, thanks, or related info -->
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: Build and Deploy Docs
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
docs:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- name: Checkout repository
|
14
|
+
uses: actions/checkout@v4
|
15
|
+
with:
|
16
|
+
fetch-depth: 0
|
17
|
+
|
18
|
+
- name: Set up Python
|
19
|
+
uses: actions/setup-python@v5
|
20
|
+
with:
|
21
|
+
python-version: '3.11'
|
22
|
+
|
23
|
+
- name: Install dependencies
|
24
|
+
run: |
|
25
|
+
pip install pdoc aiohttp
|
26
|
+
|
27
|
+
- name: Generate documentation
|
28
|
+
run: |
|
29
|
+
pdoc pyrobale --output-dir docs --docformat google
|
30
|
+
|
31
|
+
- name: Deploy to docs branch
|
32
|
+
uses: peaceiris/actions-gh-pages@v3
|
33
|
+
with:
|
34
|
+
deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
|
35
|
+
external_repository: pyrobale/docs
|
36
|
+
publish_branch: docs
|
37
|
+
publish_dir: ./docs
|
38
|
+
commit_message: "Auto-generate docs from ${{ github.sha }}"
|
pyrobale-0.3.7/PKG-INFO
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pyrobale
|
3
|
+
Version: 0.3.7
|
4
|
+
Summary: A python wrapper for bale api
|
5
|
+
Project-URL: github, https://github.com/pyrobale/pyrobale
|
6
|
+
Project-URL: website, https://pyrobale.github.io
|
7
|
+
Author-email: Ali Safamanesh <darg.q.a.a@gmail.com>, Aydin Rahbaran <codewizaard9@gmail.com>
|
8
|
+
License: MIT License
|
9
|
+
|
10
|
+
Copyright (c) 2025 Ali Safamanesh
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
14
|
+
in the Software without restriction, including without limitation the rights
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
17
|
+
furnished to do so, subject to the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
20
|
+
copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
28
|
+
SOFTWARE.
|
29
|
+
License-File: LICENSE
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
31
|
+
Classifier: Operating System :: OS Independent
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
33
|
+
Requires-Python: >=3.9
|
34
|
+
Requires-Dist: aiohttp
|
35
|
+
Description-Content-Type: text/markdown
|
36
|
+
|
37
|
+

|
38
|
+
|
39
|
+
# Bale Bot API Python Library
|
40
|
+
|
41
|
+
A modern, easy-to-use Python wrapper for the Bale Bot API that makes building Bale bots simple and intuitive.
|
42
|
+
|
43
|
+
## Features
|
44
|
+
|
45
|
+
- 🚀 **Simple & Intuitive** - Clean, Pythonic API design
|
46
|
+
- 📨 **Full Message Support** - Text, photos, videos, documents, and more
|
47
|
+
- ⌨️ **Interactive Elements** - Inline keyboards, reply keyboards, and buttons
|
48
|
+
- 🔄 **Real-time Updates** - Webhook and polling support
|
49
|
+
- 📁 **File Handling** - Easy upload and download of media files
|
50
|
+
- 🛡️ **Error Handling** - Comprehensive exception handling
|
51
|
+
- 📖 **Type Hints** - Full typing support for better development experience
|
52
|
+
- ⚡ **Async Support** - Both synchronous and asynchronous operations
|
53
|
+
|
54
|
+
## Installation
|
55
|
+
|
56
|
+
```bash
|
57
|
+
pip install pyrobale
|
58
|
+
```
|
59
|
+
|
60
|
+
## Quick Start
|
61
|
+
|
62
|
+
```python
|
63
|
+
from pyrobale.client import Client
|
64
|
+
from pyrobale.objects import Message, UpdatesTypes
|
65
|
+
|
66
|
+
bot = Client("YOUR_BOT_TOKEN")
|
67
|
+
|
68
|
+
@bot.on_message()
|
69
|
+
async def message_handler(message: User):
|
70
|
+
await message.reply("Hello, world!")
|
71
|
+
|
72
|
+
bot.run()
|
73
|
+
```
|
74
|
+
|
75
|
+
## Examples
|
76
|
+
|
77
|
+
### Conversation Bot
|
78
|
+
```python
|
79
|
+
from pyrobale.objects import *
|
80
|
+
from pyrobale.client import Client, Message, UpdatesTypes
|
81
|
+
import asyncio
|
82
|
+
|
83
|
+
client = Client("YOUR_BOT_TOKEN")
|
84
|
+
|
85
|
+
async def handle_message(message: Message):
|
86
|
+
if message.text == "/start":
|
87
|
+
await message.reply("سلام! من یک ربات PyRoBale هستم!")
|
88
|
+
await client.wait_for(UpdatesTypes.MESSAGE)
|
89
|
+
await message.reply("Okay! wait_for Test Compeleted")
|
90
|
+
|
91
|
+
client.add_handler(UpdatesTypes.MESSAGE, handle_message)
|
92
|
+
|
93
|
+
client.run()
|
94
|
+
```
|
95
|
+
|
96
|
+
### Echo Bot
|
97
|
+
```python
|
98
|
+
from pyrobale.client import Client
|
99
|
+
from pyrobale.objects import Message, UpdatesTypes
|
100
|
+
|
101
|
+
bot = Client("YOUR_BOT_TOKEN")
|
102
|
+
|
103
|
+
@bot.on_message()
|
104
|
+
async def message_handler(message: Message):
|
105
|
+
await message.reply(message.text)
|
106
|
+
|
107
|
+
bot.run()
|
108
|
+
```
|
109
|
+
|
110
|
+
### Inline Keyboard
|
111
|
+
```python
|
112
|
+
from pyrobale.client import Client
|
113
|
+
from pyrobale.objects import Message, UpdatesTypes, InlineKeyboardButton, InlineKeyboardMarkup, CopyTextButton
|
114
|
+
|
115
|
+
bot = Client("YOUR_BOT_TOKEN")
|
116
|
+
async def message_handler(message: Message):
|
117
|
+
buttons = InlineKeyboardMarkup()
|
118
|
+
buttons.add_button("URL", url="https://google.com")
|
119
|
+
buttons.add_button("Callback", callback_data="callback")
|
120
|
+
buttons.add_row()
|
121
|
+
buttons.add_button("WebApp", web_app="https://daradege.ir")
|
122
|
+
buttons.add_button("Copy", copy_text_button=CopyTextButton("TEXT"))
|
123
|
+
await message.reply("Hello, world!", reply_markup=buttons)
|
124
|
+
```
|
125
|
+
|
126
|
+
|
127
|
+
## Core Abilities
|
128
|
+
|
129
|
+
- **Message Handling** - Process text, commands, and media messages
|
130
|
+
- **Callback Queries** - Handle inline keyboard interactions
|
131
|
+
- **File Operations** - Send and receive photos, videos, documents
|
132
|
+
- **Chat Management** - Get chat info, member management
|
133
|
+
- **Custom Keyboards** - Create interactive user interfaces
|
134
|
+
- **Webhook Support** - Production-ready webhook handling
|
135
|
+
- **Middleware Support** - Add custom processing layers
|
136
|
+
|
137
|
+
## Documentation
|
138
|
+
|
139
|
+
For detailed documentation and advanced usage, visit our [documentation site](https://pyrobale.readthedocs.io).
|
140
|
+
|
141
|
+
## Contributing
|
142
|
+
|
143
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
144
|
+
|
145
|
+
## License
|
146
|
+
|
147
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
148
|
+
|
149
|
+
## Support
|
150
|
+
|
151
|
+
- 📖 [Documentation](https://pyrobale.readthedocs.io)
|
152
|
+
- 🐛 [Issue Tracker](https://github.com/pyrobale/pyrobale/issues)
|
153
|
+
- 💬 [Discussions](https://github.com/pyrobale/pyrobale/discussions)
|
pyrobale-0.3.7/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+

|
2
|
+
|
3
|
+
# Bale Bot API Python Library
|
4
|
+
|
5
|
+
A modern, easy-to-use Python wrapper for the Bale Bot API that makes building Bale bots simple and intuitive.
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- 🚀 **Simple & Intuitive** - Clean, Pythonic API design
|
10
|
+
- 📨 **Full Message Support** - Text, photos, videos, documents, and more
|
11
|
+
- ⌨️ **Interactive Elements** - Inline keyboards, reply keyboards, and buttons
|
12
|
+
- 🔄 **Real-time Updates** - Webhook and polling support
|
13
|
+
- 📁 **File Handling** - Easy upload and download of media files
|
14
|
+
- 🛡️ **Error Handling** - Comprehensive exception handling
|
15
|
+
- 📖 **Type Hints** - Full typing support for better development experience
|
16
|
+
- ⚡ **Async Support** - Both synchronous and asynchronous operations
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
```bash
|
21
|
+
pip install pyrobale
|
22
|
+
```
|
23
|
+
|
24
|
+
## Quick Start
|
25
|
+
|
26
|
+
```python
|
27
|
+
from pyrobale.client import Client
|
28
|
+
from pyrobale.objects import Message, UpdatesTypes
|
29
|
+
|
30
|
+
bot = Client("YOUR_BOT_TOKEN")
|
31
|
+
|
32
|
+
@bot.on_message()
|
33
|
+
async def message_handler(message: User):
|
34
|
+
await message.reply("Hello, world!")
|
35
|
+
|
36
|
+
bot.run()
|
37
|
+
```
|
38
|
+
|
39
|
+
## Examples
|
40
|
+
|
41
|
+
### Conversation Bot
|
42
|
+
```python
|
43
|
+
from pyrobale.objects import *
|
44
|
+
from pyrobale.client import Client, Message, UpdatesTypes
|
45
|
+
import asyncio
|
46
|
+
|
47
|
+
client = Client("YOUR_BOT_TOKEN")
|
48
|
+
|
49
|
+
async def handle_message(message: Message):
|
50
|
+
if message.text == "/start":
|
51
|
+
await message.reply("سلام! من یک ربات PyRoBale هستم!")
|
52
|
+
await client.wait_for(UpdatesTypes.MESSAGE)
|
53
|
+
await message.reply("Okay! wait_for Test Compeleted")
|
54
|
+
|
55
|
+
client.add_handler(UpdatesTypes.MESSAGE, handle_message)
|
56
|
+
|
57
|
+
client.run()
|
58
|
+
```
|
59
|
+
|
60
|
+
### Echo Bot
|
61
|
+
```python
|
62
|
+
from pyrobale.client import Client
|
63
|
+
from pyrobale.objects import Message, UpdatesTypes
|
64
|
+
|
65
|
+
bot = Client("YOUR_BOT_TOKEN")
|
66
|
+
|
67
|
+
@bot.on_message()
|
68
|
+
async def message_handler(message: Message):
|
69
|
+
await message.reply(message.text)
|
70
|
+
|
71
|
+
bot.run()
|
72
|
+
```
|
73
|
+
|
74
|
+
### Inline Keyboard
|
75
|
+
```python
|
76
|
+
from pyrobale.client import Client
|
77
|
+
from pyrobale.objects import Message, UpdatesTypes, InlineKeyboardButton, InlineKeyboardMarkup, CopyTextButton
|
78
|
+
|
79
|
+
bot = Client("YOUR_BOT_TOKEN")
|
80
|
+
async def message_handler(message: Message):
|
81
|
+
buttons = InlineKeyboardMarkup()
|
82
|
+
buttons.add_button("URL", url="https://google.com")
|
83
|
+
buttons.add_button("Callback", callback_data="callback")
|
84
|
+
buttons.add_row()
|
85
|
+
buttons.add_button("WebApp", web_app="https://daradege.ir")
|
86
|
+
buttons.add_button("Copy", copy_text_button=CopyTextButton("TEXT"))
|
87
|
+
await message.reply("Hello, world!", reply_markup=buttons)
|
88
|
+
```
|
89
|
+
|
90
|
+
|
91
|
+
## Core Abilities
|
92
|
+
|
93
|
+
- **Message Handling** - Process text, commands, and media messages
|
94
|
+
- **Callback Queries** - Handle inline keyboard interactions
|
95
|
+
- **File Operations** - Send and receive photos, videos, documents
|
96
|
+
- **Chat Management** - Get chat info, member management
|
97
|
+
- **Custom Keyboards** - Create interactive user interfaces
|
98
|
+
- **Webhook Support** - Production-ready webhook handling
|
99
|
+
- **Middleware Support** - Add custom processing layers
|
100
|
+
|
101
|
+
## Documentation
|
102
|
+
|
103
|
+
For detailed documentation and advanced usage, visit our [documentation site](https://pyrobale.readthedocs.io).
|
104
|
+
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
108
|
+
|
109
|
+
## License
|
110
|
+
|
111
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
112
|
+
|
113
|
+
## Support
|
114
|
+
|
115
|
+
- 📖 [Documentation](https://pyrobale.readthedocs.io)
|
116
|
+
- 🐛 [Issue Tracker](https://github.com/pyrobale/pyrobale/issues)
|
117
|
+
- 💬 [Discussions](https://github.com/pyrobale/pyrobale/discussions)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from ..pyrobale.client import Client
|
2
|
+
from ..pyrobale.objects import Message, UpdatesTypes
|
3
|
+
|
4
|
+
client = Client("YOUR_BOT_TOKEN")
|
5
|
+
|
6
|
+
async def message_handler(message: Message):
|
7
|
+
await message.reply("Hello, world!")
|
8
|
+
|
9
|
+
client.add_handler(UpdatesTypes.MESSAGE, message_handler)
|
10
|
+
|
11
|
+
client.run()
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from pyrobale.client import Client
|
2
|
+
from pyrobale.objects import Message, UpdatesTypes, CallbackQuery
|
3
|
+
from pyrobale.objects import InlineKeyboardButton, InlineKeyboardMarkup, CopyTextButton
|
4
|
+
|
5
|
+
client = Client("YOUR_BOT_TOKEN")
|
6
|
+
|
7
|
+
@client.on_message()
|
8
|
+
async def message_handler(message: Message):
|
9
|
+
buttons = InlineKeyboardMarkup()
|
10
|
+
buttons.add_button("Callback", callback_data="callback_data")
|
11
|
+
buttons.add_button("Copy Text", copy_text=CopyTextButton("Hello, world!"))
|
12
|
+
buttons.add_button("URL", url="https://www.google.com")
|
13
|
+
buttons.add_button("WebApp", web_app="https://daradege.ir")
|
14
|
+
await message.reply("These are Inline Buttons!", reply_markup=buttons)
|
15
|
+
|
16
|
+
@client.on_callback_query()
|
17
|
+
async def callback_handler(callback_query: CallbackQuery):
|
18
|
+
await callback_query.answer("Callback Query Received!", show_alert=True)
|
19
|
+
|
20
|
+
client.run()
|
@@ -1,8 +1,9 @@
|
|
1
1
|
[project]
|
2
2
|
name = "pyrobale"
|
3
|
-
version = "0.3.
|
3
|
+
version = "0.3.7"
|
4
4
|
authors = [
|
5
5
|
{ name = "Ali Safamanesh", email = "darg.q.a.a@gmail.com" },
|
6
|
+
{ name = "Aydin Rahbaran", email = "codewizaard9@gmail.com"},
|
6
7
|
]
|
7
8
|
description = "A python wrapper for bale api"
|
8
9
|
readme = "README.md"
|
@@ -13,7 +14,7 @@ classifiers = [
|
|
13
14
|
"Operating System :: OS Independent",
|
14
15
|
]
|
15
16
|
license = { file = "LICENSE" }
|
16
|
-
|
17
|
+
dependencies = ["aiohttp"]
|
17
18
|
[project.urls]
|
18
19
|
github = "https://github.com/pyrobale/pyrobale"
|
19
20
|
website = "https://pyrobale.github.io"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from typing import Union, TYPE_CHECKING
|
2
|
+
|
3
|
+
if TYPE_CHECKING:
|
4
|
+
from ..objects import User
|
5
|
+
from ..client import Client
|
6
|
+
|
7
|
+
|
8
|
+
class StateMachine:
|
9
|
+
def __init__(self):
|
10
|
+
self.__states = {}
|
11
|
+
|
12
|
+
def set_state(self, user_id: Union[str, int], state: str):
|
13
|
+
"""Sets or updates state of a user
|
14
|
+
|
15
|
+
Args:
|
16
|
+
user_id (string OR integer): unique id of user for setting the state
|
17
|
+
state (string): state of user (it can be anything)
|
18
|
+
"""
|
19
|
+
self.__states[user_id] = state
|
20
|
+
|
21
|
+
def get_state(self, user_id: Union[str, int]) -> str:
|
22
|
+
"""Gets state of a specified user
|
23
|
+
|
24
|
+
Args:
|
25
|
+
user_id (string OR integer): unique id of user for getting the state
|
26
|
+
|
27
|
+
Returns:
|
28
|
+
Str: the state of user
|
29
|
+
"""
|
30
|
+
|
31
|
+
if user_id in self.__states:
|
32
|
+
return self.__states[user_id]
|
33
|
+
else:
|
34
|
+
raise KeyError
|
35
|
+
|
36
|
+
def del_state(self, user_id: Union[str, int]):
|
37
|
+
"""Deletes the saved state of user
|
38
|
+
|
39
|
+
Args:
|
40
|
+
user_id (string OR integer): unique if of user to delete its state
|
41
|
+
"""
|
42
|
+
if user_id in self.__states:
|
43
|
+
del self.__states[user_id]
|
44
|
+
else:
|
45
|
+
raise KeyError
|
@@ -0,0 +1,123 @@
|
|
1
|
+
"""
|
2
|
+

|
3
|
+
|
4
|
+
# Bale Bot API Python Library
|
5
|
+
|
6
|
+
A modern, easy-to-use Python wrapper for the Bale Bot API that makes building Bale bots simple and intuitive.
|
7
|
+
|
8
|
+
## Features
|
9
|
+
|
10
|
+
- 🚀 **Simple & Intuitive** - Clean, Pythonic API design
|
11
|
+
- 📨 **Full Message Support** - Text, photos, videos, documents, and more
|
12
|
+
- ⌨️ **Interactive Elements** - Inline keyboards, reply keyboards, and buttons
|
13
|
+
- 🔄 **Real-time Updates** - Webhook and polling support
|
14
|
+
- 📁 **File Handling** - Easy upload and download of media files
|
15
|
+
- 🛡️ **Error Handling** - Comprehensive exception handling
|
16
|
+
- 📖 **Type Hints** - Full typing support for better development experience
|
17
|
+
- ⚡ **Async Support** - Both synchronous and asynchronous operations
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
```bash
|
22
|
+
pip install pyrobale
|
23
|
+
```
|
24
|
+
|
25
|
+
## Quick Start
|
26
|
+
|
27
|
+
```python
|
28
|
+
from pyrobale.client import Client
|
29
|
+
from pyrobale.objects import Message, UpdatesTypes
|
30
|
+
|
31
|
+
bot = Client("YOUR_BOT_TOKEN")
|
32
|
+
|
33
|
+
@bot.on_message()
|
34
|
+
async def message_handler(message: User):
|
35
|
+
await message.reply("Hello, world!")
|
36
|
+
|
37
|
+
bot.run()
|
38
|
+
```
|
39
|
+
|
40
|
+
## Examples
|
41
|
+
|
42
|
+
### Conversation Bot
|
43
|
+
```python
|
44
|
+
from pyrobale.objects import *
|
45
|
+
from pyrobale.client import Client, Message, UpdatesTypes
|
46
|
+
import asyncio
|
47
|
+
|
48
|
+
client = Client("YOUR_BOT_TOKEN")
|
49
|
+
|
50
|
+
async def handle_message(message: Message):
|
51
|
+
if message.text == "/start":
|
52
|
+
await message.reply("سلام! من یک ربات PyRoBale هستم!")
|
53
|
+
await client.wait_for(UpdatesTypes.MESSAGE)
|
54
|
+
await message.reply("Okay! wait_for Test Compeleted")
|
55
|
+
|
56
|
+
client.add_handler(UpdatesTypes.MESSAGE, handle_message)
|
57
|
+
|
58
|
+
client.run()
|
59
|
+
```
|
60
|
+
|
61
|
+
### Echo Bot
|
62
|
+
```python
|
63
|
+
from pyrobale.client import Client
|
64
|
+
from pyrobale.objects import Message, UpdatesTypes
|
65
|
+
|
66
|
+
bot = Client("YOUR_BOT_TOKEN")
|
67
|
+
|
68
|
+
@bot.on_message()
|
69
|
+
async def message_handler(message: Message):
|
70
|
+
await message.reply(message.text)
|
71
|
+
|
72
|
+
bot.run()
|
73
|
+
```
|
74
|
+
|
75
|
+
### Inline Keyboard
|
76
|
+
```python
|
77
|
+
from pyrobale.client import Client
|
78
|
+
from pyrobale.objects import Message, UpdatesTypes, InlineKeyboardButton, InlineKeyboardMarkup, CopyTextButton
|
79
|
+
|
80
|
+
bot = Client("YOUR_BOT_TOKEN")
|
81
|
+
async def message_handler(message: Message):
|
82
|
+
buttons = InlineKeyboardMarkup()
|
83
|
+
buttons.add_button("URL", url="https://google.com")
|
84
|
+
buttons.add_button("Callback", callback_data="callback")
|
85
|
+
buttons.add_row()
|
86
|
+
buttons.add_button("WebApp", web_app="https://daradege.ir")
|
87
|
+
buttons.add_button("Copy", copy_text_button=CopyTextButton("TEXT"))
|
88
|
+
await message.reply("Hello, world!", reply_markup=buttons)
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
## Core Abilities
|
93
|
+
|
94
|
+
- **Message Handling** - Process text, commands, and media messages
|
95
|
+
- **Callback Queries** - Handle inline keyboard interactions
|
96
|
+
- **File Operations** - Send and receive photos, videos, documents
|
97
|
+
- **Chat Management** - Get chat info, member management
|
98
|
+
- **Custom Keyboards** - Create interactive user interfaces
|
99
|
+
- **Webhook Support** - Production-ready webhook handling
|
100
|
+
- **Middleware Support** - Add custom processing layers
|
101
|
+
|
102
|
+
## Documentation
|
103
|
+
|
104
|
+
For detailed documentation and advanced usage, visit our [documentation site](https://pyrobale.readthedocs.io).
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
109
|
+
|
110
|
+
## License
|
111
|
+
|
112
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
113
|
+
|
114
|
+
## Support
|
115
|
+
|
116
|
+
- 📖 [Documentation](https://pyrobale.readthedocs.io)
|
117
|
+
- 🐛 [Issue Tracker](https://github.com/pyrobale/pyrobale/issues)
|
118
|
+
- 💬 [Discussions](https://github.com/pyrobale/pyrobale/discussions)
|
119
|
+
"""
|
120
|
+
|
121
|
+
from .objects.utils import *
|
122
|
+
from .exceptions import *
|
123
|
+
from .objects import *
|