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,59 @@
|
|
|
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 Button(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a generic interactive button in a chat keypad.**
|
|
18
|
+
`from rubigram.types import Button`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
id (`str`):
|
|
22
|
+
Unique identifier of the button.
|
|
23
|
+
|
|
24
|
+
button_text (`str`):
|
|
25
|
+
Text displayed on the button.
|
|
26
|
+
|
|
27
|
+
type (`Optional[Union[str, rubigram.enums.ButtonType]]`):
|
|
28
|
+
Type of the button.
|
|
29
|
+
|
|
30
|
+
button_selection (`Optional[rubigram.types.ButtonSelection]`):
|
|
31
|
+
Selection-type button.
|
|
32
|
+
|
|
33
|
+
button_calendar (`Optional[rubigram.types.ButtonCalendar]`):
|
|
34
|
+
Calendar-type button.
|
|
35
|
+
|
|
36
|
+
button_number_picker (`Optional[rubigram.types.ButtonNumberPicker]`):
|
|
37
|
+
Number-picker button.
|
|
38
|
+
|
|
39
|
+
button_string_picker (`Optional[rubigram.types.ButtonStringPicker]`):
|
|
40
|
+
String-picker button.
|
|
41
|
+
|
|
42
|
+
button_location (`Optional[rubigram.types.ButtonLocation]`):
|
|
43
|
+
Location picker button.
|
|
44
|
+
|
|
45
|
+
button_textbox (`Optional[rubigram.types.ButtonTextbox]`):
|
|
46
|
+
Textbox input button.
|
|
47
|
+
|
|
48
|
+
button_link (`Optional[rubigram.types.ButtonLink]`):
|
|
49
|
+
Link-type button.
|
|
50
|
+
"""
|
|
51
|
+
id: str
|
|
52
|
+
button_text: str
|
|
53
|
+
type: Optional[Union[str, rubigram.enums.ButtonType]] = rubigram.enums.ButtonType.SIMPLE
|
|
54
|
+
button_selection: Optional[rubigram.types.ButtonSelection] = None
|
|
55
|
+
button_calendar: Optional[rubigram.types.ButtonCalendar] = None
|
|
56
|
+
button_number_picker: Optional[rubigram.types.ButtonNumberPicker] = None
|
|
57
|
+
button_string_picker: Optional[rubigram.types.ButtonStringPicker] = None
|
|
58
|
+
button_location: Optional[rubigram.types.ButtonLocation] = None
|
|
59
|
+
button_textbox: Optional[rubigram.types.ButtonTextbox] = None
|
|
@@ -0,0 +1,40 @@
|
|
|
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 ButtonCalendar(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a calendar picker button.**
|
|
18
|
+
`from rubigram.types import ButtonCalendar`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
default_value (`Optional[str]`):
|
|
22
|
+
The default selected date.
|
|
23
|
+
|
|
24
|
+
type (`Optional[Union[str, rubigram.enums.ButtonCalendarType]]`):
|
|
25
|
+
Type of calendar picker.
|
|
26
|
+
|
|
27
|
+
min_year (`Optional[str]`):
|
|
28
|
+
Minimum selectable year.
|
|
29
|
+
|
|
30
|
+
max_year (`Optional[str]`):
|
|
31
|
+
Maximum selectable year.
|
|
32
|
+
|
|
33
|
+
title (`Optional[str]`):
|
|
34
|
+
Title of the calendar picker.
|
|
35
|
+
"""
|
|
36
|
+
default_value: Optional[str] = None
|
|
37
|
+
type: Optional[Union[str, rubigram.enums.ButtonCalendarType]] = None
|
|
38
|
+
min_year: Optional[str] = None
|
|
39
|
+
max_year: Optional[str] = None
|
|
40
|
+
title: Optional[str] = None
|
|
@@ -0,0 +1,40 @@
|
|
|
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 ButtonLocation(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a location picker button.**
|
|
18
|
+
`from rubigram.types import ButtonLocation`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
default_pointer_location (`Optional[rubigram.types.Location]`):
|
|
22
|
+
Default pointer location.
|
|
23
|
+
|
|
24
|
+
default_map_location (`Optional[rubigram.types.Location]`):
|
|
25
|
+
Default map location.
|
|
26
|
+
|
|
27
|
+
type (`Optional[Union[str, rubigram.enums.ButtonLocationType]]`):
|
|
28
|
+
Type of location picker.
|
|
29
|
+
|
|
30
|
+
title (`Optional[str]`):
|
|
31
|
+
Title of the location picker.
|
|
32
|
+
|
|
33
|
+
location_image_url (`Optional[str]`):
|
|
34
|
+
Optional image URL for the location.
|
|
35
|
+
"""
|
|
36
|
+
default_pointer_location: Optional[rubigram.types.Location] = None
|
|
37
|
+
default_map_location: Optional[rubigram.types.Location] = None
|
|
38
|
+
type: Optional[Union[str, rubigram.enums.ButtonLocationType]] = None
|
|
39
|
+
title: Optional[str] = None
|
|
40
|
+
location_image_url: Optional[str] = None
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from ..config import Object
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class ButtonNumberPicker(Object):
|
|
13
|
+
"""
|
|
14
|
+
**Represents a number picker button.**
|
|
15
|
+
`from rubigram.types import ButtonNumberPicker`
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
min_value (`Optional[str]`):
|
|
19
|
+
Minimum selectable number.
|
|
20
|
+
|
|
21
|
+
max_value (`Optional[str]`):
|
|
22
|
+
Maximum selectable number.
|
|
23
|
+
|
|
24
|
+
default_value (`Optional[str]`):
|
|
25
|
+
Default selected number.
|
|
26
|
+
|
|
27
|
+
title (`Optional[str]`):
|
|
28
|
+
Title of the number picker.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
min_value: Optional[str] = None
|
|
32
|
+
max_value: Optional[str] = None
|
|
33
|
+
default_value: Optional[str] = None
|
|
34
|
+
title: Optional[str] = None
|
|
@@ -0,0 +1,48 @@
|
|
|
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 ButtonSelection(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a selection of multiple items that can be shown in a button.**
|
|
18
|
+
`from rubigram.types import ButtonSelection`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
selection_id (`Optional[str]`):
|
|
22
|
+
Unique identifier for this selection.
|
|
23
|
+
|
|
24
|
+
search_type (`Optional[str]`):
|
|
25
|
+
Type of search to filter items.
|
|
26
|
+
|
|
27
|
+
get_type (`Optional[str]`):
|
|
28
|
+
Type of retrieval for items.
|
|
29
|
+
|
|
30
|
+
items (`Optional[list[rubigram.types.ButtonSelectionItem]]`):
|
|
31
|
+
List of items in the selection.
|
|
32
|
+
|
|
33
|
+
is_multi_selection (`Optional[bool]`):
|
|
34
|
+
Whether multiple items can be selected.
|
|
35
|
+
|
|
36
|
+
columns_count (`Optional[str]`):
|
|
37
|
+
Number of columns to display items in.
|
|
38
|
+
|
|
39
|
+
title (`Optional[str]`):
|
|
40
|
+
Title displayed above the selection.
|
|
41
|
+
"""
|
|
42
|
+
selection_id: Optional[str] = None
|
|
43
|
+
search_type: Optional[str] = None
|
|
44
|
+
get_type: Optional[str] = None
|
|
45
|
+
items: Optional[list[rubigram.types.ButtonSelectionItem]] = None
|
|
46
|
+
is_multi_selection: Optional[bool] = None
|
|
47
|
+
columns_count: Optional[str] = None
|
|
48
|
+
title: Optional[str] = None
|
|
@@ -0,0 +1,32 @@
|
|
|
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 ButtonSelectionItem(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents an individual selectable item in a ButtonSelection.**
|
|
18
|
+
`from rubigram.types import ButtonSelectionItem`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
text (`Optional[str]`):
|
|
22
|
+
The display text of the item.
|
|
23
|
+
|
|
24
|
+
image_url (`Optional[str]`):
|
|
25
|
+
Optional URL for an image representing the item.
|
|
26
|
+
|
|
27
|
+
type (`Optional[Union[str, rubigram.enums.ButtonSelectionType]]`):
|
|
28
|
+
Type of selection item.
|
|
29
|
+
"""
|
|
30
|
+
text: Optional[str] = None
|
|
31
|
+
image_url: Optional[str] = None
|
|
32
|
+
type: Optional[Union[str, rubigram.enums.ButtonSelectionType]] = None
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from ..config import Object
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class ButtonStringPicker(Object):
|
|
13
|
+
"""
|
|
14
|
+
**Represents a string picker button.**
|
|
15
|
+
`from rubigram.types import ButtonStringPicker`
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
items (`Optional[list[str]]`):
|
|
19
|
+
List of string options to select from.
|
|
20
|
+
|
|
21
|
+
default_value (`Optional[str]`):
|
|
22
|
+
Default selected string.
|
|
23
|
+
|
|
24
|
+
title (`Optional[str]`):
|
|
25
|
+
Title of the string picker.
|
|
26
|
+
"""
|
|
27
|
+
items: Optional[list[str]] = None
|
|
28
|
+
default_value: Optional[str] = None
|
|
29
|
+
title: Optional[str] = None
|
|
@@ -0,0 +1,40 @@
|
|
|
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 ButtonTextbox(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a textbox input button.**
|
|
18
|
+
`from rubigram.types import ButtonTextbox`
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
type_line (`Optional[Union[str, rubigram.enums.ButtonTextboxTypeLine]]`):
|
|
22
|
+
Line type for the textbox.
|
|
23
|
+
|
|
24
|
+
type_keypad (`Optional[Union[str, rubigram.enums.ButtonTextboxTypeKeypad]]`):
|
|
25
|
+
Keypad type for the textbox.
|
|
26
|
+
|
|
27
|
+
place_holder (`Optional[str]`):
|
|
28
|
+
Placeholder text.
|
|
29
|
+
|
|
30
|
+
title (`Optional[str]`):
|
|
31
|
+
Title of the textbox.
|
|
32
|
+
|
|
33
|
+
default_value (`Optional[str]`):
|
|
34
|
+
Default text in the textbox.
|
|
35
|
+
"""
|
|
36
|
+
type_line: Optional[Union[str, rubigram.enums.ButtonTextboxTypeLine]] = None
|
|
37
|
+
type_keypad: Optional[Union[str, rubigram.enums.ButtonTextboxTypeKeypad]] = None
|
|
38
|
+
place_holder: Optional[str] = None
|
|
39
|
+
title: Optional[str] = None
|
|
40
|
+
default_value: Optional[str] = None
|
rubigram/types/chat.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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 Chat(Object):
|
|
16
|
+
"""
|
|
17
|
+
**Represents a chat entity in Rubigram.**
|
|
18
|
+
`from rubigram.types import Chat`
|
|
19
|
+
|
|
20
|
+
This object can represent different types of chats such as private, group, or channel.
|
|
21
|
+
It contains identifying and descriptive information about the chat, including user
|
|
22
|
+
details for private chats and titles for groups/channels.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
chat_id (`str`):
|
|
26
|
+
Unique identifier for the chat.
|
|
27
|
+
|
|
28
|
+
chat_type (`rubigram.enums.ChatType`):
|
|
29
|
+
Type of chat (e.g., User, Group, Channel).
|
|
30
|
+
|
|
31
|
+
user_id (`str`):
|
|
32
|
+
The user ID of the chat owner (for private chats).
|
|
33
|
+
|
|
34
|
+
first_name (`Optional[str]`):
|
|
35
|
+
First name of the user (if applicable).
|
|
36
|
+
|
|
37
|
+
last_name (`Optional[str]`):
|
|
38
|
+
Last name of the user (if applicable).
|
|
39
|
+
|
|
40
|
+
title (`Optional[str]`):
|
|
41
|
+
Title of the chat (for groups and channels).
|
|
42
|
+
|
|
43
|
+
username (`Optional[str]`):
|
|
44
|
+
Username of the chat or user (if available).
|
|
45
|
+
|
|
46
|
+
full_name (`Optional[str]`):
|
|
47
|
+
Full name of the user.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
chat_id: str
|
|
51
|
+
chat_type: Union[str, rubigram.enums.ChatType]
|
|
52
|
+
user_id: str
|
|
53
|
+
first_name: Optional[str] = None
|
|
54
|
+
last_name: Optional[str] = None
|
|
55
|
+
title: Optional[str] = None
|
|
56
|
+
username: Optional[str] = None
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def full_name(self) -> str:
|
|
60
|
+
"""
|
|
61
|
+
Return the full name of the user (first + last).
|
|
62
|
+
|
|
63
|
+
Combines `first_name` and `last_name` with a space. If one of them
|
|
64
|
+
is missing, it returns only the available name. Returns an empty
|
|
65
|
+
string if both are None.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
str: Full name of the user.
|
|
69
|
+
"""
|
|
70
|
+
first = self.first_name or ""
|
|
71
|
+
last = self.last_name or ""
|
|
72
|
+
return (first + " " + last).strip()
|
|
73
|
+
|
|
74
|
+
def as_dict(self) -> dict:
|
|
75
|
+
"""
|
|
76
|
+
Convert this Chat object into a dictionary representation.
|
|
77
|
+
|
|
78
|
+
Extends the base Object.as_dict() method to include the `full_name`
|
|
79
|
+
property in the dictionary output.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
dict: Dictionary containing all chat attributes, including `full_name`.
|
|
83
|
+
"""
|
|
84
|
+
data = super().as_dict()
|
|
85
|
+
data["full_name"] = self.full_name
|
|
86
|
+
return data
|