Rubka 7.1.12__py3-none-any.whl → 7.1.14__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/api.py +2 -10
- rubka/asynco.py +11 -7
- rubka/filters.py +16 -0
- rubka/metadata.py +20 -5
- {rubka-7.1.12.dist-info → rubka-7.1.14.dist-info}/METADATA +1 -1
- {rubka-7.1.12.dist-info → rubka-7.1.14.dist-info}/RECORD +9 -9
- {rubka-7.1.12.dist-info → rubka-7.1.14.dist-info}/WHEEL +0 -0
- {rubka-7.1.12.dist-info → rubka-7.1.14.dist-info}/entry_points.txt +0 -0
- {rubka-7.1.12.dist-info → rubka-7.1.14.dist-info}/top_level.txt +0 -0
rubka/api.py
CHANGED
|
@@ -54,16 +54,8 @@ def get_latest_version(package_name: str) -> str:
|
|
|
54
54
|
data = resp.json()
|
|
55
55
|
return data["info"]["version"]
|
|
56
56
|
except Exception:return None
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
installed_version = get_installed_version(package_name)
|
|
60
|
-
if installed_version is None:return
|
|
61
|
-
latest_version = get_latest_version(package_name)
|
|
62
|
-
if latest_version is None:return
|
|
63
|
-
if installed_version != latest_version:
|
|
64
|
-
print(f"\npip install {package_name}=={latest_version}\n")
|
|
65
|
-
|
|
66
|
-
check_rubka_version()
|
|
57
|
+
|
|
58
|
+
|
|
67
59
|
def show_last_six_words(text):
|
|
68
60
|
text = text.strip()
|
|
69
61
|
return text[-6:]
|
rubka/asynco.py
CHANGED
|
@@ -200,7 +200,7 @@ async def check_rubka_version():
|
|
|
200
200
|
print(f"- Latest version : {latest_version}")
|
|
201
201
|
print("\nImmediate action is required.")
|
|
202
202
|
print(f"Run the following command to update safely:")
|
|
203
|
-
print(f"\
|
|
203
|
+
print(f"\npip install {package_name}=={latest_version}\n")
|
|
204
204
|
print("Delaying this update may result in unexpected crashes, data loss, or broken functionality.")
|
|
205
205
|
print("Stay up-to-date to ensure full support and access to the latest improvements.")
|
|
206
206
|
print("For new methods and updates, visit: @rubka_library\n")
|
|
@@ -379,8 +379,11 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
379
379
|
async def get_me(self) -> Dict[str, Any]:
|
|
380
380
|
return await self._post("getMe", {})
|
|
381
381
|
async def geteToken(self):
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
try:
|
|
383
|
+
if (await self.get_me())['status'] != "OK":
|
|
384
|
+
raise InvalidTokenError("The provided bot token is invalid or expired.")
|
|
385
|
+
except Exception as e:
|
|
386
|
+
print(e)
|
|
384
387
|
from typing import Callable, Any, Optional, List
|
|
385
388
|
|
|
386
389
|
|
|
@@ -1764,11 +1767,12 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
1764
1767
|
|
|
1765
1768
|
|
|
1766
1769
|
_log("Auto-restart requested. You can call run(...) again as needed.", "warning")
|
|
1767
|
-
def run(self, sleep_time
|
|
1770
|
+
def run(self, sleep_time: float = 0.1, *args, **kwargs):
|
|
1768
1771
|
print("Connecting to the server...")
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
+
try:
|
|
1773
|
+
loop = asyncio.get_running_loop()
|
|
1774
|
+
return loop.create_task(self.run_progelry(sleep_time=sleep_time, *args, **kwargs))
|
|
1775
|
+
except RuntimeError:return asyncio.run(self.run_progelry(sleep_time=sleep_time, *args, **kwargs))
|
|
1772
1776
|
async def _delete_after_task(self, chat_id: str, message_id: str, delay: int):
|
|
1773
1777
|
try:
|
|
1774
1778
|
await asyncio.sleep(delay)
|
rubka/filters.py
CHANGED
|
@@ -110,6 +110,9 @@ def text_length(min_len: int = 0, max_len: int = None):
|
|
|
110
110
|
def text_regex(pattern: str):
|
|
111
111
|
regex = re.compile(pattern)
|
|
112
112
|
return Filter(lambda m: getattr(m, "text", "") and regex.search(m.text))
|
|
113
|
+
def regex(pattern: str):
|
|
114
|
+
regex = re.compile(pattern)
|
|
115
|
+
return Filter(lambda m: getattr(m, "text", "") and regex.search(m.text))
|
|
113
116
|
def text_startswith(prefix: str):
|
|
114
117
|
return Filter(lambda m: getattr(m, "text", "").startswith(prefix) if getattr(m, "text", None) else False)
|
|
115
118
|
def text_endswith(suffix: str):
|
|
@@ -149,6 +152,19 @@ def sticker_id_is(sid: str):
|
|
|
149
152
|
return Filter(lambda m: m.sticker and getattr(m.sticker, "sticker_id", None) == sid)
|
|
150
153
|
def sticker_emoji_is(emoji: str):
|
|
151
154
|
return Filter(lambda m: m.sticker and getattr(m.sticker, "emoji", None) == emoji)
|
|
155
|
+
is_bold = Filter(lambda m: getattr(m, "is_bold", False))
|
|
156
|
+
is_italic = Filter(lambda m: getattr(m, "is_italic", False))
|
|
157
|
+
is_strike = Filter(lambda m: getattr(m, "is_strike", False))
|
|
158
|
+
is_underline = Filter(lambda m: getattr(m, "is_underline", False))
|
|
159
|
+
is_quote = Filter(lambda m: getattr(m, "is_quote", False))
|
|
160
|
+
is_spoiler = Filter(lambda m: getattr(m, "is_spoiler", False))
|
|
161
|
+
is_pre = Filter(lambda m: getattr(m, "is_pre", False))
|
|
162
|
+
is_mono = Filter(lambda m: getattr(m, "is_mono", False))
|
|
163
|
+
is_link_meta = Filter(lambda m: getattr(m, "is_link_meta", False))
|
|
164
|
+
has_metadata = Filter(lambda m: getattr(m, "has_metadata", False))
|
|
165
|
+
meta_links_contain = lambda keyword: Filter(lambda m: any(keyword in link for link in getattr(m, "meta_links", [])))
|
|
166
|
+
meta_link_positions_contain = lambda keyword: Filter(lambda m: any(keyword in link.get("url", "") for link in getattr(m, "meta_link_positions", [])))
|
|
167
|
+
meta_types_include = lambda types: Filter(lambda m: any(t in getattr(m, "meta_types", []) for t in types))
|
|
152
168
|
def poll_question_contains(keyword: str):
|
|
153
169
|
return Filter(lambda m: m.poll and keyword in getattr(m.poll, "question", ""))
|
|
154
170
|
def poll_option_count(min_options: int = 1, max_options: int = None):
|
rubka/metadata.py
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from typing import Any, Dict, List
|
|
3
3
|
import markdownify
|
|
4
|
+
def _normalize_multiline_quote(text: str) -> str:
|
|
5
|
+
lines = text.splitlines()
|
|
6
|
+
normalized_lines = []
|
|
7
|
+
quote_block = []
|
|
8
|
+
|
|
9
|
+
for line in lines + [""]:
|
|
10
|
+
if line.startswith(">"):quote_block.append(line[1:].strip())
|
|
11
|
+
else:
|
|
12
|
+
if quote_block:
|
|
13
|
+
normalized_lines.append("$" + "\n".join(quote_block) + "$")
|
|
14
|
+
quote_block = []
|
|
15
|
+
normalized_lines.append(line)
|
|
16
|
+
return "\n".join(normalized_lines).strip()
|
|
17
|
+
|
|
4
18
|
class Track_parsed:
|
|
5
19
|
_PATT = re.compile(
|
|
6
20
|
r"(?P<pre>```(?P<pre_c>[\s\S]*?)```)"
|
|
@@ -10,13 +24,11 @@ class Track_parsed:
|
|
|
10
24
|
r"|(?P<underline>--(?P<underline_c>.*?)--)"
|
|
11
25
|
r"|(?P<link>\[(?P<link_text>.*?)\]\((?P<link_url>\S+?)\))"
|
|
12
26
|
r"|(?P<quote>\$(?P<quote_c>[\s\S]*?)\$)"
|
|
27
|
+
r"|(?P<quote_md>^>(?P<quote_md_c>.*?)(?:\n|$))"
|
|
13
28
|
r"|(?P<strike>~~(?P<strike_c>.*?)~~)"
|
|
14
29
|
r"|(?P<spoiler>\|\|(?P<spoiler_c>.*?)\|\|)",
|
|
15
30
|
flags=re.DOTALL,
|
|
16
31
|
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
32
|
_TYPE_MAP = {
|
|
21
33
|
"pre": "Pre",
|
|
22
34
|
"bold": "Bold",
|
|
@@ -26,6 +38,7 @@ class Track_parsed:
|
|
|
26
38
|
"strike": "Strike",
|
|
27
39
|
"spoiler": "Spoiler",
|
|
28
40
|
"quote": "Quote",
|
|
41
|
+
"quote_md": "Quote",
|
|
29
42
|
"link": "Link",
|
|
30
43
|
}
|
|
31
44
|
|
|
@@ -42,7 +55,9 @@ class Track_parsed:
|
|
|
42
55
|
return src
|
|
43
56
|
|
|
44
57
|
def transcribe(self, src: str, mode: str = "MARKDOWN") -> Dict[str, Any]:
|
|
45
|
-
if mode and mode.upper() == "HTML":
|
|
58
|
+
if mode and mode.upper() == "HTML":
|
|
59
|
+
src = self._html2md(src)
|
|
60
|
+
src = _normalize_multiline_quote(src)
|
|
46
61
|
|
|
47
62
|
payload_parts: List[Dict[str, Any]] = []
|
|
48
63
|
|
|
@@ -67,7 +82,7 @@ class Track_parsed:
|
|
|
67
82
|
else:
|
|
68
83
|
inner = m.group(f"{gname}_c") or ""
|
|
69
84
|
link_href = None
|
|
70
|
-
if gname
|
|
85
|
+
if gname in ["quote", "quote_md"]:
|
|
71
86
|
inner_metadata = self.transcribe(inner, mode="MARKDOWN")
|
|
72
87
|
inner = inner_metadata["text"]
|
|
73
88
|
if "metadata" in inner_metadata:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 7.1.
|
|
3
|
+
Version: 7.1.14
|
|
4
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
6
|
Download-URL: https://github.com/Mahdy-Ahmadi/rubka/archive/refs/tags/v6.6.4.zip
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
rubka/__init__.py,sha256=P6IBiORfp-GqKHe5LZ-5lldWyG7tnrUYUcAQDUgwXmY,1973
|
|
2
|
-
rubka/api.py,sha256=
|
|
3
|
-
rubka/asynco.py,sha256=
|
|
2
|
+
rubka/api.py,sha256=71B10uy2iU3gP6yHQltjyTkq2mgkzWuV1TsE2kgHOZg,68092
|
|
3
|
+
rubka/asynco.py,sha256=f54Pc7tb2awE0qz-uALA_gExvBiCFlxlKR7ICTLdPSs,119448
|
|
4
4
|
rubka/button.py,sha256=woSzZVd5MtTqOrP-YgkH5b0GS9y4DuKBsFSc9-KuLnk,13320
|
|
5
5
|
rubka/config.py,sha256=Bck59xkOiqioLv0GkQ1qPGnBXVctz1hKk6LT4h2EPx0,78
|
|
6
6
|
rubka/context.py,sha256=brl7WXe4nzpLpcaMiOLVMfOs8BFTU5z5Sw6AIecCtOA,42492
|
|
7
7
|
rubka/decorators.py,sha256=hGwUoE4q2ImrunJIGJ_kzGYYxQf1ueE0isadqraKEts,1157
|
|
8
8
|
rubka/exceptions.py,sha256=DDOGIHEMoliHNW5E7C_s38WZgqqMBv9812fcJGvj7TY,1173
|
|
9
|
-
rubka/filters.py,sha256=
|
|
9
|
+
rubka/filters.py,sha256=fQYgFKhXfq18pOzjkKc3BmOgoZqQKriid_SAQR5uVT4,13254
|
|
10
10
|
rubka/helpers.py,sha256=QvK5lg4QDmycImxJia4m8HDpfacYzbKKZiOk536mafc,65161
|
|
11
11
|
rubka/jobs.py,sha256=GvLMLsVhcSEzRTgkvnPISPEBN71suW2xXI0hUaUZPTo,378
|
|
12
12
|
rubka/keyboards.py,sha256=7nr-dT2bQJVQnQ6RMWPTSjML6EEk6dsBx-4d8pab8xk,488
|
|
13
13
|
rubka/keypad.py,sha256=yGsNt8W5HtUFBzVF1m_p7GySlu1hwIcSvXZ4BTdrlvg,9558
|
|
14
14
|
rubka/logger.py,sha256=J2I6NiK1z32lrAzC4H1Et6WPMBXxXGCVUsW4jgcAofs,289
|
|
15
|
-
rubka/metadata.py,sha256=
|
|
15
|
+
rubka/metadata.py,sha256=7LKtFpZAGOvOHwsFcGds99vyHFmXVNNfdpyuUEKOHBI,4277
|
|
16
16
|
rubka/rubino.py,sha256=HOILsm2zOIRe9EW1hxhLinhjwE_TvFrOAxBsg9T_L5E,61701
|
|
17
17
|
rubka/tv.py,sha256=rBoyCadCH3I3YqQGrQYv_dLtTg1I63AzVf1orn-hbko,5724
|
|
18
18
|
rubka/update.py,sha256=brl7WXe4nzpLpcaMiOLVMfOs8BFTU5z5Sw6AIecCtOA,42492
|
|
@@ -38,8 +38,8 @@ rubka/adaptorrubka/types/socket/message.py,sha256=0WgLMZh4eow8Zn7AiSX4C3GZjQTkIg
|
|
|
38
38
|
rubka/adaptorrubka/utils/__init__.py,sha256=OgCFkXdNFh379quNwIVOAWY2NP5cIOxU5gDRRALTk4o,54
|
|
39
39
|
rubka/adaptorrubka/utils/configs.py,sha256=nMUEOJh1NqDJsf9W9PurkN_DLYjO6kKPMm923i4Jj_A,492
|
|
40
40
|
rubka/adaptorrubka/utils/utils.py,sha256=5-LioLNYX_TIbQGDeT50j7Sg9nAWH2LJUUs-iEXpsUY,8816
|
|
41
|
-
rubka-7.1.
|
|
42
|
-
rubka-7.1.
|
|
43
|
-
rubka-7.1.
|
|
44
|
-
rubka-7.1.
|
|
45
|
-
rubka-7.1.
|
|
41
|
+
rubka-7.1.14.dist-info/METADATA,sha256=aP-fn92U05-HDs5cs2N2EE7TTD5Byl-HeqbGaSsweeE,34645
|
|
42
|
+
rubka-7.1.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
43
|
+
rubka-7.1.14.dist-info/entry_points.txt,sha256=4aESuUmuUOALMUy7Kucv_Gb5YlqhsJmTmdXLlZU9sJ0,46
|
|
44
|
+
rubka-7.1.14.dist-info/top_level.txt,sha256=vy2A4lot11cRMdQS-F4HDCIXL3JK8RKfu7HMDkezJW4,6
|
|
45
|
+
rubka-7.1.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|