RubigramClient 1.7.1__tar.gz → 1.7.3__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.

Potentially problematic release.


This version of RubigramClient might be problematic. Click here for more details.

Files changed (84) hide show
  1. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/PKG-INFO +4 -3
  2. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/README.md +1 -1
  3. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/RubigramClient.egg-info/PKG-INFO +4 -3
  4. rubigramclient-1.7.3/RubigramClient.egg-info/SOURCES.txt +74 -0
  5. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/pyproject.toml +5 -3
  6. rubigramclient-1.7.3/rubigram/__init__.py +2 -0
  7. rubigramclient-1.7.3/rubigram/client.py +144 -0
  8. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/rubigram/enums.py +4 -3
  9. rubigramclient-1.7.3/rubigram/filters.py +641 -0
  10. rubigramclient-1.7.3/rubigram/handler.py +24 -0
  11. rubigramclient-1.7.3/rubigram/http.py +32 -0
  12. rubigramclient-1.7.3/rubigram/logger.py +20 -0
  13. rubigramclient-1.7.3/rubigram/method/__init__.py +18 -0
  14. rubigramclient-1.7.3/rubigram/method/chat/__init__.py +10 -0
  15. rubigramclient-1.7.3/rubigram/method/chat/get_chat.py +26 -0
  16. rubigramclient-1.7.3/rubigram/method/chat/get_me.py +22 -0
  17. rubigramclient-1.7.3/rubigram/method/chat/get_update.py +32 -0
  18. rubigramclient-1.7.3/rubigram/method/decorator/__init__.py +19 -0
  19. rubigramclient-1.7.3/rubigram/method/decorator/on_delete_message.py +37 -0
  20. rubigramclient-1.7.3/rubigram/method/decorator/on_edit_message.py +37 -0
  21. rubigramclient-1.7.3/rubigram/method/decorator/on_inline_message.py +40 -0
  22. rubigramclient-1.7.3/rubigram/method/decorator/on_message.py +38 -0
  23. rubigramclient-1.7.3/rubigram/method/decorator/on_start.py +30 -0
  24. rubigramclient-1.7.3/rubigram/method/decorator/on_stop.py +29 -0
  25. rubigramclient-1.7.3/rubigram/method/decorator/register.py +43 -0
  26. rubigramclient-1.7.3/rubigram/method/file/__init__.py +32 -0
  27. rubigramclient-1.7.3/rubigram/method/file/download_file.py +34 -0
  28. rubigramclient-1.7.3/rubigram/method/file/get_bytes.py +25 -0
  29. rubigramclient-1.7.3/rubigram/method/file/get_file.py +27 -0
  30. rubigramclient-1.7.3/rubigram/method/file/get_file_name.py +29 -0
  31. rubigramclient-1.7.3/rubigram/method/file/request_download_file.py +35 -0
  32. rubigramclient-1.7.3/rubigram/method/file/request_send_file.py +28 -0
  33. rubigramclient-1.7.3/rubigram/method/file/request_upload_file.py +62 -0
  34. rubigramclient-1.7.3/rubigram/method/file/send_document.py +58 -0
  35. rubigramclient-1.7.3/rubigram/method/file/send_file.py +78 -0
  36. rubigramclient-1.7.3/rubigram/method/file/send_gif.py +58 -0
  37. rubigramclient-1.7.3/rubigram/method/file/send_music.py +58 -0
  38. rubigramclient-1.7.3/rubigram/method/file/send_photo.py +58 -0
  39. rubigramclient-1.7.3/rubigram/method/file/send_video.py +58 -0
  40. rubigramclient-1.7.3/rubigram/method/file/send_voice.py +55 -0
  41. rubigramclient-1.7.3/rubigram/method/messages/__init__.py +29 -0
  42. rubigramclient-1.7.3/rubigram/method/messages/delete_message.py +50 -0
  43. rubigramclient-1.7.3/rubigram/method/messages/edit_chat_keypad.py +34 -0
  44. rubigramclient-1.7.3/rubigram/method/messages/edit_message.py +41 -0
  45. rubigramclient-1.7.3/rubigram/method/messages/edit_message_keypad.py +38 -0
  46. rubigramclient-1.7.3/rubigram/method/messages/edit_message_text.py +34 -0
  47. rubigramclient-1.7.3/rubigram/method/messages/forward_message.py +43 -0
  48. rubigramclient-1.7.3/rubigram/method/messages/remove_chat_keypad.py +28 -0
  49. rubigramclient-1.7.3/rubigram/method/messages/send_contact.py +74 -0
  50. rubigramclient-1.7.3/rubigram/method/messages/send_location.py +70 -0
  51. rubigramclient-1.7.3/rubigram/method/messages/send_message.py +67 -0
  52. rubigramclient-1.7.3/rubigram/method/messages/send_poll.py +71 -0
  53. rubigramclient-1.7.3/rubigram/method/messages/send_sticker.py +66 -0
  54. rubigramclient-1.7.3/rubigram/method/network/__init__.py +7 -0
  55. rubigramclient-1.7.3/rubigram/method/network/request.py +20 -0
  56. rubigramclient-1.7.3/rubigram/method/setting/__init__.py +9 -0
  57. rubigramclient-1.7.3/rubigram/method/setting/set_command.py +32 -0
  58. rubigramclient-1.7.3/rubigram/method/setting/update_bot_endpoint.py +31 -0
  59. rubigramclient-1.7.3/rubigram/method/utilities/__init__.py +11 -0
  60. rubigramclient-1.7.3/rubigram/method/utilities/dispatch.py +25 -0
  61. rubigramclient-1.7.3/rubigram/method/utilities/setup_endpoint.py +16 -0
  62. rubigramclient-1.7.3/rubigram/method/utilities/updater.py +17 -0
  63. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/rubigram/rubino/client.py +16 -130
  64. rubigramclient-1.7.3/rubigram/rubino/network.py +121 -0
  65. rubigramclient-1.7.3/rubigram/state.py +30 -0
  66. rubigramclient-1.7.3/rubigram/types/__init__.py +3 -0
  67. rubigramclient-1.7.3/rubigram/types/messages.py +175 -0
  68. rubigramclient-1.7.3/rubigram/types/object.py +112 -0
  69. rubigramclient-1.7.3/rubigram/types/types.py +211 -0
  70. rubigramclient-1.7.3/rubigram/types/updates.py +572 -0
  71. rubigramclient-1.7.1/RubigramClient.egg-info/SOURCES.txt +0 -18
  72. rubigramclient-1.7.1/rubigram/__init__.py +0 -6
  73. rubigramclient-1.7.1/rubigram/client.py +0 -196
  74. rubigramclient-1.7.1/rubigram/filters.py +0 -180
  75. rubigramclient-1.7.1/rubigram/method.py +0 -354
  76. rubigramclient-1.7.1/rubigram/network.py +0 -80
  77. rubigramclient-1.7.1/rubigram/state.py +0 -35
  78. rubigramclient-1.7.1/rubigram/types.py +0 -538
  79. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/LICENSE +0 -0
  80. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/RubigramClient.egg-info/dependency_links.txt +0 -0
  81. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/RubigramClient.egg-info/requires.txt +0 -0
  82. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/RubigramClient.egg-info/top_level.txt +0 -0
  83. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/rubigram/rubino/__init__.py +0 -0
  84. {rubigramclient-1.7.1 → rubigramclient-1.7.3}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RubigramClient
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.
5
- Author-email: Javad RZ <MrJavad.Email@gmail.com>
5
+ Author-email: Javad <MrJavad.Email@gmail.com>
6
6
  License: MIT License
7
7
 
8
8
  Copyright (c) 2025 Javad
@@ -24,6 +24,7 @@ License: MIT License
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
+ Project-URL: GitHub, https://github.com/Javad-RZ/rubigram
27
28
  Classifier: Programming Language :: Python :: 3
28
29
  Classifier: License :: OSI Approved :: MIT License
29
30
  Classifier: Operating System :: OS Independent
@@ -38,7 +39,7 @@ Dynamic: license-file
38
39
  A lightweight Python library to build Rubika bots easily.
39
40
 
40
41
  <div align="center">
41
- <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
+ <img src="http://rubigram.ir/rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
43
  </div>
43
44
 
44
45
 
@@ -2,7 +2,7 @@
2
2
  A lightweight Python library to build Rubika bots easily.
3
3
 
4
4
  <div align="center">
5
- <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
5
+ <img src="http://rubigram.ir/rubigram.jpg" alt="Rubigram Logo" width="200"/>
6
6
  </div>
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RubigramClient
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.
5
- Author-email: Javad RZ <MrJavad.Email@gmail.com>
5
+ Author-email: Javad <MrJavad.Email@gmail.com>
6
6
  License: MIT License
7
7
 
8
8
  Copyright (c) 2025 Javad
@@ -24,6 +24,7 @@ License: MIT License
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
+ Project-URL: GitHub, https://github.com/Javad-RZ/rubigram
27
28
  Classifier: Programming Language :: Python :: 3
28
29
  Classifier: License :: OSI Approved :: MIT License
29
30
  Classifier: Operating System :: OS Independent
@@ -38,7 +39,7 @@ Dynamic: license-file
38
39
  A lightweight Python library to build Rubika bots easily.
39
40
 
40
41
  <div align="center">
41
- <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
+ <img src="http://rubigram.ir/rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
43
  </div>
43
44
 
44
45
 
@@ -0,0 +1,74 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ RubigramClient.egg-info/PKG-INFO
5
+ RubigramClient.egg-info/SOURCES.txt
6
+ RubigramClient.egg-info/dependency_links.txt
7
+ RubigramClient.egg-info/requires.txt
8
+ RubigramClient.egg-info/top_level.txt
9
+ rubigram/__init__.py
10
+ rubigram/client.py
11
+ rubigram/enums.py
12
+ rubigram/filters.py
13
+ rubigram/handler.py
14
+ rubigram/http.py
15
+ rubigram/logger.py
16
+ rubigram/state.py
17
+ rubigram/method/__init__.py
18
+ rubigram/method/chat/__init__.py
19
+ rubigram/method/chat/get_chat.py
20
+ rubigram/method/chat/get_me.py
21
+ rubigram/method/chat/get_update.py
22
+ rubigram/method/decorator/__init__.py
23
+ rubigram/method/decorator/on_delete_message.py
24
+ rubigram/method/decorator/on_edit_message.py
25
+ rubigram/method/decorator/on_inline_message.py
26
+ rubigram/method/decorator/on_message.py
27
+ rubigram/method/decorator/on_start.py
28
+ rubigram/method/decorator/on_stop.py
29
+ rubigram/method/decorator/register.py
30
+ rubigram/method/file/__init__.py
31
+ rubigram/method/file/download_file.py
32
+ rubigram/method/file/get_bytes.py
33
+ rubigram/method/file/get_file.py
34
+ rubigram/method/file/get_file_name.py
35
+ rubigram/method/file/request_download_file.py
36
+ rubigram/method/file/request_send_file.py
37
+ rubigram/method/file/request_upload_file.py
38
+ rubigram/method/file/send_document.py
39
+ rubigram/method/file/send_file.py
40
+ rubigram/method/file/send_gif.py
41
+ rubigram/method/file/send_music.py
42
+ rubigram/method/file/send_photo.py
43
+ rubigram/method/file/send_video.py
44
+ rubigram/method/file/send_voice.py
45
+ rubigram/method/messages/__init__.py
46
+ rubigram/method/messages/delete_message.py
47
+ rubigram/method/messages/edit_chat_keypad.py
48
+ rubigram/method/messages/edit_message.py
49
+ rubigram/method/messages/edit_message_keypad.py
50
+ rubigram/method/messages/edit_message_text.py
51
+ rubigram/method/messages/forward_message.py
52
+ rubigram/method/messages/remove_chat_keypad.py
53
+ rubigram/method/messages/send_contact.py
54
+ rubigram/method/messages/send_location.py
55
+ rubigram/method/messages/send_message.py
56
+ rubigram/method/messages/send_poll.py
57
+ rubigram/method/messages/send_sticker.py
58
+ rubigram/method/network/__init__.py
59
+ rubigram/method/network/request.py
60
+ rubigram/method/setting/__init__.py
61
+ rubigram/method/setting/set_command.py
62
+ rubigram/method/setting/update_bot_endpoint.py
63
+ rubigram/method/utilities/__init__.py
64
+ rubigram/method/utilities/dispatch.py
65
+ rubigram/method/utilities/setup_endpoint.py
66
+ rubigram/method/utilities/updater.py
67
+ rubigram/rubino/__init__.py
68
+ rubigram/rubino/client.py
69
+ rubigram/rubino/network.py
70
+ rubigram/types/__init__.py
71
+ rubigram/types/messages.py
72
+ rubigram/types/object.py
73
+ rubigram/types/types.py
74
+ rubigram/types/updates.py
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "RubigramClient"
3
- version = "1.7.1"
3
+ version = "1.7.3"
4
4
  description = "A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.7"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
- { name="Javad RZ", email="MrJavad.Email@gmail.com" }
9
+ { name="Javad", email="MrJavad.Email@gmail.com" }
10
10
  ]
11
11
  classifiers = [
12
12
  "Programming Language :: Python :: 3",
@@ -16,4 +16,6 @@ classifiers = [
16
16
  dependencies = [
17
17
  "aiohttp",
18
18
  "aiofiles"
19
- ]
19
+ ]
20
+
21
+ urls = { "GitHub" = "https://github.com/Javad-RZ/rubigram" }
@@ -0,0 +1,2 @@
1
+ from .client import Client
2
+ from . import enums, types, filters
@@ -0,0 +1,144 @@
1
+ from .method import Method
2
+ from .http import Http
3
+ from .handler import Handler
4
+ from aiohttp.web import Application, Request, json_response, run_app
5
+ from datetime import datetime
6
+ from typing import Optional, Callable
7
+ from .logger import logger
8
+ import asyncio
9
+
10
+
11
+ class Client(Method):
12
+ def __init__(
13
+ self,
14
+ token: str,
15
+ endpoint: Optional[str] = None,
16
+ host: Optional[str] = "0.0.0.0",
17
+ port: Optional[int] = 8000,
18
+ timeout: Optional[float] = 30
19
+ ):
20
+ self.token = token
21
+ self.endpoint = endpoint
22
+ self.host = host
23
+ self.port = port
24
+ self.timeout = timeout
25
+ self.offset_id = None
26
+ self.http: Http = Http(timeout)
27
+ self.set_endpoint = True
28
+ self.handlers: dict[str, list[Handler]] = {
29
+ "message": [],
30
+ "inline": [],
31
+ "delete": [],
32
+ "edit": [],
33
+ }
34
+ self.on_start_app: list[Callable] = []
35
+ self.on_stop_app: list[Callable] = []
36
+ self.routes = []
37
+ super().__init__(self)
38
+
39
+ async def start(self):
40
+ await self.http.connect()
41
+
42
+ async def stop(self):
43
+ await self.http.disconnect()
44
+
45
+ async def __aenter__(self):
46
+ await self.start()
47
+ return self
48
+
49
+ async def __aexit__(self, *args):
50
+ await self.stop()
51
+
52
+ async def run_start_app(self):
53
+ for func in self.on_start_app:
54
+ try:
55
+ await func(self)
56
+ except Exception as error:
57
+ logger.error("[!] On Start App Error : {}".format(error))
58
+
59
+ async def run_stop_app(self):
60
+ for func in self.on_stop_app:
61
+ try:
62
+ await func(self)
63
+ except Exception as error:
64
+ logger.error("[!] On Stop App Error : {}".format(error))
65
+
66
+ async def startup(self, app):
67
+ await self.run_start_app()
68
+ if self.set_endpoint:
69
+ await self.setup_endpoints()
70
+ await self.start()
71
+
72
+ async def cleanup(self, app):
73
+ await self.run_stop_app()
74
+ await self.stop()
75
+
76
+ def request_handler(self):
77
+ async def wrapper(request: Request):
78
+ data = await request.json()
79
+ await self.updater(data)
80
+ return json_response({"status": "OK"})
81
+ return wrapper
82
+
83
+ async def run_polling(self):
84
+ try:
85
+ await self.run_start_app()
86
+ await self.start()
87
+ while True:
88
+ response = await self.get_updates(100, self.offset_id)
89
+ updates = response.updates
90
+
91
+ if updates:
92
+ for update in updates:
93
+ message_time = (
94
+ update.new_message.time
95
+ if update.type == "NewMessage"
96
+ else update.updated_message.time
97
+ if update.type == "UpdatedMessage"
98
+ else None
99
+ )
100
+
101
+ if message_time:
102
+ now = int(datetime.now().timestamp())
103
+ if int(message_time) + 2 >= now:
104
+ update.client = self
105
+ await self.dispatch(update)
106
+
107
+ self.offset_id = response.next_offset_id
108
+
109
+ except Exception as error:
110
+ logger.error("[!] {} : {}".format(__class__.__name__, error))
111
+
112
+ finally:
113
+ await self.run_stop_app()
114
+ await self.stop()
115
+
116
+ def run(
117
+ self,
118
+ set_endpoint: Optional[bool] = True
119
+ ):
120
+ self.set_endpoint = set_endpoint
121
+ if self.endpoint:
122
+ app = Application()
123
+ app.on_startup.append(self.startup)
124
+ app.on_cleanup.append(self.cleanup)
125
+
126
+ app.router.add_post("/ReceiveUpdate", self.request_handler())
127
+ app.router.add_post("/ReceiveInlineMessage", self.request_handler())
128
+
129
+ for path, func, method in self.routes:
130
+ app.router.add_route(method, path, func)
131
+
132
+ logger.info("[<] Start bot on {}:{}".format(self.host, self.port))
133
+ run_app(app, host=self.host, port=self.port)
134
+
135
+ else:
136
+ try:
137
+ logger.info("[<] Start bot ...")
138
+ asyncio.run(self.run_polling())
139
+
140
+ except KeyboardInterrupt:
141
+ logger.info("[<] Stop bot")
142
+
143
+ except Exception as error:
144
+ logger.error("[!] Unexpected error : {}".format(error))
@@ -69,6 +69,7 @@ class ButtonLinkType(str, Enum):
69
69
  joinchannel = "joinchannel"
70
70
  url = "url"
71
71
 
72
+
72
73
  class MessageSender(str, Enum):
73
74
  User = "User"
74
75
  Bot = "Bot"
@@ -94,7 +95,7 @@ class UpdateEndpointType(str, Enum):
94
95
  ReceiveQuery = "ReceiveQuery"
95
96
  GetSelectionItem = "GetSelectionItem"
96
97
  SearchSelectionItems = "SearchSelectionItems"
97
-
98
+
98
99
 
99
100
  class ButtonType(str, Enum):
100
101
  Simple = "Simple"
@@ -118,7 +119,7 @@ class ButtonType(str, Enum):
118
119
  AskMyPhoneNumber = "AskMyPhoneNumber"
119
120
  AskLocation = "AskLocation"
120
121
  Barcode = "Barcode"
121
-
122
+
122
123
 
123
124
  class FileType(str, Enum):
124
125
  File = "File"
@@ -127,7 +128,7 @@ class FileType(str, Enum):
127
128
  Gif = "Gif"
128
129
  Music = "Music"
129
130
  Voice = "Voice"
130
-
131
+
131
132
 
132
133
  class ChatAction(str, Enum):
133
134
  Typing = "Typing"