RubigramClient 1.7.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.
- rubigram/__init__.py +15 -0
- rubigram/client.py +294 -0
- rubigram/enums/__init__.py +52 -0
- rubigram/enums/buttons/__init__.py +13 -0
- rubigram/enums/buttons/button_calendar_type.py +20 -0
- rubigram/enums/buttons/button_location_type.py +20 -0
- rubigram/enums/buttons/button_selection_get_type.py +20 -0
- rubigram/enums/buttons/button_selection_search_type.py +20 -0
- rubigram/enums/buttons/button_selection_type.py +22 -0
- rubigram/enums/buttons/button_textbox_type_keypad.py +20 -0
- rubigram/enums/buttons/button_textbox_type_line.py +20 -0
- rubigram/enums/buttons/button_type.py +58 -0
- rubigram/enums/chat_action_type.py +22 -0
- rubigram/enums/chat_keypad_type.py +20 -0
- rubigram/enums/chat_type.py +24 -0
- rubigram/enums/enum.py +6 -0
- rubigram/enums/file_type.py +28 -0
- rubigram/enums/forwarded_from_type.py +22 -0
- rubigram/enums/live_location_status.py +20 -0
- rubigram/enums/message_sender_type.py +20 -0
- rubigram/enums/metadata_type.py +18 -0
- rubigram/enums/parse_mode.py +20 -0
- rubigram/enums/payment_status_type.py +20 -0
- rubigram/enums/poll_status_type.py +20 -0
- rubigram/enums/update_endpoint_type.py +26 -0
- rubigram/enums/update_type.py +28 -0
- rubigram/errors.py +16 -0
- rubigram/filters.py +865 -0
- rubigram/http_session.py +96 -0
- rubigram/methods/__init__.py +26 -0
- rubigram/methods/chats/__init__.py +10 -0
- rubigram/methods/chats/get_chat.py +53 -0
- rubigram/methods/decorators/__init__.py +25 -0
- rubigram/methods/decorators/on_inline_message.py +70 -0
- rubigram/methods/decorators/on_message.py +62 -0
- rubigram/methods/decorators/on_remove_message.py +65 -0
- rubigram/methods/decorators/on_start.py +65 -0
- rubigram/methods/decorators/on_started_bot.py +70 -0
- rubigram/methods/decorators/on_stop.py +65 -0
- rubigram/methods/decorators/on_stopped_bot.py +70 -0
- rubigram/methods/decorators/on_update_message.py +70 -0
- rubigram/methods/files/__init__.py +32 -0
- rubigram/methods/files/download_file.py +118 -0
- rubigram/methods/files/get_file.py +41 -0
- rubigram/methods/files/get_file_name.py +41 -0
- rubigram/methods/files/request_send_file.py +49 -0
- rubigram/methods/files/send_file.py +133 -0
- rubigram/methods/files/send_gif.py +51 -0
- rubigram/methods/files/send_music.py +97 -0
- rubigram/methods/files/send_photo.py +95 -0
- rubigram/methods/files/send_video.py +96 -0
- rubigram/methods/files/send_voice.py +96 -0
- rubigram/methods/files/upload_file.py +114 -0
- rubigram/methods/messages/__init__.py +34 -0
- rubigram/methods/messages/delete_messages.py +84 -0
- rubigram/methods/messages/edit_chat_keypad.py +68 -0
- rubigram/methods/messages/edit_message.py +82 -0
- rubigram/methods/messages/edit_message_keypad.py +72 -0
- rubigram/methods/messages/edit_message_text.py +68 -0
- rubigram/methods/messages/forward_message.py +78 -0
- rubigram/methods/messages/remove_chat_keypad.py +46 -0
- rubigram/methods/messages/send_contact.py +114 -0
- rubigram/methods/messages/send_location.py +108 -0
- rubigram/methods/messages/send_message.py +115 -0
- rubigram/methods/messages/send_poll.py +104 -0
- rubigram/methods/messages/send_sticker.py +98 -0
- rubigram/methods/network/__init__.py +12 -0
- rubigram/methods/network/request.py +129 -0
- rubigram/methods/settings/__init__.py +16 -0
- rubigram/methods/settings/set_command.py +50 -0
- rubigram/methods/settings/setup_endpoints.py +48 -0
- rubigram/methods/settings/update_bot_endpoint.py +62 -0
- rubigram/methods/updates/__init__.py +14 -0
- rubigram/methods/updates/get_me.py +35 -0
- rubigram/methods/updates/get_update.py +62 -0
- rubigram/methods/utilities/__init__.py +14 -0
- rubigram/methods/utilities/dispatcher.py +66 -0
- rubigram/methods/utilities/run.py +118 -0
- rubigram/rubino/__init__.py +6 -0
- rubigram/rubino/client.py +374 -0
- rubigram/rubino/network.py +129 -0
- rubigram/server/__init__.py +6 -0
- rubigram/server/server.py +245 -0
- rubigram/state/__init__.py +7 -0
- rubigram/state/state.py +121 -0
- rubigram/state/storage.py +131 -0
- rubigram/types/__init__.py +66 -0
- rubigram/types/aux_data.py +28 -0
- rubigram/types/bot.py +51 -0
- rubigram/types/bot_command.py +26 -0
- rubigram/types/buttons/__init__.py +13 -0
- rubigram/types/buttons/button.py +59 -0
- rubigram/types/buttons/button_calendar.py +40 -0
- rubigram/types/buttons/button_location.py +40 -0
- rubigram/types/buttons/button_number_picker.py +34 -0
- rubigram/types/buttons/button_selection.py +48 -0
- rubigram/types/buttons/button_selection_item.py +32 -0
- rubigram/types/buttons/button_string_picker.py +29 -0
- rubigram/types/buttons/button_text_box.py +40 -0
- rubigram/types/chat.py +86 -0
- rubigram/types/config/__init__.py +6 -0
- rubigram/types/config/object.py +442 -0
- rubigram/types/contact_message.py +29 -0
- rubigram/types/file.py +78 -0
- rubigram/types/forwarded_from.py +39 -0
- rubigram/types/keypads/__init__.py +7 -0
- rubigram/types/keypads/keypad.py +31 -0
- rubigram/types/keypads/keypad_row.py +23 -0
- rubigram/types/live_location.py +44 -0
- rubigram/types/location.py +24 -0
- rubigram/types/messages/__init__.py +8 -0
- rubigram/types/messages/inline_message.py +78 -0
- rubigram/types/messages/message.py +117 -0
- rubigram/types/messages/update_message.py +341 -0
- rubigram/types/metadata/__init__.py +7 -0
- rubigram/types/metadata/metadata.py +43 -0
- rubigram/types/metadata/metadata_parts.py +42 -0
- rubigram/types/payment_status.py +30 -0
- rubigram/types/poll.py +32 -0
- rubigram/types/poll_status.py +40 -0
- rubigram/types/sticker.py +33 -0
- rubigram/types/updates/__init__.py +7 -0
- rubigram/types/updates/update.py +917 -0
- rubigram/types/updates/updates.py +56 -0
- rubigram/utils/__init__.py +14 -0
- rubigram/utils/auto_delete.py +93 -0
- rubigram/utils/parser.py +99 -0
- rubigramclient-1.7.17.dist-info/METADATA +215 -0
- rubigramclient-1.7.17.dist-info/RECORD +132 -0
- rubigramclient-1.7.17.dist-info/WHEEL +5 -0
- rubigramclient-1.7.17.dist-info/licenses/LICENSE +21 -0
- rubigramclient-1.7.17.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from .config import Object
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Location(Object):
|
|
12
|
+
"""
|
|
13
|
+
**Represents a geographical location.**
|
|
14
|
+
`from rubigram.types import Location`
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
longitude (`str`):
|
|
18
|
+
Longitude of the location.
|
|
19
|
+
|
|
20
|
+
latitude (`str`):
|
|
21
|
+
Latitude of the location.
|
|
22
|
+
"""
|
|
23
|
+
longitude: str
|
|
24
|
+
latitude: str
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from .message import Message
|
|
7
|
+
from .update_message import UMessage
|
|
8
|
+
from .inline_message import InlineMessage
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from ..config import Object
|
|
11
|
+
import rubigram
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class InlineMessage(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents an inline message in Rubigram.**
|
|
18
|
+
`from rubigram.types import InlineMessage`
|
|
19
|
+
|
|
20
|
+
Inline messages are sent in response to inline queries and may include text,
|
|
21
|
+
files, location, or auxiliary data.
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
chat_id (`str`):
|
|
25
|
+
ID of the chat where the message is sent.
|
|
26
|
+
|
|
27
|
+
sender_id (`Optional[str]`):
|
|
28
|
+
ID of the sender.
|
|
29
|
+
|
|
30
|
+
text (`Optional[str]`):
|
|
31
|
+
Text content of the message.
|
|
32
|
+
|
|
33
|
+
message_id (`Optional[str]`):
|
|
34
|
+
Unique identifier of the message.
|
|
35
|
+
|
|
36
|
+
file (`Optional[rubigram.types.File]`):
|
|
37
|
+
File attached to the message.
|
|
38
|
+
|
|
39
|
+
location (`Optional[rubigram.types.Location]`):
|
|
40
|
+
Location attached to the message.
|
|
41
|
+
|
|
42
|
+
aux_data (`Optional[rubigram.types.AuxData]`):
|
|
43
|
+
Additional data attached to the message.
|
|
44
|
+
|
|
45
|
+
client (`Optional[rubigram.Client]`):
|
|
46
|
+
The Rubigram client associated with the message.
|
|
47
|
+
"""
|
|
48
|
+
chat_id: str
|
|
49
|
+
sender_id: Optional[str] = None
|
|
50
|
+
text: Optional[str] = None
|
|
51
|
+
message_id: Optional[str] = None
|
|
52
|
+
file: Optional[rubigram.types.File] = None
|
|
53
|
+
location: Optional[rubigram.types.Location] = None
|
|
54
|
+
aux_data: Optional[rubigram.types.AuxData] = None
|
|
55
|
+
client: Optional[rubigram.Client] = None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def answer(
|
|
59
|
+
self,
|
|
60
|
+
text: str,
|
|
61
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
62
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
63
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
64
|
+
disable_notification: bool = False,
|
|
65
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
66
|
+
auto_delete: Optional[int] = None
|
|
67
|
+
) -> rubigram.types.UMessage:
|
|
68
|
+
return await self.client.send_message(
|
|
69
|
+
self.chat_id,
|
|
70
|
+
text,
|
|
71
|
+
chat_keypad,
|
|
72
|
+
inline_keypad,
|
|
73
|
+
chat_keypad_type,
|
|
74
|
+
disable_notification,
|
|
75
|
+
self.message_id,
|
|
76
|
+
parse_mode,
|
|
77
|
+
auto_delete
|
|
78
|
+
)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from ..config import Object
|
|
11
|
+
import html
|
|
12
|
+
import rubigram
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Message(Object):
|
|
17
|
+
"""
|
|
18
|
+
**Represents a message in Rubigram.**
|
|
19
|
+
`from rubigram.types import Message`
|
|
20
|
+
|
|
21
|
+
This object can represent different types of messages including text, files,
|
|
22
|
+
stickers, contacts, polls, live locations, and forwarded messages.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
id (`str`):
|
|
26
|
+
Unique identifier of the message.
|
|
27
|
+
|
|
28
|
+
text (`Optional[str]`):
|
|
29
|
+
Text content of the message.
|
|
30
|
+
|
|
31
|
+
time (`Optional[str]`):
|
|
32
|
+
Timestamp of when the message was sent.
|
|
33
|
+
|
|
34
|
+
is_edited (`Optional[bool]`):
|
|
35
|
+
Whether the message has been edited.
|
|
36
|
+
|
|
37
|
+
sender_type (`Optional[rubigram.enums.MessageSenderType]`):
|
|
38
|
+
Type of the sender (User or Bot).
|
|
39
|
+
|
|
40
|
+
sender_id (`Optional[str]`):
|
|
41
|
+
Unique identifier of the sender.
|
|
42
|
+
|
|
43
|
+
aux_data (`Optional[rubigram.types.AuxData]`):
|
|
44
|
+
Additional data attached to the message.
|
|
45
|
+
|
|
46
|
+
file (`Optional[rubigram.types.File]`):
|
|
47
|
+
File attached to the message.
|
|
48
|
+
|
|
49
|
+
reply_to_message_id (`Optional[str]`):
|
|
50
|
+
ID of the message this is replying to.
|
|
51
|
+
|
|
52
|
+
forwarded_from (`Optional[rubigram.types.ForwardedFrom]`):
|
|
53
|
+
Information about the original sender if forwarded.
|
|
54
|
+
|
|
55
|
+
forwarded_no_link (`Optional[str]`):
|
|
56
|
+
Forwarded message without link.
|
|
57
|
+
|
|
58
|
+
location (`Optional[rubigram.types.Location]`):
|
|
59
|
+
Location attached to the message.
|
|
60
|
+
|
|
61
|
+
sticker (`Optional[rubigram.types.Sticker]`):
|
|
62
|
+
Sticker attached to the message.
|
|
63
|
+
|
|
64
|
+
contact_message (`Optional[rubigram.types.ContactMessage]`):
|
|
65
|
+
Contact information attached to the message.
|
|
66
|
+
|
|
67
|
+
poll (`Optional[rubigram.types.Poll]`):
|
|
68
|
+
Poll attached to the message.
|
|
69
|
+
|
|
70
|
+
live_location (`Optional[rubigram.types.LiveLocation]`):
|
|
71
|
+
Live location attached to the message.
|
|
72
|
+
|
|
73
|
+
metadata (`Optional[rubigram.types.MetaData]`):
|
|
74
|
+
Metadata describing text formatting, links, mentions, etc.
|
|
75
|
+
|
|
76
|
+
client (`Optional[rubigram.Client]`):
|
|
77
|
+
The Rubigram client associated with the message.
|
|
78
|
+
"""
|
|
79
|
+
id: str
|
|
80
|
+
text: Optional[str] = None
|
|
81
|
+
time: Optional[str] = None
|
|
82
|
+
is_edited: Optional[bool] = None
|
|
83
|
+
sender_type: Optional[Union[str, rubigram.enums.MessageSenderType]] = None
|
|
84
|
+
sender_id: Optional[str] = None
|
|
85
|
+
aux_data: Optional[rubigram.types.AuxData] = None
|
|
86
|
+
file: Optional[rubigram.types.File] = None
|
|
87
|
+
reply_to_message_id: Optional[str] = None
|
|
88
|
+
forwarded_from: Optional[rubigram.types.ForwardedFrom] = None
|
|
89
|
+
forwarded_no_link: Optional[str] = None
|
|
90
|
+
location: Optional[rubigram.types.Location] = None
|
|
91
|
+
sticker: Optional[rubigram.types.Sticker] = None
|
|
92
|
+
contact_message: Optional[rubigram.types.ContactMessage] = None
|
|
93
|
+
poll: Optional[rubigram.types.Poll] = None
|
|
94
|
+
live_location: Optional[rubigram.types.LiveLocation] = None
|
|
95
|
+
metadata: Optional[rubigram.types.Metadata] = None
|
|
96
|
+
client: Optional[rubigram.Client] = None
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def mention(self):
|
|
100
|
+
"""
|
|
101
|
+
**Generate an HTML mention for the message sender.**
|
|
102
|
+
|
|
103
|
+
Usage:
|
|
104
|
+
message.mention()
|
|
105
|
+
message.mention("Custom Name")
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
callable: Function that returns HTML mention string.
|
|
109
|
+
"""
|
|
110
|
+
def func(text: Optional[str] = None) -> str:
|
|
111
|
+
if not self.sender_id:
|
|
112
|
+
raise ValueError("Cannot mention without sender_id")
|
|
113
|
+
|
|
114
|
+
name = html.escape(text or self.sender_id)
|
|
115
|
+
return f"@@{name}|{self.sender_id}@@"
|
|
116
|
+
|
|
117
|
+
return func
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from ..config import Object
|
|
11
|
+
from io import BytesIO
|
|
12
|
+
import rubigram
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class UMessage(Object):
|
|
17
|
+
"""
|
|
18
|
+
**Represents an updatable message in Rubigram.**
|
|
19
|
+
`from rubigram.types import UMessage`
|
|
20
|
+
|
|
21
|
+
This class extends the base message functionality by providing
|
|
22
|
+
methods to edit, delete, and forward messages directly through
|
|
23
|
+
the bound Rubigram client instance.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
message_id (`Optional[str]`):
|
|
27
|
+
Unique identifier of the message.
|
|
28
|
+
|
|
29
|
+
file_id (`Optional[str]`):
|
|
30
|
+
Identifier of the file attached to the message (if any).
|
|
31
|
+
|
|
32
|
+
chat_id (`Optional[str]`):
|
|
33
|
+
Identifier of the chat where the message is located.
|
|
34
|
+
|
|
35
|
+
client (`Optional[rubigram.Client]`):
|
|
36
|
+
The Rubigram client instance bound to this message.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
message_id: Optional[str] = None
|
|
40
|
+
file_id: Optional[str] = None
|
|
41
|
+
chat_id: Optional[str] = None
|
|
42
|
+
client: Optional["rubigram.Client"] = None
|
|
43
|
+
|
|
44
|
+
async def reply(
|
|
45
|
+
self,
|
|
46
|
+
text: str,
|
|
47
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
48
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
49
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
50
|
+
disable_notification: bool = False,
|
|
51
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
52
|
+
auto_delete: Optional[int] = None
|
|
53
|
+
) -> UMessage:
|
|
54
|
+
"""
|
|
55
|
+
**Reply to the current message with text and optional keypads.**
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
text (`str`):
|
|
59
|
+
The text of the reply message.
|
|
60
|
+
|
|
61
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
62
|
+
Keypad to show in the chat. Defaults to None.
|
|
63
|
+
|
|
64
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
65
|
+
Inline keypad to show. Defaults to None.
|
|
66
|
+
|
|
67
|
+
chat_keypad_type (`Optional[rubigramenums.ChatKeypadType]`):
|
|
68
|
+
Type of chat keypad. Defaults to None.
|
|
69
|
+
|
|
70
|
+
disable_notification (`Optional[bool]`):
|
|
71
|
+
If True, disables notification for the message. Defaults to None.
|
|
72
|
+
|
|
73
|
+
auto_delete (`Optional[int]`):
|
|
74
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
78
|
+
|
|
79
|
+
Example:
|
|
80
|
+
.. code-block:: python
|
|
81
|
+
|
|
82
|
+
await update.reply(
|
|
83
|
+
text=text,
|
|
84
|
+
chat_keypad=chat_keypad,
|
|
85
|
+
chat_keypad_type=rubigram.enums.ChatKeypadType.New,
|
|
86
|
+
disable_notification=True
|
|
87
|
+
)
|
|
88
|
+
"""
|
|
89
|
+
return await self.client.send_message(
|
|
90
|
+
self.chat_id,
|
|
91
|
+
text,
|
|
92
|
+
chat_keypad,
|
|
93
|
+
inline_keypad,
|
|
94
|
+
chat_keypad_type,
|
|
95
|
+
disable_notification,
|
|
96
|
+
self.message_id,
|
|
97
|
+
parse_mode,
|
|
98
|
+
auto_delete
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
async def delete(self):
|
|
102
|
+
"""
|
|
103
|
+
**Delete this message from the chat.**
|
|
104
|
+
|
|
105
|
+
Sends a request to Rubigram to remove the message identified
|
|
106
|
+
by this object's `message_id` from its associated chat.
|
|
107
|
+
|
|
108
|
+
Example:
|
|
109
|
+
.. code-block:: python
|
|
110
|
+
|
|
111
|
+
message = await client.send_message(
|
|
112
|
+
chat_id=chat_id,
|
|
113
|
+
text=text
|
|
114
|
+
)
|
|
115
|
+
await message.delete()
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Raises:
|
|
119
|
+
"""
|
|
120
|
+
return await self.client.delete_messages(self.chat_id, self.message_id)
|
|
121
|
+
|
|
122
|
+
async def edit(
|
|
123
|
+
self,
|
|
124
|
+
text: Optional[str] = None,
|
|
125
|
+
inline: Optional[rubigram.types.Keypad] = None,
|
|
126
|
+
keypad: Optional[rubigram.types.Keypad] = None,
|
|
127
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None
|
|
128
|
+
) -> None:
|
|
129
|
+
"""
|
|
130
|
+
**Edit this message's text, inline keyboard, or chat keypad.**
|
|
131
|
+
|
|
132
|
+
This method provides a unified way to update message components such as text,
|
|
133
|
+
inline keyboards, and chat keypads. You can update one or more components
|
|
134
|
+
in a single call.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
text (`Optional[str]`):
|
|
138
|
+
New text content to replace the current message text.
|
|
139
|
+
If None, the text remains unchanged.
|
|
140
|
+
|
|
141
|
+
inline (`Optional[rubigram.types.Keypad]`):
|
|
142
|
+
New inline keyboard to attach to the message.
|
|
143
|
+
If None, the inline keyboard remains unchanged.
|
|
144
|
+
|
|
145
|
+
keypad (`Optional[rubigram.types.Keypad]`):
|
|
146
|
+
New chat keypad to attach to the chat.
|
|
147
|
+
If None, the chat keypad remains unchanged.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
Example:
|
|
151
|
+
.. code-block:: python
|
|
152
|
+
|
|
153
|
+
await client.send_message(
|
|
154
|
+
chat_id=chat_id,
|
|
155
|
+
text=text,
|
|
156
|
+
chat_keypad=keypad,
|
|
157
|
+
chat_keypad_type=rubigram.enums.ChatKeypadType.New
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
# Edit only the text
|
|
161
|
+
await message.edit(text=new_text)
|
|
162
|
+
|
|
163
|
+
# Edit only the chat keyboard
|
|
164
|
+
await message.edit(keypad=new_keypad)
|
|
165
|
+
|
|
166
|
+
# Edit both text and keypad
|
|
167
|
+
await message.edit(
|
|
168
|
+
text=new_text,
|
|
169
|
+
keypad=new_keypad
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Raises:
|
|
174
|
+
"""
|
|
175
|
+
if text:
|
|
176
|
+
await self.edit_text(text, parse_mode)
|
|
177
|
+
if inline:
|
|
178
|
+
await self.edit_inline(inline)
|
|
179
|
+
if keypad:
|
|
180
|
+
await self.edit_keypad(keypad)
|
|
181
|
+
|
|
182
|
+
async def edit_text(
|
|
183
|
+
self,
|
|
184
|
+
text: str,
|
|
185
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None
|
|
186
|
+
):
|
|
187
|
+
"""
|
|
188
|
+
**Edit the text content of this message.**
|
|
189
|
+
|
|
190
|
+
Updates the text content of the message while preserving other
|
|
191
|
+
message components like inline keyboards or attachments.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
text (`str`):
|
|
195
|
+
The new text content for the message.
|
|
196
|
+
Cannot be empty or None.
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
.. code-block:: python
|
|
200
|
+
|
|
201
|
+
message = await client.send_message(
|
|
202
|
+
chat_id=chat_id,
|
|
203
|
+
text=text
|
|
204
|
+
)
|
|
205
|
+
updated_message = await message.edit_text(text=new_text)
|
|
206
|
+
|
|
207
|
+
Raises:
|
|
208
|
+
ValueError: If text is empty or None.
|
|
209
|
+
Exception: If the message cannot be edited due to permissions or other issues.
|
|
210
|
+
"""
|
|
211
|
+
return await self.client.edit_message_text(
|
|
212
|
+
self.chat_id,
|
|
213
|
+
self.message_id,
|
|
214
|
+
text,
|
|
215
|
+
parse_mode
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
async def edit_keypad(
|
|
219
|
+
self,
|
|
220
|
+
keypad: rubigram.types.Keypad
|
|
221
|
+
):
|
|
222
|
+
"""
|
|
223
|
+
**Edit the chat keypad for the chat of this message.**
|
|
224
|
+
|
|
225
|
+
Updates the chat keypad (custom keyboard) for the chat where this message
|
|
226
|
+
is located. This affects the keyboard shown to all users in the chat.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
keypad (`rubigram.types.Keypad`):
|
|
230
|
+
The new chat keypad to attach to the chat.
|
|
231
|
+
Contains rows of buttons and display settings.
|
|
232
|
+
|
|
233
|
+
Example:
|
|
234
|
+
.. code-block:: python
|
|
235
|
+
|
|
236
|
+
from rubigram.types import Keypad, KeypadRow, Button
|
|
237
|
+
|
|
238
|
+
keypad = Keypad(rows=[
|
|
239
|
+
KeypadRow(buttons=[
|
|
240
|
+
Button(button_text="Option 1", id="btn1"),
|
|
241
|
+
Button(button_text="Option 2", id="btn2")
|
|
242
|
+
])
|
|
243
|
+
])
|
|
244
|
+
|
|
245
|
+
await message.edit_keypad(keypad=keypad)
|
|
246
|
+
|
|
247
|
+
Note:
|
|
248
|
+
This method updates the keypad for the entire chat, not just this specific message.
|
|
249
|
+
"""
|
|
250
|
+
return await self.client.edit_chat_keypad(
|
|
251
|
+
self.chat_id,
|
|
252
|
+
keypad
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
async def edit_inline(
|
|
256
|
+
self,
|
|
257
|
+
inline: rubigram.types.Keypad
|
|
258
|
+
):
|
|
259
|
+
"""
|
|
260
|
+
**Edit the inline keyboard attached to this message.**
|
|
261
|
+
|
|
262
|
+
Updates the inline keyboard (buttons displayed below the message)
|
|
263
|
+
for this specific message without affecting the message text.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
inline (`rubigram.types.Keypad`):
|
|
267
|
+
The new inline keyboard to attach to the message.
|
|
268
|
+
Contains rows of interactive buttons.
|
|
269
|
+
|
|
270
|
+
Example:
|
|
271
|
+
.. code-block:: python
|
|
272
|
+
from rubigram.types import Keypad, KeypadRow, Button
|
|
273
|
+
|
|
274
|
+
inline_keypad = Keypad(rows=[
|
|
275
|
+
KeypadRow(buttons=[
|
|
276
|
+
Button(button_text="Like", id="like_btn"),
|
|
277
|
+
Button(button_text="Share", id="share_btn")
|
|
278
|
+
])
|
|
279
|
+
])
|
|
280
|
+
|
|
281
|
+
updated_message = await message.edit_inline(inline=inline_keypad)
|
|
282
|
+
|
|
283
|
+
Note:
|
|
284
|
+
This method only affects the inline keyboard of this specific message,
|
|
285
|
+
not the chat's main keypad.
|
|
286
|
+
"""
|
|
287
|
+
return await self.client.edit_message_keypad(
|
|
288
|
+
self.chat_id,
|
|
289
|
+
self.message_id,
|
|
290
|
+
inline
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
async def forward(
|
|
294
|
+
self,
|
|
295
|
+
chat_id: str,
|
|
296
|
+
disable_notification: bool = False,
|
|
297
|
+
auto_delete: Optional[int] = None
|
|
298
|
+
) -> UMessage:
|
|
299
|
+
"""
|
|
300
|
+
**Forward this message to another chat.**
|
|
301
|
+
|
|
302
|
+
Forwards this message to the specified target chat while preserving
|
|
303
|
+
all message content, attachments, and metadata.
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
chat_id (`str`):
|
|
307
|
+
The target chat ID to forward the message to.
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
UMessage: The forwarded message object in the target chat.
|
|
311
|
+
|
|
312
|
+
Example:
|
|
313
|
+
.. code-block:: python
|
|
314
|
+
message = await client.send_message(
|
|
315
|
+
chat_id=chat_id,
|
|
316
|
+
text=text
|
|
317
|
+
)
|
|
318
|
+
await message.forward(chat_id=chat_id)
|
|
319
|
+
"""
|
|
320
|
+
return await self.client.forward_message(
|
|
321
|
+
self.chat_id,
|
|
322
|
+
self.message_id,
|
|
323
|
+
chat_id,
|
|
324
|
+
disable_notification,
|
|
325
|
+
auto_delete
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
async def download(
|
|
329
|
+
self,
|
|
330
|
+
file_name: Optional[str] = None,
|
|
331
|
+
directory: Optional[str] = None,
|
|
332
|
+
chunk_size: int = 64 * 1024,
|
|
333
|
+
in_memory: bool = False,
|
|
334
|
+
) -> Union[str, BytesIO]:
|
|
335
|
+
return await self.client.download_file(
|
|
336
|
+
self.file_id,
|
|
337
|
+
file_name,
|
|
338
|
+
directory,
|
|
339
|
+
chunk_size,
|
|
340
|
+
in_memory
|
|
341
|
+
)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from ..config import Object
|
|
11
|
+
import rubigram
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class Metadata(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents metadata for messages or files.**
|
|
18
|
+
`from rubigram.types import MetaData`
|
|
19
|
+
|
|
20
|
+
This class contains metadata information that can be attached to
|
|
21
|
+
messages or files, typically used for additional context or
|
|
22
|
+
structured data.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
meta_data_parts (`Optional[list[rubigram.types.MetadataParts]]`):
|
|
26
|
+
List of metadata parts containing key-value pairs or
|
|
27
|
+
structured data components.
|
|
28
|
+
"""
|
|
29
|
+
meta_data_parts: Optional[list[rubigram.types.MetadataParts]] = None
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def parse(cls, data: dict, client=None):
|
|
33
|
+
"""
|
|
34
|
+
Parse dict into a MetaData object.
|
|
35
|
+
"""
|
|
36
|
+
data = data or {}
|
|
37
|
+
parts = [
|
|
38
|
+
rubigram.types.MetadataParts.parse(part, client)
|
|
39
|
+
if isinstance(part, dict)
|
|
40
|
+
else part
|
|
41
|
+
for part in data.get("meta_data_parts", []) or []
|
|
42
|
+
]
|
|
43
|
+
return cls(meta_data_parts=parts)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from typing import Optional, Union
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from ..config import Object
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class MetadataParts(Object):
|
|
15
|
+
"""
|
|
16
|
+
**Represents a part of metadata with specific attributes.**
|
|
17
|
+
`from rubigram.types import MetaDataParts`
|
|
18
|
+
|
|
19
|
+
This class defines individual components of metadata that can be
|
|
20
|
+
used to annotate messages with links, mentions, or other structured data.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
from_index (`Optional[int]`):
|
|
24
|
+
The starting index position in the text where this metadata applies.
|
|
25
|
+
|
|
26
|
+
length (`Optional[int]`):
|
|
27
|
+
The length of the text segment this metadata applies to.
|
|
28
|
+
|
|
29
|
+
type (`Optional[str]`):
|
|
30
|
+
The type of metadata (e.g., "link", "mention", "hashtag").
|
|
31
|
+
|
|
32
|
+
link_url (`Optional[str]`):
|
|
33
|
+
The URL for link-type metadata.
|
|
34
|
+
|
|
35
|
+
mention_text_user_id (`Optional[str]`):
|
|
36
|
+
The user ID for mention-type metadata.
|
|
37
|
+
"""
|
|
38
|
+
from_index: int
|
|
39
|
+
length: int
|
|
40
|
+
type: Union[str] = None
|
|
41
|
+
link_url: Optional[str] = None
|
|
42
|
+
mention_text_user_id: Optional[str] = None
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from .config import Object
|
|
11
|
+
import rubigram
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class PaymentStatus(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents the payment status of a transaction in Rubigram.**
|
|
18
|
+
`from rubigram.types import PaymentStatus`
|
|
19
|
+
|
|
20
|
+
Tracks the unique payment ID and the current status of the payment.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
payment_id (`Optional[str]`):
|
|
24
|
+
Unique identifier for the payment.
|
|
25
|
+
|
|
26
|
+
status (`Optional[Union[str, rubigram.enums.PaymentStatusType]]`):
|
|
27
|
+
Current status of the payment, either as a string or as an enum (Paid, NotPaid).
|
|
28
|
+
"""
|
|
29
|
+
payment_id: Optional[str] = None
|
|
30
|
+
status: Optional[Union[str, rubigram.enums.PaymentStatusType]] = None
|