pyrobale 0.2.9.4.1__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.
Files changed (55) hide show
  1. pyrobale-0.3.7/.github/ISSUE_TEMPLATE/issue-template-/342/204/271/357/270/217.md +64 -0
  2. pyrobale-0.3.7/.github/workflows/docs.yml +38 -0
  3. pyrobale-0.3.7/LICENSE +21 -0
  4. pyrobale-0.3.7/PKG-INFO +153 -0
  5. pyrobale-0.3.7/README.md +117 -0
  6. pyrobale-0.3.7/examples/echo_bot.py +10 -0
  7. pyrobale-0.3.7/examples/handler_system.py +11 -0
  8. pyrobale-0.3.7/examples/inline_keyboard.py +20 -0
  9. {pyrobale-0.2.9.4.1 → pyrobale-0.3.7}/pyproject.toml +7 -3
  10. pyrobale-0.3.7/pyrobale/StateMachine/__init__.py +45 -0
  11. pyrobale-0.3.7/pyrobale/__init__.py +123 -0
  12. pyrobale-0.3.7/pyrobale/client/__init__.py +1117 -0
  13. pyrobale-0.3.7/pyrobale/exceptions/__init__.py +0 -0
  14. pyrobale-0.3.7/pyrobale/exceptions/common.py +10 -0
  15. pyrobale-0.3.7/pyrobale/objects/__init__.py +89 -0
  16. pyrobale-0.3.7/pyrobale/objects/animation.py +33 -0
  17. pyrobale-0.3.7/pyrobale/objects/audio.py +24 -0
  18. pyrobale-0.3.7/pyrobale/objects/callbackquery.py +37 -0
  19. pyrobale-0.3.7/pyrobale/objects/chat.py +463 -0
  20. pyrobale-0.3.7/pyrobale/objects/chatmember.py +163 -0
  21. pyrobale-0.3.7/pyrobale/objects/chatphoto.py +18 -0
  22. pyrobale-0.3.7/pyrobale/objects/contact.py +16 -0
  23. pyrobale-0.3.7/pyrobale/objects/copytextbutton.py +5 -0
  24. pyrobale-0.3.7/pyrobale/objects/document.py +26 -0
  25. pyrobale-0.3.7/pyrobale/objects/enums.py +44 -0
  26. pyrobale-0.3.7/pyrobale/objects/file.py +15 -0
  27. pyrobale-0.3.7/pyrobale/objects/inlinekeyboardbutton.py +24 -0
  28. pyrobale-0.3.7/pyrobale/objects/inlinekeyboardmarkup.py +84 -0
  29. pyrobale-0.3.7/pyrobale/objects/inputfile.py +17 -0
  30. pyrobale-0.3.7/pyrobale/objects/inputmedias.py +166 -0
  31. pyrobale-0.3.7/pyrobale/objects/invoice.py +14 -0
  32. pyrobale-0.3.7/pyrobale/objects/keyboardbutton.py +19 -0
  33. pyrobale-0.3.7/pyrobale/objects/labeledprice.py +8 -0
  34. pyrobale-0.3.7/pyrobale/objects/location.py +4 -0
  35. pyrobale-0.3.7/pyrobale/objects/message.py +387 -0
  36. pyrobale-0.3.7/pyrobale/objects/messageid.py +3 -0
  37. pyrobale-0.3.7/pyrobale/objects/photosize.py +9 -0
  38. pyrobale-0.3.7/pyrobale/objects/precheckoutquery.py +21 -0
  39. pyrobale-0.3.7/pyrobale/objects/replykeyboardmarkup.py +54 -0
  40. pyrobale-0.3.7/pyrobale/objects/sticker.py +16 -0
  41. pyrobale-0.3.7/pyrobale/objects/stickerset.py +12 -0
  42. pyrobale-0.3.7/pyrobale/objects/successfulpayment.py +15 -0
  43. pyrobale-0.3.7/pyrobale/objects/update.py +23 -0
  44. pyrobale-0.3.7/pyrobale/objects/user.py +22 -0
  45. pyrobale-0.3.7/pyrobale/objects/utils.py +27 -0
  46. pyrobale-0.3.7/pyrobale/objects/video.py +20 -0
  47. pyrobale-0.3.7/pyrobale/objects/voice.py +4 -0
  48. pyrobale-0.3.7/pyrobale/objects/webappdata.py +3 -0
  49. pyrobale-0.3.7/pyrobale/objects/webappinfo.py +3 -0
  50. {pyrobale-0.2.9.4.1 → pyrobale-0.3.7}/pyrobale.png +0 -0
  51. {pyrobale-0.2.9.4.1 → pyrobale-0.3.7}/pyrobaletext.png +0 -0
  52. pyrobale-0.2.9.4.1/LICENSE +0 -678
  53. pyrobale-0.2.9.4.1/PKG-INFO +0 -833
  54. pyrobale-0.2.9.4.1/README.md +0 -141
  55. pyrobale-0.2.9.4.1/pyrobale.py +0 -2543
@@ -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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ali Safamanesh
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,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
+ ![pyrobaletext](https://raw.githubusercontent.com/pyrobale/pyrobale/refs/heads/main/pyrobaletext.png)
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)
@@ -0,0 +1,117 @@
1
+ ![pyrobaletext](https://raw.githubusercontent.com/pyrobale/pyrobale/refs/heads/main/pyrobaletext.png)
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,10 @@
1
+ from pyrobale.client import Client
2
+ from pyrobale.objects import Message, UpdatesTypes
3
+
4
+ client = Client("YOUR_BOT_TOKEN")
5
+
6
+ @client.on_message()
7
+ async def message_handler(message: Message):
8
+ await message.reply(message.text)
9
+
10
+ client.run()
@@ -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.2.9.4.1"
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,11 +14,14 @@ 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"
20
21
 
21
22
  [build-system]
22
23
  requires = ["hatchling"]
23
- build-backend = "hatchling.build"
24
+ build-backend = "hatchling.build"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["pyrobale"]
@@ -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
+ ![pyrobaletext](https://raw.githubusercontent.com/pyrobale/pyrobale/refs/heads/main/pyrobaletext.png)
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 *