Rubka 7.1.17__tar.gz → 7.2.1__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-7.1.17 → rubka-7.2.1}/PKG-INFO +1 -1
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/PKG-INFO +1 -1
- {rubka-7.1.17 → rubka-7.2.1}/rubka/asynco.py +58 -40
- {rubka-7.1.17 → rubka-7.2.1}/rubka/context.py +28 -2
- {rubka-7.1.17 → rubka-7.2.1}/rubka/filters.py +4 -3
- {rubka-7.1.17 → rubka-7.2.1}/setup.py +1 -1
- {rubka-7.1.17 → rubka-7.2.1}/README.md +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/SOURCES.txt +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/dependency_links.txt +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/entry_points.txt +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/not-zip-safe +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/requires.txt +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/Rubka.egg-info/top_level.txt +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/client/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/client/client.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/crypto/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/crypto/crypto.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/enums.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/exceptions.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/methods/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/methods/methods.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/network/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/network/helper.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/network/network.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/network/socket.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/sessions/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/sessions/sessions.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/types/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/types/socket/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/types/socket/message.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/utils/__init__.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/utils/configs.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/adaptorrubka/utils/utils.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/api.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/button.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/config.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/decorators.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/exceptions.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/helpers.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/jobs.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/keyboards.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/keypad.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/logger.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/metadata.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/rubino.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/tv.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/update.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/rubka/utils.py +0 -0
- {rubka-7.1.17 → rubka-7.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 7.1
|
|
3
|
+
Version: 7.2.1
|
|
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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 7.1
|
|
3
|
+
Version: 7.2.1
|
|
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
|
|
@@ -280,6 +280,7 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
280
280
|
self.proxy = proxy
|
|
281
281
|
self.max_msg_age = max_msg_age
|
|
282
282
|
self.retries = retries
|
|
283
|
+
self.middleware_data = []
|
|
283
284
|
|
|
284
285
|
self.retry_delay = retry_delay
|
|
285
286
|
self.raise_errors = raise_errors
|
|
@@ -346,7 +347,6 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
346
347
|
async def _post(self, method: str, data: Dict[str, Any]) -> Dict[str, Any]:
|
|
347
348
|
base_url = BASE_URLS[self.api_endpoint]
|
|
348
349
|
url = f"{base_url}/{self.token}/{method}"
|
|
349
|
-
print(url)
|
|
350
350
|
session = await self._get_session()
|
|
351
351
|
for attempt in range(1, self.retries + 1):
|
|
352
352
|
try:
|
|
@@ -542,6 +542,11 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
542
542
|
|
|
543
543
|
#decorator#
|
|
544
544
|
|
|
545
|
+
def middleware(self):
|
|
546
|
+
def decorator(func: Callable[[Any, Union[Message, InlineMessage]], None]):
|
|
547
|
+
self.middleware_data.append(func)
|
|
548
|
+
return func
|
|
549
|
+
return decorator
|
|
545
550
|
def on_message_private(
|
|
546
551
|
self,
|
|
547
552
|
chat_id: Optional[Union[str, List[str]]] = None,
|
|
@@ -1843,20 +1848,23 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
1843
1848
|
reply_to_message_id: Optional[str] = None,
|
|
1844
1849
|
chat_keypad_type: Optional[Literal["New", "Remove"]] = None,
|
|
1845
1850
|
delete_after: Optional[int] = None,
|
|
1846
|
-
parse_mode: Optional[Literal["HTML", "Markdown"]] = None
|
|
1851
|
+
parse_mode: Optional[Literal["HTML", "Markdown"]] = None,
|
|
1852
|
+
meta_data:Optional[dict] = None
|
|
1847
1853
|
) -> Dict[str, Any]:
|
|
1848
|
-
|
|
1849
1854
|
payload = {
|
|
1850
1855
|
"chat_id": chat_id,
|
|
1851
1856
|
"text": text,
|
|
1852
1857
|
"disable_notification": disable_notification,
|
|
1853
1858
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1859
|
+
if not meta_data:
|
|
1860
|
+
parse_mode_to_use = parse_mode or self.parse_mode
|
|
1861
|
+
if text:
|
|
1862
|
+
text, metadata = self._parse_text_metadata(text, parse_mode_to_use)
|
|
1863
|
+
payload["text"] = text
|
|
1864
|
+
if metadata:
|
|
1865
|
+
payload["metadata"] = metadata
|
|
1866
|
+
else :
|
|
1867
|
+
payload["metadata"] = meta_data
|
|
1860
1868
|
if chat_keypad:
|
|
1861
1869
|
payload["chat_keypad"] = chat_keypad
|
|
1862
1870
|
payload["chat_keypad_type"] = chat_keypad_type or "New"
|
|
@@ -2143,16 +2151,20 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2143
2151
|
raise ValueError(f"Invalid media type. Must be one of {allowed}")
|
|
2144
2152
|
result = await self._post("requestSendFile", {"type": media_type})
|
|
2145
2153
|
return result.get("data", {}).get("upload_url")
|
|
2146
|
-
async def _send_uploaded_file(self, chat_id: str, file_id: str,type_file : str = "file",text: Optional[str] = None, chat_keypad: Optional[Dict[str, Any]] = None, inline_keypad: Optional[Dict[str, Any]] = None, disable_notification: bool = False, reply_to_message_id: Optional[str] = None, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2154
|
+
async def _send_uploaded_file(self, chat_id: str, file_id: str,type_file : str = "file",text: Optional[str] = None, chat_keypad: Optional[Dict[str, Any]] = None, inline_keypad: Optional[Dict[str, Any]] = None, disable_notification: bool = False, reply_to_message_id: Optional[str] = None, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2147
2155
|
payload = {"chat_id": chat_id, "file_id": file_id, "text": text, "disable_notification": disable_notification, "chat_keypad_type": chat_keypad_type}
|
|
2148
2156
|
if chat_keypad: payload["chat_keypad"] = chat_keypad
|
|
2149
2157
|
if inline_keypad: payload["inline_keypad"] = inline_keypad
|
|
2150
2158
|
if reply_to_message_id: payload["reply_to_message_id"] = str(reply_to_message_id)
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2159
|
+
if not meta_data:
|
|
2160
|
+
parse_mode_to_use = parse_mode or self.parse_mode
|
|
2161
|
+
if text:
|
|
2162
|
+
text, metadata = self._parse_text_metadata(text, parse_mode_to_use)
|
|
2163
|
+
payload["text"] = text
|
|
2164
|
+
if metadata:
|
|
2165
|
+
payload["metadata"] = metadata
|
|
2166
|
+
else :
|
|
2167
|
+
payload["metadata"] = meta_data
|
|
2156
2168
|
payload["time"] = "10"
|
|
2157
2169
|
resp = await self._post("sendFile", payload)
|
|
2158
2170
|
message_id_put = resp["data"]["message_id"]
|
|
@@ -2172,26 +2184,26 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2172
2184
|
"chat_keypad_type":chat_keypad_type
|
|
2173
2185
|
}
|
|
2174
2186
|
return AttrDict(result)
|
|
2175
|
-
async def _send_file_generic(self, media_type, chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode: Optional[Literal["HTML", "Markdown"]] = None):
|
|
2187
|
+
async def _send_file_generic(self, media_type, chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None):
|
|
2176
2188
|
if path:
|
|
2177
2189
|
file_name = file_name or Path(path).name
|
|
2178
2190
|
upload_url = await self.get_upload_url(media_type)
|
|
2179
2191
|
file_id = await self.upload_media_file(upload_url, file_name, path)
|
|
2180
2192
|
if not file_id:
|
|
2181
2193
|
raise ValueError("Either path or file_id must be provided.")
|
|
2182
|
-
return await self._send_uploaded_file(chat_id=chat_id, file_id=file_id, text=text, inline_keypad=inline_keypad, chat_keypad=chat_keypad, reply_to_message_id=reply_to_message_id, disable_notification=disable_notification, chat_keypad_type=chat_keypad_type,type_file=media_type,parse_mode=parse_mode)
|
|
2183
|
-
async def send_document(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2184
|
-
return await self._send_file_generic("File", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2185
|
-
async def send_file(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, caption: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2186
|
-
return await self._send_file_generic("File", chat_id, path, file_id, caption, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2187
|
-
async def re_send(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, caption: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2188
|
-
return await self._send_file_generic("File", chat_id, path, file_id, caption, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2189
|
-
async def send_video(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2190
|
-
return await self._send_file_generic("Video", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2191
|
-
async def send_voice(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2192
|
-
return await self._send_file_generic("voice", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2193
|
-
async def send_image(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2194
|
-
return await self._send_file_generic("Image", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode)
|
|
2194
|
+
return await self._send_uploaded_file(chat_id=chat_id, file_id=file_id, text=text, inline_keypad=inline_keypad, chat_keypad=chat_keypad, reply_to_message_id=reply_to_message_id, disable_notification=disable_notification, chat_keypad_type=chat_keypad_type,type_file=media_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2195
|
+
async def send_document(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2196
|
+
return await self._send_file_generic("File", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2197
|
+
async def send_file(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, caption: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2198
|
+
return await self._send_file_generic("File", chat_id, path, file_id, caption, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2199
|
+
async def re_send(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, caption: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2200
|
+
return await self._send_file_generic("File", chat_id, path, file_id, caption, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2201
|
+
async def send_video(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2202
|
+
return await self._send_file_generic("Video", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2203
|
+
async def send_voice(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2204
|
+
return await self._send_file_generic("voice", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2205
|
+
async def send_image(self, chat_id: str, path: Optional[Union[str, Path]] = None, file_id: Optional[str] = None, text: Optional[str] = None, file_name: Optional[str] = None, inline_keypad: Optional[Dict[str, Any]] = None, chat_keypad: Optional[Dict[str, Any]] = None, reply_to_message_id: Optional[str] = None, disable_notification: bool = False, chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2206
|
+
return await self._send_file_generic("Image", chat_id, path, file_id, text, file_name, inline_keypad, chat_keypad, reply_to_message_id, disable_notification, chat_keypad_type,parse_mode=parse_mode,meta_data=meta_data)
|
|
2195
2207
|
async def send_music(
|
|
2196
2208
|
self,
|
|
2197
2209
|
chat_id: str,
|
|
@@ -2204,7 +2216,8 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2204
2216
|
reply_to_message_id: Optional[str] = None,
|
|
2205
2217
|
disable_notification: bool = False,
|
|
2206
2218
|
chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",
|
|
2207
|
-
parse_mode: Optional[Literal["HTML", "Markdown"]] = None
|
|
2219
|
+
parse_mode: Optional[Literal["HTML", "Markdown"]] = None,
|
|
2220
|
+
meta_data:Optional[dict] = None
|
|
2208
2221
|
) -> Dict[str, Any]:
|
|
2209
2222
|
valid_extensions = {"ogg", "oga", "opus", "flac"}
|
|
2210
2223
|
extension = "flac"
|
|
@@ -2237,7 +2250,8 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2237
2250
|
reply_to_message_id,
|
|
2238
2251
|
disable_notification,
|
|
2239
2252
|
chat_keypad_type,
|
|
2240
|
-
parse_mode=parse_mode
|
|
2253
|
+
parse_mode=parse_mode,
|
|
2254
|
+
meta_data=meta_data
|
|
2241
2255
|
)
|
|
2242
2256
|
async def send_gif(
|
|
2243
2257
|
self,
|
|
@@ -2251,7 +2265,8 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2251
2265
|
reply_to_message_id: Optional[str] = None,
|
|
2252
2266
|
disable_notification: bool = False,
|
|
2253
2267
|
chat_keypad_type: Optional[Literal["New", "Remove", "None"]] = "None",
|
|
2254
|
-
parse_mode: Optional[Literal["HTML", "Markdown"]] = None
|
|
2268
|
+
parse_mode: Optional[Literal["HTML", "Markdown"]] = None,
|
|
2269
|
+
meta_data:Optional[dict] = None
|
|
2255
2270
|
) -> Dict[str, Any]:
|
|
2256
2271
|
valid_extensions = {"gif"}
|
|
2257
2272
|
extension = "gif"
|
|
@@ -2284,7 +2299,7 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2284
2299
|
reply_to_message_id,
|
|
2285
2300
|
disable_notification,
|
|
2286
2301
|
chat_keypad_type,
|
|
2287
|
-
parse_mode=parse_mode
|
|
2302
|
+
parse_mode=parse_mode,meta_data=meta_data
|
|
2288
2303
|
)
|
|
2289
2304
|
|
|
2290
2305
|
async def get_avatar_me(self, save_as: str = None) -> str:
|
|
@@ -2428,18 +2443,21 @@ max_cache_size and max_msg_age help manage duplicate message processing efficien
|
|
|
2428
2443
|
return await self._post("leaveChat", {"chat_id": chat_id})
|
|
2429
2444
|
async def forward_message(self, from_chat_id: str, message_id: str, to_chat_id: str, disable_notification: bool = False) -> Dict[str, Any]:
|
|
2430
2445
|
return await self._post("forwardMessage", {"from_chat_id": from_chat_id, "message_id": message_id, "to_chat_id": to_chat_id, "disable_notification": disable_notification})
|
|
2431
|
-
async def edit_message_text(self, chat_id: str, message_id: str, text: str, parse_mode: Optional[Literal["HTML", "Markdown"]] = None) -> Dict[str, Any]:
|
|
2446
|
+
async def edit_message_text(self, chat_id: str, message_id: str, text: str, parse_mode: Optional[Literal["HTML", "Markdown"]] = None,meta_data:Optional[dict] = None) -> Dict[str, Any]:
|
|
2432
2447
|
payload = {
|
|
2433
2448
|
"chat_id": chat_id,
|
|
2434
2449
|
"message_id": message_id,
|
|
2435
2450
|
"text": text,
|
|
2436
2451
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2452
|
+
if not meta_data:
|
|
2453
|
+
parse_mode_to_use = parse_mode or self.parse_mode
|
|
2454
|
+
if text:
|
|
2455
|
+
text, metadata = self._parse_text_metadata(text, parse_mode_to_use)
|
|
2456
|
+
payload["text"] = text
|
|
2457
|
+
if metadata:
|
|
2458
|
+
payload["metadata"] = metadata
|
|
2459
|
+
else :
|
|
2460
|
+
payload["metadata"] = meta_data
|
|
2443
2461
|
return await self._post("editMessageText", payload)
|
|
2444
2462
|
async def edit_inline_keypad(self,chat_id: str,message_id: str,inline_keypad: Dict[str, Any],text: str = None) -> Dict[str, Any]:
|
|
2445
2463
|
if text is not None:await self._post("editMessageText", {"chat_id": chat_id,"message_id": message_id,"text": text})
|
|
@@ -288,6 +288,7 @@ class Message:
|
|
|
288
288
|
self.is_audio = None
|
|
289
289
|
self.is_voice = None
|
|
290
290
|
self.is_document = None
|
|
291
|
+
self.is_music = None
|
|
291
292
|
self.is_archive = None
|
|
292
293
|
self.is_executable = None
|
|
293
294
|
self.is_font = None
|
|
@@ -356,6 +357,7 @@ class Message:
|
|
|
356
357
|
self.is_photo = name.endswith((".jpg", ".jpeg", ".png", ".gif", ".webp"))
|
|
357
358
|
self.is_video = name.endswith((".mp4", ".mov", ".avi", ".mkv", ".webm"))
|
|
358
359
|
self.is_audio = name.endswith((".mp3", ".wav", ".ogg", ".m4a", ".flac"))
|
|
360
|
+
self.is_music = name.endswith((".mp3", ".wav", ".ogg", ".m4a", ".flac"))
|
|
359
361
|
self.is_voice = name.endswith((".ogg", ".m4a"))
|
|
360
362
|
self.is_document = name.endswith((".pdf", ".doc", ".docx", ".txt", ".xls", ".xlsx", ".ppt", ".pptx"))
|
|
361
363
|
self.is_archive = name.endswith((".zip", ".rar", ".7z", ".tar", ".gz"))
|
|
@@ -437,8 +439,32 @@ class Message:
|
|
|
437
439
|
reply_to_message_id=self.message_id,
|
|
438
440
|
**kwargs
|
|
439
441
|
)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
async def copy(self, to_chat_id: Optional[str], message_id: Optional[str] = None):await self.copy_message(to_chat_id, message_id)
|
|
443
|
+
async def copy_message(self, to_chat_id: Optional[str], message_id: Optional[str] = None):
|
|
444
|
+
try:
|
|
445
|
+
send_func = None
|
|
446
|
+
kwargs = {
|
|
447
|
+
"chat_id": to_chat_id,
|
|
448
|
+
"reply_to_message_id": message_id,
|
|
449
|
+
"meta_data": self.metadata
|
|
450
|
+
}
|
|
451
|
+
if getattr(self, "is_photo", False):
|
|
452
|
+
send_func = self.bot.send_image
|
|
453
|
+
elif getattr(self, "is_video", False):
|
|
454
|
+
send_func = self.bot.send_video
|
|
455
|
+
elif getattr(self, "is_document", False):
|
|
456
|
+
send_func = self.bot.send_document
|
|
457
|
+
elif getattr(self, "is_text", False):
|
|
458
|
+
send_func = self.bot.send_message
|
|
459
|
+
kwargs["text"] = self.text
|
|
460
|
+
if send_func:
|
|
461
|
+
if hasattr(self, "file") and self.file:
|
|
462
|
+
kwargs["path"] = await self.bot.get_url_file(self.file.file_id)
|
|
463
|
+
return await send_func(**kwargs)
|
|
464
|
+
else:
|
|
465
|
+
raise Exception("Unsupported message type.")
|
|
466
|
+
except Exception as e:
|
|
467
|
+
raise Exception(f"Error: {e}")
|
|
442
468
|
def reply_poll(
|
|
443
469
|
self,
|
|
444
470
|
question: str,
|
|
@@ -244,9 +244,10 @@ def chat_title_equals(value: str):
|
|
|
244
244
|
|
|
245
245
|
return Filter(lambda m: getattr(m, "chat", None) and getattr(m.chat, "title", "") == value)
|
|
246
246
|
|
|
247
|
-
def chat_id_is(
|
|
248
|
-
return Filter(lambda m: getattr(m, "
|
|
249
|
-
|
|
247
|
+
def chat_id_is(sender_id: str):
|
|
248
|
+
return Filter(lambda m: getattr(m, "chat_id", None) == sender_id)
|
|
249
|
+
def sender_id_is(sender_id: str):
|
|
250
|
+
return Filter(lambda m: getattr(m, "sender_id", None) == sender_id)
|
|
250
251
|
def chat_member_count(min_count: int = 0, max_count: int = None):
|
|
251
252
|
|
|
252
253
|
def _filter(m):
|
|
@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as f:
|
|
|
13
13
|
|
|
14
14
|
setup(
|
|
15
15
|
name='Rubka',
|
|
16
|
-
version='7.1
|
|
16
|
+
version='7.2.1',
|
|
17
17
|
description=(
|
|
18
18
|
"Rubika: A Python library for interacting with the Rubika Bot API. "
|
|
19
19
|
"This library provides an easy-to-use interface to send messages, polls, "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|