Rubka 6.4.8__tar.gz → 7.1.15__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.
- {rubka-6.4.8 → rubka-7.1.15}/PKG-INFO +29 -11
- {rubka-6.4.8 → rubka-7.1.15}/README.md +10 -7
- {rubka-6.4.8 → rubka-7.1.15}/Rubka.egg-info/PKG-INFO +29 -11
- {rubka-6.4.8 → rubka-7.1.15}/Rubka.egg-info/SOURCES.txt +6 -0
- rubka-7.1.15/Rubka.egg-info/entry_points.txt +2 -0
- rubka-7.1.15/Rubka.egg-info/not-zip-safe +1 -0
- {rubka-6.4.8 → rubka-7.1.15}/Rubka.egg-info/requires.txt +2 -1
- rubka-7.1.15/rubka/__init__.py +80 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/api.py +27 -21
- {rubka-6.4.8 → rubka-7.1.15}/rubka/asynco.py +1049 -403
- {rubka-6.4.8 → rubka-7.1.15}/rubka/button.py +1 -1
- rubka-7.1.15/rubka/context.py +1038 -0
- rubka-7.1.15/rubka/exceptions.py +37 -0
- rubka-7.1.15/rubka/filters.py +321 -0
- rubka-7.1.15/rubka/helpers.py +1461 -0
- rubka-7.1.15/rubka/metadata.py +117 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/rubino.py +227 -96
- rubka-7.1.15/rubka/tv.py +145 -0
- rubka-7.1.15/rubka/update.py +1038 -0
- rubka-7.1.15/setup.py +75 -0
- rubka-6.4.8/rubka/__init__.py +0 -10
- rubka-6.4.8/rubka/context.py +0 -503
- rubka-6.4.8/rubka/exceptions.py +0 -3
- rubka-6.4.8/rubka/update.py +0 -503
- rubka-6.4.8/setup.py +0 -43
- {rubka-6.4.8 → rubka-7.1.15}/Rubka.egg-info/dependency_links.txt +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/Rubka.egg-info/top_level.txt +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/client/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/client/client.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/crypto/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/crypto/crypto.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/enums.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/exceptions.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/methods/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/methods/methods.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/network/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/network/helper.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/network/network.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/network/socket.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/sessions/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/sessions/sessions.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/types/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/types/socket/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/types/socket/message.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/utils/__init__.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/utils/configs.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/adaptorrubka/utils/utils.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/config.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/decorators.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/jobs.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/keyboards.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/keypad.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/logger.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/rubka/utils.py +0 -0
- {rubka-6.4.8 → rubka-7.1.15}/setup.cfg +0 -0
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version:
|
|
4
|
-
Summary: A Python library for interacting with Rubika Bot API.
|
|
3
|
+
Version: 7.1.15
|
|
4
|
+
Summary: Rubika: A Python library for interacting with the Rubika Bot API. This library provides an easy-to-use interface to send messages, polls, stickers, media files, manage groups and channels, handle inline keyboards, and implement advanced bot features like subscription management, user authentication, and message handling. Ideal for developers looking to automate and extend their Rubika bots with Python.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
|
-
Download-URL: https://github.com/Mahdy-Ahmadi/rubka/
|
|
6
|
+
Download-URL: https://github.com/Mahdy-Ahmadi/rubka/archive/refs/tags/v6.6.4.zip
|
|
7
7
|
Author: Mahdi Ahmadi
|
|
8
8
|
Author-email: mahdiahmadi.1208@gmail.com
|
|
9
9
|
Maintainer: Mahdi Ahmadi
|
|
10
10
|
Maintainer-email: mahdiahmadi.1208@gmail.com
|
|
11
|
+
License: MIT
|
|
12
|
+
Project-URL: Bug Tracker, https://t.me/Bprogrammer
|
|
13
|
+
Project-URL: Documentation, https://github.com/Mahdy-Ahmadi/rubka/blob/main/README.md
|
|
14
|
+
Project-URL: Source Code, https://github.com/Mahdy-Ahmadi/Rubka
|
|
15
|
+
Keywords: rubika bot api library chat messaging rubpy pyrubi rubigram rubika_bot rubika_api fast_rub
|
|
16
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
11
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
22
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
23
|
Classifier: Operating System :: OS Independent
|
|
14
24
|
Classifier: Topic :: Communications :: Chat
|
|
15
25
|
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Natural Language :: Persian
|
|
16
27
|
Requires-Python: >=3.6
|
|
17
28
|
Description-Content-Type: text/markdown
|
|
18
29
|
Requires-Dist: requests
|
|
19
|
-
Requires-Dist: Pillow
|
|
20
30
|
Requires-Dist: websocket-client
|
|
21
31
|
Requires-Dist: pycryptodome
|
|
22
32
|
Requires-Dist: aiohttp
|
|
33
|
+
Requires-Dist: httpx
|
|
23
34
|
Requires-Dist: tqdm
|
|
24
35
|
Requires-Dist: mutagen
|
|
36
|
+
Requires-Dist: markdownify
|
|
25
37
|
Requires-Dist: filetype
|
|
26
38
|
Requires-Dist: aiofiles
|
|
27
39
|
Dynamic: author
|
|
@@ -31,12 +43,18 @@ Dynamic: description
|
|
|
31
43
|
Dynamic: description-content-type
|
|
32
44
|
Dynamic: download-url
|
|
33
45
|
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
34
48
|
Dynamic: maintainer
|
|
35
49
|
Dynamic: maintainer-email
|
|
50
|
+
Dynamic: project-url
|
|
36
51
|
Dynamic: requires-dist
|
|
37
52
|
Dynamic: requires-python
|
|
38
53
|
Dynamic: summary
|
|
39
54
|
|
|
55
|
+
# وبسایت کتابخونه / نمونه کد ها / وب هوک رایگان
|
|
56
|
+
برای مشاهده مستندات کامل و وب هوک رایگان به آدرس زیر مراجعه کنید:
|
|
57
|
+
[rubka.ir](rubka.ir)
|
|
40
58
|
# 📚 Rubka Bot Python Library Documentation
|
|
41
59
|
# نمونه تنظیم وبهوک (Webhook) در کتابخونه rubla
|
|
42
60
|
|
|
@@ -62,16 +80,16 @@ If `importlib.metadata` is not available, it installs `importlib-metadata` autom
|
|
|
62
80
|
## 🚀 Getting Started
|
|
63
81
|
|
|
64
82
|
```python
|
|
65
|
-
from rubka import Robot
|
|
83
|
+
from rubka.asynco import Robot
|
|
66
84
|
from rubka.context import Message
|
|
67
|
-
|
|
85
|
+
import asyncio
|
|
68
86
|
bot = Robot(token="YOUR_TOKEN_HERE")
|
|
69
87
|
|
|
70
88
|
@bot.on_message(commands=["start"])
|
|
71
|
-
def start(bot: Robot, message: Message):
|
|
72
|
-
message.reply("سلام! خوش آمدید!")
|
|
89
|
+
async def start(bot: Robot, message: Message):
|
|
90
|
+
await message.reply("سلام! خوش آمدید!")
|
|
73
91
|
|
|
74
|
-
bot.run()
|
|
92
|
+
asyncio.run(bot.run())
|
|
75
93
|
```
|
|
76
94
|
|
|
77
95
|
---
|
|
@@ -82,8 +100,8 @@ You can handle incoming text messages using `@bot.on_message()`:
|
|
|
82
100
|
|
|
83
101
|
```python
|
|
84
102
|
@bot.on_message(commands=["hello"])
|
|
85
|
-
def greet(bot: Robot, message: Message):
|
|
86
|
-
|
|
103
|
+
async def greet(bot: Robot, message: Message):
|
|
104
|
+
await message.reply("سلام کاربر عزیز 👋")
|
|
87
105
|
```
|
|
88
106
|
|
|
89
107
|
You can also add filters.
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# وبسایت کتابخونه / نمونه کد ها / وب هوک رایگان
|
|
2
|
+
برای مشاهده مستندات کامل و وب هوک رایگان به آدرس زیر مراجعه کنید:
|
|
3
|
+
[rubka.ir](rubka.ir)
|
|
1
4
|
# 📚 Rubka Bot Python Library Documentation
|
|
2
5
|
# نمونه تنظیم وبهوک (Webhook) در کتابخونه rubla
|
|
3
6
|
|
|
@@ -23,16 +26,16 @@ If `importlib.metadata` is not available, it installs `importlib-metadata` autom
|
|
|
23
26
|
## 🚀 Getting Started
|
|
24
27
|
|
|
25
28
|
```python
|
|
26
|
-
from rubka import Robot
|
|
29
|
+
from rubka.asynco import Robot
|
|
27
30
|
from rubka.context import Message
|
|
28
|
-
|
|
31
|
+
import asyncio
|
|
29
32
|
bot = Robot(token="YOUR_TOKEN_HERE")
|
|
30
33
|
|
|
31
34
|
@bot.on_message(commands=["start"])
|
|
32
|
-
def start(bot: Robot, message: Message):
|
|
33
|
-
message.reply("سلام! خوش آمدید!")
|
|
35
|
+
async def start(bot: Robot, message: Message):
|
|
36
|
+
await message.reply("سلام! خوش آمدید!")
|
|
34
37
|
|
|
35
|
-
bot.run()
|
|
38
|
+
asyncio.run(bot.run())
|
|
36
39
|
```
|
|
37
40
|
|
|
38
41
|
---
|
|
@@ -43,8 +46,8 @@ You can handle incoming text messages using `@bot.on_message()`:
|
|
|
43
46
|
|
|
44
47
|
```python
|
|
45
48
|
@bot.on_message(commands=["hello"])
|
|
46
|
-
def greet(bot: Robot, message: Message):
|
|
47
|
-
|
|
49
|
+
async def greet(bot: Robot, message: Message):
|
|
50
|
+
await message.reply("سلام کاربر عزیز 👋")
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
You can also add filters.
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version:
|
|
4
|
-
Summary: A Python library for interacting with Rubika Bot API.
|
|
3
|
+
Version: 7.1.15
|
|
4
|
+
Summary: Rubika: A Python library for interacting with the Rubika Bot API. This library provides an easy-to-use interface to send messages, polls, stickers, media files, manage groups and channels, handle inline keyboards, and implement advanced bot features like subscription management, user authentication, and message handling. Ideal for developers looking to automate and extend their Rubika bots with Python.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
|
-
Download-URL: https://github.com/Mahdy-Ahmadi/rubka/
|
|
6
|
+
Download-URL: https://github.com/Mahdy-Ahmadi/rubka/archive/refs/tags/v6.6.4.zip
|
|
7
7
|
Author: Mahdi Ahmadi
|
|
8
8
|
Author-email: mahdiahmadi.1208@gmail.com
|
|
9
9
|
Maintainer: Mahdi Ahmadi
|
|
10
10
|
Maintainer-email: mahdiahmadi.1208@gmail.com
|
|
11
|
+
License: MIT
|
|
12
|
+
Project-URL: Bug Tracker, https://t.me/Bprogrammer
|
|
13
|
+
Project-URL: Documentation, https://github.com/Mahdy-Ahmadi/rubka/blob/main/README.md
|
|
14
|
+
Project-URL: Source Code, https://github.com/Mahdy-Ahmadi/Rubka
|
|
15
|
+
Keywords: rubika bot api library chat messaging rubpy pyrubi rubigram rubika_bot rubika_api fast_rub
|
|
16
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
11
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
22
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
23
|
Classifier: Operating System :: OS Independent
|
|
14
24
|
Classifier: Topic :: Communications :: Chat
|
|
15
25
|
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Natural Language :: Persian
|
|
16
27
|
Requires-Python: >=3.6
|
|
17
28
|
Description-Content-Type: text/markdown
|
|
18
29
|
Requires-Dist: requests
|
|
19
|
-
Requires-Dist: Pillow
|
|
20
30
|
Requires-Dist: websocket-client
|
|
21
31
|
Requires-Dist: pycryptodome
|
|
22
32
|
Requires-Dist: aiohttp
|
|
33
|
+
Requires-Dist: httpx
|
|
23
34
|
Requires-Dist: tqdm
|
|
24
35
|
Requires-Dist: mutagen
|
|
36
|
+
Requires-Dist: markdownify
|
|
25
37
|
Requires-Dist: filetype
|
|
26
38
|
Requires-Dist: aiofiles
|
|
27
39
|
Dynamic: author
|
|
@@ -31,12 +43,18 @@ Dynamic: description
|
|
|
31
43
|
Dynamic: description-content-type
|
|
32
44
|
Dynamic: download-url
|
|
33
45
|
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
34
48
|
Dynamic: maintainer
|
|
35
49
|
Dynamic: maintainer-email
|
|
50
|
+
Dynamic: project-url
|
|
36
51
|
Dynamic: requires-dist
|
|
37
52
|
Dynamic: requires-python
|
|
38
53
|
Dynamic: summary
|
|
39
54
|
|
|
55
|
+
# وبسایت کتابخونه / نمونه کد ها / وب هوک رایگان
|
|
56
|
+
برای مشاهده مستندات کامل و وب هوک رایگان به آدرس زیر مراجعه کنید:
|
|
57
|
+
[rubka.ir](rubka.ir)
|
|
40
58
|
# 📚 Rubka Bot Python Library Documentation
|
|
41
59
|
# نمونه تنظیم وبهوک (Webhook) در کتابخونه rubla
|
|
42
60
|
|
|
@@ -62,16 +80,16 @@ If `importlib.metadata` is not available, it installs `importlib-metadata` autom
|
|
|
62
80
|
## 🚀 Getting Started
|
|
63
81
|
|
|
64
82
|
```python
|
|
65
|
-
from rubka import Robot
|
|
83
|
+
from rubka.asynco import Robot
|
|
66
84
|
from rubka.context import Message
|
|
67
|
-
|
|
85
|
+
import asyncio
|
|
68
86
|
bot = Robot(token="YOUR_TOKEN_HERE")
|
|
69
87
|
|
|
70
88
|
@bot.on_message(commands=["start"])
|
|
71
|
-
def start(bot: Robot, message: Message):
|
|
72
|
-
message.reply("سلام! خوش آمدید!")
|
|
89
|
+
async def start(bot: Robot, message: Message):
|
|
90
|
+
await message.reply("سلام! خوش آمدید!")
|
|
73
91
|
|
|
74
|
-
bot.run()
|
|
92
|
+
asyncio.run(bot.run())
|
|
75
93
|
```
|
|
76
94
|
|
|
77
95
|
---
|
|
@@ -82,8 +100,8 @@ You can handle incoming text messages using `@bot.on_message()`:
|
|
|
82
100
|
|
|
83
101
|
```python
|
|
84
102
|
@bot.on_message(commands=["hello"])
|
|
85
|
-
def greet(bot: Robot, message: Message):
|
|
86
|
-
|
|
103
|
+
async def greet(bot: Robot, message: Message):
|
|
104
|
+
await message.reply("سلام کاربر عزیز 👋")
|
|
87
105
|
```
|
|
88
106
|
|
|
89
107
|
You can also add filters.
|
|
@@ -3,6 +3,8 @@ setup.py
|
|
|
3
3
|
Rubka.egg-info/PKG-INFO
|
|
4
4
|
Rubka.egg-info/SOURCES.txt
|
|
5
5
|
Rubka.egg-info/dependency_links.txt
|
|
6
|
+
Rubka.egg-info/entry_points.txt
|
|
7
|
+
Rubka.egg-info/not-zip-safe
|
|
6
8
|
Rubka.egg-info/requires.txt
|
|
7
9
|
Rubka.egg-info/top_level.txt
|
|
8
10
|
rubka/__init__.py
|
|
@@ -13,11 +15,15 @@ rubka/config.py
|
|
|
13
15
|
rubka/context.py
|
|
14
16
|
rubka/decorators.py
|
|
15
17
|
rubka/exceptions.py
|
|
18
|
+
rubka/filters.py
|
|
19
|
+
rubka/helpers.py
|
|
16
20
|
rubka/jobs.py
|
|
17
21
|
rubka/keyboards.py
|
|
18
22
|
rubka/keypad.py
|
|
19
23
|
rubka/logger.py
|
|
24
|
+
rubka/metadata.py
|
|
20
25
|
rubka/rubino.py
|
|
26
|
+
rubka/tv.py
|
|
21
27
|
rubka/update.py
|
|
22
28
|
rubka/utils.py
|
|
23
29
|
rubka/adaptorrubka/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
|
|
69
|
+
from .api import Robot
|
|
70
|
+
from .rubino import Bot
|
|
71
|
+
from .exceptions import APIRequestError
|
|
72
|
+
from .rubino import Bot as rubino
|
|
73
|
+
from .tv import TV as TvRubika
|
|
74
|
+
|
|
75
|
+
__all__ = [
|
|
76
|
+
"Robot",
|
|
77
|
+
"on_message",
|
|
78
|
+
"APIRequestError",
|
|
79
|
+
"create_simple_keyboard",
|
|
80
|
+
]
|
|
@@ -3,6 +3,8 @@ from typing import List, Optional, Dict, Any, Literal
|
|
|
3
3
|
from .exceptions import APIRequestError
|
|
4
4
|
from .adaptorrubka import Client as Client_get
|
|
5
5
|
from .logger import logger
|
|
6
|
+
from . import filters
|
|
7
|
+
from . import helpers
|
|
6
8
|
from typing import Callable
|
|
7
9
|
from .context import Message,InlineMessage
|
|
8
10
|
from typing import Optional, Union, Literal, Dict, Any
|
|
@@ -52,22 +54,8 @@ def get_latest_version(package_name: str) -> str:
|
|
|
52
54
|
data = resp.json()
|
|
53
55
|
return data["info"]["version"]
|
|
54
56
|
except Exception:return None
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
installed_version = get_installed_version(package_name)
|
|
58
|
-
if installed_version is None:return
|
|
59
|
-
latest_version = get_latest_version(package_name)
|
|
60
|
-
if latest_version is None:return
|
|
61
|
-
if installed_version != latest_version:
|
|
62
|
-
print(f"\n\nWARNING: Your installed version of '{package_name}' is OUTDATED and may cause errors or security risks!")
|
|
63
|
-
print(f"Installed version : {installed_version}")
|
|
64
|
-
print(f"Latest available version : {latest_version}")
|
|
65
|
-
print(f"Please update IMMEDIATELY by running:")
|
|
66
|
-
print(f"\npip install {package_name}=={latest_version}\n")
|
|
67
|
-
print(f"Not updating may lead to malfunctions or incompatibility.")
|
|
68
|
-
print(f"To see new methods : @rubka_library\n\n")
|
|
69
|
-
|
|
70
|
-
check_rubka_version()
|
|
57
|
+
|
|
58
|
+
|
|
71
59
|
def show_last_six_words(text):
|
|
72
60
|
text = text.strip()
|
|
73
61
|
return text[-6:]
|
|
@@ -489,14 +477,28 @@ class Robot:
|
|
|
489
477
|
|
|
490
478
|
return decorator
|
|
491
479
|
|
|
492
|
-
def on_message(
|
|
480
|
+
def on_message(
|
|
481
|
+
self,
|
|
482
|
+
filters: Optional[Callable[[Message], bool]] = None,
|
|
483
|
+
commands: Optional[List[str]] = None
|
|
484
|
+
):
|
|
493
485
|
def decorator(func: Callable[[Any, Message], None]):
|
|
486
|
+
def wrapper(bot, message: Message):
|
|
487
|
+
if filters and not filters(message):
|
|
488
|
+
return
|
|
489
|
+
if commands:
|
|
490
|
+
if not getattr(message, "is_command", False):
|
|
491
|
+
return
|
|
492
|
+
cmd = message.text.split()[0].lstrip("/") if message.text else ""
|
|
493
|
+
if cmd not in commands:
|
|
494
|
+
return
|
|
495
|
+
return func(bot, message)
|
|
494
496
|
self._message_handlers.append({
|
|
495
|
-
"func":
|
|
497
|
+
"func": wrapper,
|
|
496
498
|
"filters": filters,
|
|
497
499
|
"commands": commands
|
|
498
500
|
})
|
|
499
|
-
return
|
|
501
|
+
return wrapper
|
|
500
502
|
return decorator
|
|
501
503
|
def on_message_file(self, filters: Optional[Callable[[Message], bool]] = None, commands: Optional[List[str]] = None):
|
|
502
504
|
def decorator(func: Callable[[Any, Message], None]):
|
|
@@ -1000,7 +1002,9 @@ class Robot:
|
|
|
1000
1002
|
inline_keypad: Optional[Dict[str, Any]] = None,
|
|
1001
1003
|
disable_notification: bool = False,
|
|
1002
1004
|
reply_to_message_id: Optional[str] = None,
|
|
1003
|
-
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
|
|
1004
1008
|
) -> Dict[str, Any]:
|
|
1005
1009
|
"""
|
|
1006
1010
|
Send a text message to a chat.
|
|
@@ -1654,9 +1658,11 @@ class Robot:
|
|
|
1654
1658
|
self,
|
|
1655
1659
|
chat_id: str,
|
|
1656
1660
|
message_id: str,
|
|
1657
|
-
inline_keypad: Dict[str, Any]
|
|
1661
|
+
inline_keypad: Dict[str, Any],
|
|
1662
|
+
text : str = None
|
|
1658
1663
|
) -> Dict[str, Any]:
|
|
1659
1664
|
"""Edit inline keypad of a message."""
|
|
1665
|
+
if text is not None:self._post("editMessageText", {"chat_id": chat_id,"message_id": message_id,"text": text})
|
|
1660
1666
|
return self._post("editMessageKeypad", {
|
|
1661
1667
|
"chat_id": chat_id,
|
|
1662
1668
|
"message_id": message_id,
|