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.
Files changed (132) hide show
  1. rubigram/__init__.py +15 -0
  2. rubigram/client.py +294 -0
  3. rubigram/enums/__init__.py +52 -0
  4. rubigram/enums/buttons/__init__.py +13 -0
  5. rubigram/enums/buttons/button_calendar_type.py +20 -0
  6. rubigram/enums/buttons/button_location_type.py +20 -0
  7. rubigram/enums/buttons/button_selection_get_type.py +20 -0
  8. rubigram/enums/buttons/button_selection_search_type.py +20 -0
  9. rubigram/enums/buttons/button_selection_type.py +22 -0
  10. rubigram/enums/buttons/button_textbox_type_keypad.py +20 -0
  11. rubigram/enums/buttons/button_textbox_type_line.py +20 -0
  12. rubigram/enums/buttons/button_type.py +58 -0
  13. rubigram/enums/chat_action_type.py +22 -0
  14. rubigram/enums/chat_keypad_type.py +20 -0
  15. rubigram/enums/chat_type.py +24 -0
  16. rubigram/enums/enum.py +6 -0
  17. rubigram/enums/file_type.py +28 -0
  18. rubigram/enums/forwarded_from_type.py +22 -0
  19. rubigram/enums/live_location_status.py +20 -0
  20. rubigram/enums/message_sender_type.py +20 -0
  21. rubigram/enums/metadata_type.py +18 -0
  22. rubigram/enums/parse_mode.py +20 -0
  23. rubigram/enums/payment_status_type.py +20 -0
  24. rubigram/enums/poll_status_type.py +20 -0
  25. rubigram/enums/update_endpoint_type.py +26 -0
  26. rubigram/enums/update_type.py +28 -0
  27. rubigram/errors.py +16 -0
  28. rubigram/filters.py +865 -0
  29. rubigram/http_session.py +96 -0
  30. rubigram/methods/__init__.py +26 -0
  31. rubigram/methods/chats/__init__.py +10 -0
  32. rubigram/methods/chats/get_chat.py +53 -0
  33. rubigram/methods/decorators/__init__.py +25 -0
  34. rubigram/methods/decorators/on_inline_message.py +70 -0
  35. rubigram/methods/decorators/on_message.py +62 -0
  36. rubigram/methods/decorators/on_remove_message.py +65 -0
  37. rubigram/methods/decorators/on_start.py +65 -0
  38. rubigram/methods/decorators/on_started_bot.py +70 -0
  39. rubigram/methods/decorators/on_stop.py +65 -0
  40. rubigram/methods/decorators/on_stopped_bot.py +70 -0
  41. rubigram/methods/decorators/on_update_message.py +70 -0
  42. rubigram/methods/files/__init__.py +32 -0
  43. rubigram/methods/files/download_file.py +118 -0
  44. rubigram/methods/files/get_file.py +41 -0
  45. rubigram/methods/files/get_file_name.py +41 -0
  46. rubigram/methods/files/request_send_file.py +49 -0
  47. rubigram/methods/files/send_file.py +133 -0
  48. rubigram/methods/files/send_gif.py +51 -0
  49. rubigram/methods/files/send_music.py +97 -0
  50. rubigram/methods/files/send_photo.py +95 -0
  51. rubigram/methods/files/send_video.py +96 -0
  52. rubigram/methods/files/send_voice.py +96 -0
  53. rubigram/methods/files/upload_file.py +114 -0
  54. rubigram/methods/messages/__init__.py +34 -0
  55. rubigram/methods/messages/delete_messages.py +84 -0
  56. rubigram/methods/messages/edit_chat_keypad.py +68 -0
  57. rubigram/methods/messages/edit_message.py +82 -0
  58. rubigram/methods/messages/edit_message_keypad.py +72 -0
  59. rubigram/methods/messages/edit_message_text.py +68 -0
  60. rubigram/methods/messages/forward_message.py +78 -0
  61. rubigram/methods/messages/remove_chat_keypad.py +46 -0
  62. rubigram/methods/messages/send_contact.py +114 -0
  63. rubigram/methods/messages/send_location.py +108 -0
  64. rubigram/methods/messages/send_message.py +115 -0
  65. rubigram/methods/messages/send_poll.py +104 -0
  66. rubigram/methods/messages/send_sticker.py +98 -0
  67. rubigram/methods/network/__init__.py +12 -0
  68. rubigram/methods/network/request.py +129 -0
  69. rubigram/methods/settings/__init__.py +16 -0
  70. rubigram/methods/settings/set_command.py +50 -0
  71. rubigram/methods/settings/setup_endpoints.py +48 -0
  72. rubigram/methods/settings/update_bot_endpoint.py +62 -0
  73. rubigram/methods/updates/__init__.py +14 -0
  74. rubigram/methods/updates/get_me.py +35 -0
  75. rubigram/methods/updates/get_update.py +62 -0
  76. rubigram/methods/utilities/__init__.py +14 -0
  77. rubigram/methods/utilities/dispatcher.py +66 -0
  78. rubigram/methods/utilities/run.py +118 -0
  79. rubigram/rubino/__init__.py +6 -0
  80. rubigram/rubino/client.py +374 -0
  81. rubigram/rubino/network.py +129 -0
  82. rubigram/server/__init__.py +6 -0
  83. rubigram/server/server.py +245 -0
  84. rubigram/state/__init__.py +7 -0
  85. rubigram/state/state.py +121 -0
  86. rubigram/state/storage.py +131 -0
  87. rubigram/types/__init__.py +66 -0
  88. rubigram/types/aux_data.py +28 -0
  89. rubigram/types/bot.py +51 -0
  90. rubigram/types/bot_command.py +26 -0
  91. rubigram/types/buttons/__init__.py +13 -0
  92. rubigram/types/buttons/button.py +59 -0
  93. rubigram/types/buttons/button_calendar.py +40 -0
  94. rubigram/types/buttons/button_location.py +40 -0
  95. rubigram/types/buttons/button_number_picker.py +34 -0
  96. rubigram/types/buttons/button_selection.py +48 -0
  97. rubigram/types/buttons/button_selection_item.py +32 -0
  98. rubigram/types/buttons/button_string_picker.py +29 -0
  99. rubigram/types/buttons/button_text_box.py +40 -0
  100. rubigram/types/chat.py +86 -0
  101. rubigram/types/config/__init__.py +6 -0
  102. rubigram/types/config/object.py +442 -0
  103. rubigram/types/contact_message.py +29 -0
  104. rubigram/types/file.py +78 -0
  105. rubigram/types/forwarded_from.py +39 -0
  106. rubigram/types/keypads/__init__.py +7 -0
  107. rubigram/types/keypads/keypad.py +31 -0
  108. rubigram/types/keypads/keypad_row.py +23 -0
  109. rubigram/types/live_location.py +44 -0
  110. rubigram/types/location.py +24 -0
  111. rubigram/types/messages/__init__.py +8 -0
  112. rubigram/types/messages/inline_message.py +78 -0
  113. rubigram/types/messages/message.py +117 -0
  114. rubigram/types/messages/update_message.py +341 -0
  115. rubigram/types/metadata/__init__.py +7 -0
  116. rubigram/types/metadata/metadata.py +43 -0
  117. rubigram/types/metadata/metadata_parts.py +42 -0
  118. rubigram/types/payment_status.py +30 -0
  119. rubigram/types/poll.py +32 -0
  120. rubigram/types/poll_status.py +40 -0
  121. rubigram/types/sticker.py +33 -0
  122. rubigram/types/updates/__init__.py +7 -0
  123. rubigram/types/updates/update.py +917 -0
  124. rubigram/types/updates/updates.py +56 -0
  125. rubigram/utils/__init__.py +14 -0
  126. rubigram/utils/auto_delete.py +93 -0
  127. rubigram/utils/parser.py +99 -0
  128. rubigramclient-1.7.17.dist-info/METADATA +215 -0
  129. rubigramclient-1.7.17.dist-info/RECORD +132 -0
  130. rubigramclient-1.7.17.dist-info/WHEEL +5 -0
  131. rubigramclient-1.7.17.dist-info/licenses/LICENSE +21 -0
  132. rubigramclient-1.7.17.dist-info/top_level.txt +1 -0
@@ -0,0 +1,104 @@
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 rubigram.utils import AutoDelete
10
+ import rubigram
11
+
12
+
13
+ class SendPoll:
14
+ async def send_poll(
15
+ self: rubigram.Client,
16
+ chat_id: str,
17
+ question: str,
18
+ options: list[str],
19
+ chat_keypad: Optional[rubigram.types.Keypad] = None,
20
+ inline_keypad: Optional[rubigram.types.Keypad] = None,
21
+ chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
22
+ disable_notification: bool = False,
23
+ reply_to_message_id: Optional[str] = None,
24
+ auto_delete: Optional[int] = None
25
+ ) -> rubigram.types.UMessage:
26
+ """
27
+ **Send a poll to a chat.**
28
+ `await client.send_poll(chat_id, question, options)`
29
+
30
+ This method sends an interactive poll to the specified chat.
31
+ Users can vote on the provided options and see real-time results.
32
+
33
+ Args:
34
+ chat_id (`str`):
35
+ The ID of the chat where the poll will be sent.
36
+
37
+ question (`str`):
38
+ The poll question text.
39
+
40
+ options (`list[str]`):
41
+ List of answer options for the poll (minimum 2 options).
42
+
43
+ chat_keypad (`Optional[rubigram.types.Keypad]`):
44
+ Custom keyboard to show in the chat. Defaults to None.
45
+
46
+ inline_keypad (`Optional[rubigram.types.Keypad]`):
47
+ Inline keyboard to attach below the poll. Defaults to None.
48
+
49
+ chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
50
+ Type of chat keypad (New, Remove). Defaults to None.
51
+
52
+ disable_notification (`Optional[bool]`):
53
+ If True, disables notification for the poll. Defaults to False.
54
+
55
+ reply_to_message_id (`Optional[str]`):
56
+ ID of the message to reply to. Defaults to None.
57
+
58
+ auto_delete (`Optional[int]`):
59
+ If set, the message will be automatically deleted after the specified number of seconds.
60
+
61
+ Returns:
62
+ rubigram.types.UMessage: The sent poll message object with client binding.
63
+
64
+ Example:
65
+ .. code-block:: python
66
+
67
+ # Send a poll with multiple options
68
+ await client.send_poll(
69
+ chat_id=chat_id,
70
+ question="What's your favorite programming language?",
71
+ options=["Python", "JavaScript", "Java", "C++"],
72
+ disable_notification=True
73
+ )
74
+
75
+ Note:
76
+ - Polls must have at least 2 options
77
+ - Users can only vote once per poll
78
+ - Poll results are visible to all participants in real-time
79
+ """
80
+ data = {
81
+ "chat_id": chat_id,
82
+ "question": question,
83
+ "options": options
84
+ }
85
+
86
+ if chat_keypad:
87
+ data["chat_keypad"] = chat_keypad.as_dict()
88
+ if inline_keypad:
89
+ data["inline_keypad"] = inline_keypad.as_dict()
90
+ if chat_keypad_type:
91
+ data["chat_keypad_type"] = chat_keypad_type
92
+ if disable_notification:
93
+ data["disable_notification"] = disable_notification
94
+ if reply_to_message_id:
95
+ data["reply_to_message_id"] = reply_to_message_id
96
+
97
+ response = await self.request("sendPoll", data)
98
+ message = rubigram.types.UMessage.parse(response, self)
99
+ message.chat_id = chat_id
100
+
101
+ if auto_delete and auto_delete > 0:
102
+ AutoDelete.run(self, message, auto_delete)
103
+
104
+ return message
@@ -0,0 +1,98 @@
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 rubigram.utils import AutoDelete
10
+ import rubigram
11
+
12
+
13
+ class SendSticker:
14
+ async def send_sticker(
15
+ self: rubigram.Client,
16
+ chat_id: str,
17
+ sticker_id: str,
18
+ chat_keypad: Optional[rubigram.types.Keypad] = None,
19
+ inline_keypad: Optional[rubigram.types.Keypad] = None,
20
+ chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
21
+ disable_notification: bool = False,
22
+ reply_to_message_id: Optional[str] = None,
23
+ auto_delete: Optional[int] = None
24
+ ) -> rubigram.types.UMessage:
25
+ """
26
+ **Send a sticker to a chat.**
27
+ `await client.send_sticker(chat_id, sticker_id)`
28
+
29
+ This method sends a sticker to the specified chat using its unique identifier.
30
+ Stickers are graphical elements that can express emotions, reactions, or concepts.
31
+
32
+ Args:
33
+ chat_id (`str`):
34
+ The ID of the chat where the sticker will be sent.
35
+
36
+ sticker_id (`str`):
37
+ The unique identifier of the sticker to send.
38
+
39
+ chat_keypad (`Optional[rubigram.types.Keypad]`):
40
+ Custom keyboard to show in the chat. Defaults to None.
41
+
42
+ inline_keypad (`Optional[rubigram.types.Keypad]`):
43
+ Inline keyboard to attach below the sticker. Defaults to None.
44
+
45
+ chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
46
+ Type of chat keypad (New, Remove). Defaults to None.
47
+
48
+ disable_notification (`Optional[bool]`):
49
+ If True, disables notification for the sticker. Defaults to False.
50
+
51
+ reply_to_message_id (`Optional[str]`):
52
+ ID of the message to reply to. Defaults to None.
53
+
54
+ auto_delete (`Optional[int]`):
55
+ If set, the message will be automatically deleted after the specified number of seconds.
56
+
57
+ Returns:
58
+ rubigram.types.UMessage: The sent sticker message object with client binding.
59
+
60
+ Example:
61
+ .. code-block:: python
62
+
63
+ # Send a sticker to a chat
64
+ await client.send_sticker(
65
+ chat_id=chat_id,
66
+ sticker_id=sticker_id,
67
+ disable_notification=True
68
+ )
69
+
70
+ Note:
71
+ - Sticker IDs are unique identifiers for each sticker in Rubigram's sticker pack
72
+ - Stickers are displayed as large, animated or static images
73
+ - Users can tap on stickers to see them in full size
74
+ """
75
+ data = {
76
+ "chat_id": chat_id,
77
+ "sticker_id": sticker_id
78
+ }
79
+
80
+ if chat_keypad:
81
+ data["chat_keypad"] = chat_keypad.as_dict()
82
+ if inline_keypad:
83
+ data["inline_keypad"] = inline_keypad.as_dict()
84
+ if chat_keypad_type:
85
+ data["chat_keypad_type"] = chat_keypad_type
86
+ if disable_notification:
87
+ data["disable_notification"] = disable_notification
88
+ if reply_to_message_id:
89
+ data["reply_to_message_id"] = reply_to_message_id
90
+
91
+ response = await self.request("sendSticker", data)
92
+ message = rubigram.types.UMessage.parse(response, self)
93
+ message.chat_id = chat_id
94
+
95
+ if auto_delete and auto_delete > 0:
96
+ AutoDelete.run(self, message, auto_delete)
97
+
98
+ return message
@@ -0,0 +1,12 @@
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 .request import Request
7
+
8
+
9
+ class Network(
10
+ Request
11
+ ):
12
+ pass
@@ -0,0 +1,129 @@
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 aiohttp import ClientError
10
+ import asyncio
11
+ import rubigram
12
+ import logging
13
+
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ class Request:
19
+ """
20
+ HTTP request handler with retry logic for Rubika API.
21
+
22
+ This class provides an asynchronous method to send POST requests
23
+ to the Rubika Bot API with configurable retries, delays, backoff,
24
+ and optional proxy support. It handles HTTP errors and validates
25
+ the API response, raising appropriate exceptions if the request
26
+ fails.
27
+ """
28
+
29
+ __slots__ = ()
30
+
31
+ async def request(
32
+ self: rubigram.Client,
33
+ endpoint: str,
34
+ payload: dict,
35
+ *,
36
+ headers: Optional[dict] = None,
37
+ proxy: Optional[str] = None,
38
+ retries: Optional[int] = None,
39
+ delay: Optional[float] = None,
40
+ backoff: Optional[float] = None,
41
+ max_delay: float = 5.0
42
+ ) -> dict:
43
+ """
44
+ Send an HTTP request to the specified endpoint with the
45
+ provided JSON payload.
46
+
47
+ Parameters:
48
+ endpoint (str):
49
+ API endpoint name (e.g., "sendMessage").
50
+ payload (dict):
51
+ JSON-serializable data to send in the request body.
52
+ headers (Optional[dict], default=None):
53
+ Custom HTTP headers.
54
+ proxy (Optional[str], default=None):
55
+ Proxy URL for the request. Uses client's proxy if None.
56
+ retries (Optional[int], default=None):
57
+ Number of retry attempts. Uses client's default if None.
58
+ delay (Optional[float], default=None):
59
+ Initial delay between retries in seconds.
60
+ backoff (Optional[float], default=None):
61
+ Multiplier to increase delay after each retry.
62
+ max_delay (float, default=5.0):
63
+ Maximum delay allowed between retries.
64
+
65
+ Returns:
66
+ dict: The "data" field from the API response if status is "OK".
67
+
68
+ Raises:
69
+ rubigram.errors.InvalidInput:
70
+ If the API response status is "INVALID_INPUT".
71
+ rubigram.errors.InvalidInput:
72
+ If the API response status is not "INVALID_ACCESS".
73
+ aiohttp.ClientError:
74
+ For network or HTTP errors.
75
+ RuntimeError:
76
+ If maximum retries are exceeded.
77
+
78
+ Example:
79
+ .. code-block:: python
80
+ # Assuming `client` is an instance of Rubigram.Client
81
+ response = await client.request(
82
+ endpoint="sendMessage",
83
+ payload={"chat_id": "chat_id", "text": "text"},
84
+ retries=5,
85
+ delay=1.0,
86
+ backoff=2.0
87
+ )
88
+ """
89
+ proxy = self.proxy if proxy is None else proxy
90
+ retries = self.retries if retries is None else retries
91
+ delay = self.delay if delay is None else delay
92
+ backoff = self.backoff if backoff is None else backoff
93
+ max_delay = self.max_delay if max_delay is None else max_delay
94
+
95
+ last_error = None
96
+
97
+ for attempt in range(1, retries + 1):
98
+ try:
99
+ async with self.http.session.post(
100
+ self.api + endpoint,
101
+ json=payload,
102
+ headers=headers,
103
+ proxy=proxy
104
+ ) as response:
105
+ response.raise_for_status()
106
+ data: dict = await response.json()
107
+
108
+ if data.get("status") == "OK":
109
+ logger.debug(data.get("data"))
110
+ return data.get("data")
111
+
112
+ if data.get("status") == "INVALID_INPUT":
113
+ raise rubigram.errors.InvalidInput(data)
114
+
115
+ elif data.get("status") == "INVALID_ACCESS":
116
+ raise rubigram.errors.InvalidAccess(data)
117
+
118
+ else:
119
+ raise Exception(str(data))
120
+
121
+ except ClientError as error:
122
+ last_error = error
123
+ if attempt == retries:
124
+ raise error
125
+
126
+ await asyncio.sleep(min(delay, max_delay))
127
+ delay *= backoff
128
+
129
+ raise last_error or RuntimeError("Max retries exceeded")
@@ -0,0 +1,16 @@
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 .set_command import SetCommands
7
+ from .setup_endpoints import SetupEndpoints
8
+ from .update_bot_endpoint import UpdateBotEndpoints
9
+
10
+
11
+ class Settings(
12
+ SetCommands,
13
+ SetupEndpoints,
14
+ UpdateBotEndpoints
15
+ ):
16
+ pass
@@ -0,0 +1,50 @@
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
+ import rubigram
7
+
8
+
9
+ class SetCommands:
10
+ async def set_commands(
11
+ self: "rubigram.Client",
12
+ commands: list["rubigram.types.BotCommand"]
13
+ ) -> dict:
14
+ """
15
+ **Set bot commands for the Rubigram bot.**
16
+ `await client.set_commands(commands)`
17
+
18
+ This method registers a list of bot commands that will be displayed
19
+ in the chat interface and accessible to users through the bot menu.
20
+
21
+ Args:
22
+ commands (`list[rubigram.types.BotCommand]`):
23
+ List of BotCommand objects to register for the bot.
24
+
25
+ Returns:
26
+ dict: The API response from Rubigram.
27
+
28
+ Example:
29
+ .. code-block:: python
30
+
31
+ from rubigram.types import BotCommand
32
+
33
+ # Define bot commands
34
+ commands = [
35
+ BotCommand(command="start", description="Start the bot"),
36
+ BotCommand(command="help", description="Get help"),
37
+ BotCommand(command="settings", description="Change settings")
38
+ ]
39
+
40
+ # Register commands with Rubigram
41
+ result = await client.set_commands(commands)
42
+
43
+ Note:
44
+ - Commands will appear in the bot's menu in user chats
45
+ - Each command should have a unique command string
46
+ - Descriptions should be clear and concise for users
47
+ """
48
+ data = {"bot_commands": [command.as_dict() for command in commands]}
49
+ response = await self.request("setCommands", data)
50
+ return response
@@ -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
+ import rubigram
7
+ import logging
8
+
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ class SetupEndpoints:
14
+ async def setup_endpoints(self: "rubigram.Client"):
15
+ """
16
+ **Set up webhook endpoints for all update types.**
17
+ `await client.setup_endpoints()`
18
+
19
+ This method automatically configures webhook endpoints for all
20
+ available update types in Rubigram. Each endpoint type will be
21
+ registered with the base webhook URL followed by the endpoint type.
22
+
23
+ Example:
24
+ .. code-block:: python
25
+
26
+ # Set up all webhook endpoints
27
+ await client.setup_endpoints()
28
+
29
+ # Example of configured endpoints:
30
+ # - https://api.example.com/webhook/ReceiveUpdate
31
+ # - https://api.example.com/webhook/ReceiveInlineMessage
32
+ # - https://api.example.com/webhook/ReceiveQuery
33
+ # - https://api.example.com/webhook/GetSelectionItem
34
+ # - https://api.example.com/webhook/SearchSelectionItems
35
+
36
+ Note:
37
+ - Requires `webhook_url` to be set in the client instance
38
+ - Configures endpoints for all UpdateEndpointType enum values
39
+ - Logs the status of each endpoint setup operation
40
+ - Each endpoint type gets its own unique URL path
41
+ """
42
+ for i in rubigram.enums.UpdateEndpointType:
43
+ type = i.value
44
+ url = f"{self.webhook}/{type}"
45
+ set_endpoint = await self.update_bot_endpoints(url, type)
46
+ logger.info(
47
+ "ENDPOINT SET(type=%s, status=%s)", type, set_endpoint["status"]
48
+ )
@@ -0,0 +1,62 @@
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 Union
7
+ import rubigram
8
+
9
+
10
+ class UpdateBotEndpoints:
11
+ async def update_bot_endpoints(
12
+ self: "rubigram.Client",
13
+ url: str,
14
+ type: Union[str, "rubigram.enums.UpdateEndpointType"] = "ReceiveUpdate"
15
+ ) -> dict:
16
+ """
17
+ **Update webhook endpoints for receiving bot updates.**
18
+ `await client.update_bot_endpoints(url, type)`
19
+
20
+ This method sets or updates the webhook URL where Rubigram will send
21
+ bot updates. Different endpoint types can be configured for various
22
+ types of interactions.
23
+
24
+ Args:
25
+ url (`str`):
26
+ The webhook URL where updates will be sent.
27
+
28
+ type (`Optional[Union[str, rubigram.enums.UpdateEndpointType]]`):
29
+ The type of endpoint to update. Defaults to "ReceiveUpdate".
30
+ Available types:
31
+ - "ReceiveUpdate": General updates
32
+ - "ReceiveInlineMessage": Inline message updates
33
+ - "ReceiveQuery": Callback query updates
34
+ - "GetSelectionItem": Selection item retrieval
35
+ - "SearchSelectionItems": Selection item search
36
+
37
+ Returns:
38
+ dict: The API response from Rubigram.
39
+
40
+ Example:
41
+ .. code-block:: python
42
+
43
+ # Set webhook for general updates
44
+ result = await client.update_bot_endpoints(
45
+ url="https://api.example.com/webhook",
46
+ type="ReceiveUpdate"
47
+ )
48
+
49
+ # Set webhook for inline messages
50
+ from rubigram.enums import UpdateEndpointType
51
+ result = await client.update_bot_endpoints(
52
+ url="https://api.example.com/inline",
53
+ type=UpdateEndpointType.ReceiveInlineMessage
54
+ )
55
+
56
+ Note:
57
+ - The URL must be HTTPS for security reasons
58
+ - Each endpoint type requires a separate configuration
59
+ - Make sure your webhook server can handle POST requests with JSON payloads
60
+ """
61
+ response = await self.request("updateBotEndpoints", {"url": url, "type": type})
62
+ return response
@@ -0,0 +1,14 @@
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 .get_update import GetUpdates
7
+ from .get_me import GetMe
8
+
9
+
10
+ class Updates(
11
+ GetUpdates,
12
+ GetMe
13
+ ):
14
+ pass
@@ -0,0 +1,35 @@
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
+ import rubigram
7
+
8
+
9
+ class GetMe:
10
+ async def get_me(self: "rubigram.Client") -> "rubigram.types.Bot":
11
+ """
12
+ **Get information about the current bot.**
13
+ `await client.get_me()`
14
+
15
+ This method retrieves the current bot's information, including
16
+ the bot's ID, username, and other relevant details.
17
+
18
+ Returns:
19
+ rubigram.types.Bot: A Bot object containing the bot's information.
20
+
21
+ Example:
22
+ .. code-block:: python
23
+
24
+ # Get bot information
25
+ bot = await client.get_me()
26
+ print(f"Bot ID: {bot.bot_id}")
27
+ print(f"Bot username: {bot.username}")
28
+ print(f"Bot title : {bot.bot_title }")
29
+
30
+ Note:
31
+ This method is useful for verifying that the bot token is valid
32
+ and for accessing the bot's own profile information.
33
+ """
34
+ response = await self.request("getMe", None)
35
+ return rubigram.types.Bot(response["bot"])
@@ -0,0 +1,62 @@
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
+ import rubigram
8
+
9
+
10
+ class GetUpdates:
11
+ async def get_updates(
12
+ self: "rubigram.Client",
13
+ limit: Optional[int] = 1,
14
+ offset_id: Optional[str] = None
15
+ ) -> "rubigram.types.Updates":
16
+ """
17
+ **Retrieve incoming updates from Rubigram.**
18
+ `await client.get_updates(limit=10, offset_id="12345")`
19
+
20
+ This method fetches updates (new messages, edits, deletions, etc.)
21
+ from the Rubigram server. It supports pagination through the offset_id
22
+ parameter for efficient update retrieval.
23
+
24
+ Args:
25
+ limit (`Optional[int]`):
26
+ Maximum number of updates to retrieve. Defaults to 1.
27
+
28
+ offset_id (`Optional[str]`):
29
+ ID of the last received update. Updates with higher IDs
30
+ will be returned. Defaults to None.
31
+
32
+ Returns:
33
+ rubigram.types.Updates: A collection of update objects with next_offset_id.
34
+
35
+ Example:
36
+ .. code-block:: python
37
+
38
+ # Get the latest 10 updates
39
+ updates = await client.get_updates(limit=10)
40
+ for update in updates.updates:
41
+ print(f"New update type: {update.type}")
42
+
43
+ # Get updates after a specific ID
44
+ updates = await client.get_updates(
45
+ limit=5,
46
+ offset_id="12345"
47
+ )
48
+ print(f"Next offset: {updates.next_offset_id}")
49
+
50
+ Note:
51
+ - Use the returned next_offset_id for subsequent calls to avoid missing updates
52
+ - Updates are automatically marked as received by the server
53
+ - Consider using a reasonable limit to avoid overwhelming the client
54
+ """
55
+ response = await self.request(
56
+ "getUpdates",
57
+ {
58
+ "limit": limit,
59
+ "offset_id": offset_id
60
+ }
61
+ )
62
+ return rubigram.types.Updates.parse(response)
@@ -0,0 +1,14 @@
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 .dispatcher import Dispatcher
7
+ from .run import Run
8
+
9
+
10
+ class Utilities(
11
+ Run,
12
+ Dispatcher
13
+ ):
14
+ pass