Rubka 6.6.2__py3-none-any.whl → 7.1.17__py3-none-any.whl
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.
- rubka/__init__.py +70 -0
- rubka/api.py +6 -17
- rubka/asynco.py +1058 -255
- rubka/button.py +1 -1
- rubka/context.py +560 -25
- rubka/exceptions.py +35 -1
- rubka/filters.py +16 -0
- rubka/helpers.py +1461 -0
- rubka/metadata.py +117 -0
- rubka/rubino.py +227 -96
- rubka/tv.py +145 -0
- rubka/update.py +560 -25
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/METADATA +29 -11
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/RECORD +17 -13
- rubka-7.1.17.dist-info/entry_points.txt +2 -0
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/WHEEL +0 -0
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/top_level.txt +0 -0
rubka/__init__.py
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
🔹 Synchronous Example
|
|
3
|
+
```python
|
|
4
|
+
from rubka import Robot, Message
|
|
5
|
+
|
|
6
|
+
bot = Robot(token="YOUR_BOT_TOKEN")
|
|
7
|
+
|
|
8
|
+
@bot.on_message(commands=["start", "help"])
|
|
9
|
+
def handle_start(bot: Robot, message: Message):
|
|
10
|
+
message.reply("👋 Hello! Welcome to the Rubka bot (sync example).")
|
|
11
|
+
|
|
12
|
+
bot.run()
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Explanation
|
|
16
|
+
|
|
17
|
+
Robot is created with your bot token.
|
|
18
|
+
@bot.on_message registers a handler for incoming messages.
|
|
19
|
+
|
|
20
|
+
The function handle_start runs synchronously (step by step, blocking).
|
|
21
|
+
|
|
22
|
+
message.reply sends a message back to the user immediately.
|
|
23
|
+
|
|
24
|
+
Finally, bot.run() starts the event loop and keeps the bot running.
|
|
25
|
+
|
|
26
|
+
This approach is simpler and best for small bots or basic logic where you don’t need concurrency.
|
|
27
|
+
|
|
28
|
+
🔹 Asynchronous Example
|
|
29
|
+
```python
|
|
30
|
+
import asyncio
|
|
31
|
+
from rubka.asynco import Robot, Message
|
|
32
|
+
|
|
33
|
+
bot = Robot(token="YOUR_BOT_TOKEN")
|
|
34
|
+
|
|
35
|
+
@bot.on_message(commands=["start", "help"])
|
|
36
|
+
async def handle_start(bot: Robot, message: Message):
|
|
37
|
+
await message.reply("⚡ Hello! This is the async version of Rubka.")
|
|
38
|
+
|
|
39
|
+
async def main():
|
|
40
|
+
await bot.run()
|
|
41
|
+
|
|
42
|
+
asyncio.run(main())
|
|
43
|
+
```
|
|
44
|
+
Explanation
|
|
45
|
+
|
|
46
|
+
Uses rubka.asynco.Robot for asynchronous operation.
|
|
47
|
+
|
|
48
|
+
The handler handle_start is defined with async def.
|
|
49
|
+
|
|
50
|
+
await message.reply(...) is non-blocking: the bot can process other tasks while waiting for Rubika’s response.
|
|
51
|
+
|
|
52
|
+
asyncio.run(main()) starts the async event loop.
|
|
53
|
+
|
|
54
|
+
This approach is more powerful and recommended for larger bots or when you:
|
|
55
|
+
|
|
56
|
+
Need to call external APIs.
|
|
57
|
+
|
|
58
|
+
Handle multiple long-running tasks.
|
|
59
|
+
|
|
60
|
+
Want better performance and scalability.
|
|
61
|
+
|
|
62
|
+
👉 In short:
|
|
63
|
+
|
|
64
|
+
Sync = simple, step-by-step, blocking.
|
|
65
|
+
|
|
66
|
+
Async = scalable, concurrent, non-blocking.
|
|
67
|
+
"""
|
|
68
|
+
|
|
1
69
|
from .api import Robot
|
|
2
70
|
from .rubino import Bot
|
|
3
71
|
from .exceptions import APIRequestError
|
|
72
|
+
from .rubino import Bot as rubino
|
|
73
|
+
from .tv import TV as TvRubika
|
|
4
74
|
|
|
5
75
|
__all__ = [
|
|
6
76
|
"Robot",
|
rubka/api.py
CHANGED
|
@@ -4,6 +4,7 @@ from .exceptions import APIRequestError
|
|
|
4
4
|
from .adaptorrubka import Client as Client_get
|
|
5
5
|
from .logger import logger
|
|
6
6
|
from . import filters
|
|
7
|
+
from . import helpers
|
|
7
8
|
from typing import Callable
|
|
8
9
|
from .context import Message,InlineMessage
|
|
9
10
|
from typing import Optional, Union, Literal, Dict, Any
|
|
@@ -53,22 +54,8 @@ def get_latest_version(package_name: str) -> str:
|
|
|
53
54
|
data = resp.json()
|
|
54
55
|
return data["info"]["version"]
|
|
55
56
|
except Exception:return None
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
installed_version = get_installed_version(package_name)
|
|
59
|
-
if installed_version is None:return
|
|
60
|
-
latest_version = get_latest_version(package_name)
|
|
61
|
-
if latest_version is None:return
|
|
62
|
-
if installed_version != latest_version:
|
|
63
|
-
print(f"\n\nWARNING: Your installed version of '{package_name}' is OUTDATED and may cause errors or security risks!")
|
|
64
|
-
print(f"Installed version : {installed_version}")
|
|
65
|
-
print(f"Latest available version : {latest_version}")
|
|
66
|
-
print(f"Please update IMMEDIATELY by running:")
|
|
67
|
-
print(f"\npip install {package_name}=={latest_version}\n")
|
|
68
|
-
print(f"Not updating may lead to malfunctions or incompatibility.")
|
|
69
|
-
print(f"To see new methods : @rubka_library\n\n")
|
|
70
|
-
|
|
71
|
-
check_rubka_version()
|
|
57
|
+
|
|
58
|
+
|
|
72
59
|
def show_last_six_words(text):
|
|
73
60
|
text = text.strip()
|
|
74
61
|
return text[-6:]
|
|
@@ -1015,7 +1002,9 @@ class Robot:
|
|
|
1015
1002
|
inline_keypad: Optional[Dict[str, Any]] = None,
|
|
1016
1003
|
disable_notification: bool = False,
|
|
1017
1004
|
reply_to_message_id: Optional[str] = None,
|
|
1018
|
-
chat_keypad_type: Optional[Literal["New", "Removed"]] = None
|
|
1005
|
+
chat_keypad_type: Optional[Literal["New", "Removed"]] = None,
|
|
1006
|
+
delete_after = None,
|
|
1007
|
+
parse_mode = None
|
|
1019
1008
|
) -> Dict[str, Any]:
|
|
1020
1009
|
"""
|
|
1021
1010
|
Send a text message to a chat.
|