RubigramClient 1.6.9__tar.gz → 1.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (24) hide show
  1. rubigramclient-1.7.1/LICENSE +21 -0
  2. {rubigramclient-1.6.9/RubigramClient.egg-info → rubigramclient-1.7.1}/PKG-INFO +58 -5
  3. rubigramclient-1.6.9/PKG-INFO → rubigramclient-1.7.1/README.md +36 -19
  4. rubigramclient-1.7.1/RubigramClient.egg-info/PKG-INFO +159 -0
  5. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/RubigramClient.egg-info/requires.txt +0 -1
  6. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/pyproject.toml +2 -3
  7. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/client.py +37 -1
  8. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/filters.py +8 -6
  9. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/method.py +5 -5
  10. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/network.py +1 -1
  11. rubigramclient-1.7.1/rubigram/rubino/client.py +480 -0
  12. rubigramclient-1.7.1/rubigram/types.py +538 -0
  13. rubigramclient-1.6.9/LICENSE +0 -0
  14. rubigramclient-1.6.9/README.md +0 -90
  15. rubigramclient-1.6.9/rubigram/rubino/client.py +0 -82
  16. rubigramclient-1.6.9/rubigram/types.py +0 -979
  17. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/RubigramClient.egg-info/SOURCES.txt +0 -0
  18. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/RubigramClient.egg-info/dependency_links.txt +0 -0
  19. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/RubigramClient.egg-info/top_level.txt +0 -0
  20. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/__init__.py +0 -0
  21. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/enums.py +0 -0
  22. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/rubino/__init__.py +0 -0
  23. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/rubigram/state.py +0 -0
  24. {rubigramclient-1.6.9 → rubigramclient-1.7.1}/setup.cfg +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Javad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,8 +1,29 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RubigramClient
3
- Version: 1.6.9
3
+ Version: 1.7.1
4
4
  Summary: A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.
5
5
  Author-email: Javad RZ <MrJavad.Email@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Javad
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
6
27
  Classifier: Programming Language :: Python :: 3
7
28
  Classifier: License :: OSI Approved :: MIT License
8
29
  Classifier: Operating System :: OS Independent
@@ -11,18 +32,36 @@ Description-Content-Type: text/markdown
11
32
  License-File: LICENSE
12
33
  Requires-Dist: aiohttp
13
34
  Requires-Dist: aiofiles
14
- Requires-Dist: pydantic
15
35
  Dynamic: license-file
16
36
 
17
37
  # Rubigram
18
38
  A lightweight Python library to build Rubika bots easily.
19
39
 
40
+ <div align="center">
41
+ <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
+ </div>
43
+
44
+
45
+
20
46
  ## Installation
21
47
  ```bash
22
48
  pip install RubigramClient
23
49
  ```
24
50
 
25
- ## Send Message
51
+ ## Quick Example
52
+ ```python
53
+ from rubigram import Client
54
+
55
+ bot = Client(token="YOUR_TOKEN")
56
+
57
+ @bot.on_message()
58
+ async def handler(client, message):
59
+ await message.reply("Hello Rubigram!")
60
+
61
+ bot.run()
62
+ ```
63
+
64
+ ## Reply and Edit message
26
65
  ```python
27
66
  from rubigram import Client, filters
28
67
  from rubigram.types import Update
@@ -30,8 +69,8 @@ from rubigram.types import Update
30
69
  bot = Client(token="YOUR_TOKEN_BOT")
31
70
 
32
71
  @bot.on_message(filters.private)
33
- async def welcome_message(client, message: Update):
34
- send = await message.reply("Hi, WELCOME TO RUBIGRAM")
72
+ async def echo(client, message: Update):
73
+ send = await message.reply(f"Hi, {message.new_message.text}")
35
74
  await send.edit_text("message was edited")
36
75
 
37
76
  bot.run()
@@ -104,3 +143,17 @@ async def main():
104
143
 
105
144
  asyncio.run(main())
106
145
  ```
146
+
147
+ ## Rubino
148
+ ```python
149
+ from rubigram.rubino import Rubino
150
+ import asyncio
151
+
152
+ async def main():
153
+ auth = "YOUR_AUTH_ACCOUNT"
154
+ async with Rubino(auth) as app:
155
+ info = await app.get_my_profile_info()
156
+ print(info)
157
+
158
+ asyncio.run(main())
159
+ ```
@@ -1,28 +1,31 @@
1
- Metadata-Version: 2.4
2
- Name: RubigramClient
3
- Version: 1.6.9
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>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Operating System :: OS Independent
9
- Requires-Python: >=3.7
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: aiohttp
13
- Requires-Dist: aiofiles
14
- Requires-Dist: pydantic
15
- Dynamic: license-file
16
-
17
1
  # Rubigram
18
2
  A lightweight Python library to build Rubika bots easily.
19
3
 
4
+ <div align="center">
5
+ <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
6
+ </div>
7
+
8
+
9
+
20
10
  ## Installation
21
11
  ```bash
22
12
  pip install RubigramClient
23
13
  ```
24
14
 
25
- ## Send Message
15
+ ## Quick Example
16
+ ```python
17
+ from rubigram import Client
18
+
19
+ bot = Client(token="YOUR_TOKEN")
20
+
21
+ @bot.on_message()
22
+ async def handler(client, message):
23
+ await message.reply("Hello Rubigram!")
24
+
25
+ bot.run()
26
+ ```
27
+
28
+ ## Reply and Edit message
26
29
  ```python
27
30
  from rubigram import Client, filters
28
31
  from rubigram.types import Update
@@ -30,8 +33,8 @@ from rubigram.types import Update
30
33
  bot = Client(token="YOUR_TOKEN_BOT")
31
34
 
32
35
  @bot.on_message(filters.private)
33
- async def welcome_message(client, message: Update):
34
- send = await message.reply("Hi, WELCOME TO RUBIGRAM")
36
+ async def echo(client, message: Update):
37
+ send = await message.reply(f"Hi, {message.new_message.text}")
35
38
  await send.edit_text("message was edited")
36
39
 
37
40
  bot.run()
@@ -104,3 +107,17 @@ async def main():
104
107
 
105
108
  asyncio.run(main())
106
109
  ```
110
+
111
+ ## Rubino
112
+ ```python
113
+ from rubigram.rubino import Rubino
114
+ import asyncio
115
+
116
+ async def main():
117
+ auth = "YOUR_AUTH_ACCOUNT"
118
+ async with Rubino(auth) as app:
119
+ info = await app.get_my_profile_info()
120
+ print(info)
121
+
122
+ asyncio.run(main())
123
+ ```
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: RubigramClient
3
+ Version: 1.7.1
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>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Javad
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: License :: OSI Approved :: MIT License
29
+ Classifier: Operating System :: OS Independent
30
+ Requires-Python: >=3.7
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: aiohttp
34
+ Requires-Dist: aiofiles
35
+ Dynamic: license-file
36
+
37
+ # Rubigram
38
+ A lightweight Python library to build Rubika bots easily.
39
+
40
+ <div align="center">
41
+ <img src="http://rubigram.ir/Rubigram.jpg" alt="Rubigram Logo" width="200"/>
42
+ </div>
43
+
44
+
45
+
46
+ ## Installation
47
+ ```bash
48
+ pip install RubigramClient
49
+ ```
50
+
51
+ ## Quick Example
52
+ ```python
53
+ from rubigram import Client
54
+
55
+ bot = Client(token="YOUR_TOKEN")
56
+
57
+ @bot.on_message()
58
+ async def handler(client, message):
59
+ await message.reply("Hello Rubigram!")
60
+
61
+ bot.run()
62
+ ```
63
+
64
+ ## Reply and Edit message
65
+ ```python
66
+ from rubigram import Client, filters
67
+ from rubigram.types import Update
68
+
69
+ bot = Client(token="YOUR_TOKEN_BOT")
70
+
71
+ @bot.on_message(filters.private)
72
+ async def echo(client, message: Update):
73
+ send = await message.reply(f"Hi, {message.new_message.text}")
74
+ await send.edit_text("message was edited")
75
+
76
+ bot.run()
77
+ ```
78
+
79
+ ## Send Message & Get receiveInlineMessage
80
+ ```python
81
+ from rubigram import Client, filters
82
+ from rubigram.types import Update, Button, Keypad, KeypadRow, InlineMessage
83
+
84
+
85
+ bot = Client(token="BOT_TOKEN", endpoint="ENDPOINT_URL")
86
+
87
+
88
+ @bot.on_message(filters.command("start"))
89
+ async def start(_, message: Update):
90
+ inline = Keypad(
91
+ rows=[
92
+ KeypadRow(
93
+ buttons=[
94
+ Button("1", "Button 1"),
95
+ Button("2", "Button 2")
96
+ ]
97
+ )
98
+ ]
99
+ )
100
+ await bot.send_message(message.chat_id, "Hi", inline_keypad=inline)
101
+
102
+
103
+ @bot.on_inline_message(filters.button(["1", "2"]))
104
+ async def button(_, message: InlineMessage):
105
+ if message.aux_data.button_id == "1":
106
+ await bot.send_message(message.chat_id, "You Click Button 1")
107
+ elif message.aux_data.button_id == "2":
108
+ await bot.send_message(message.chat_id, "You Click Button 2")
109
+
110
+ bot.run()
111
+ ```
112
+
113
+ ## Contex Manager
114
+ ```python
115
+ from rubigram import Client
116
+ import asyncio
117
+
118
+ bot = Client("YOUR_BOT_TOKEN")
119
+
120
+ async def main():
121
+ async with bot:
122
+ data = await bot.get_me()
123
+ print(data.bot_id)
124
+
125
+ asyncio.run(main())
126
+ ```
127
+
128
+ ## Implementation of multiple programs
129
+ ```python
130
+ from rubigram import Client
131
+ import asyncio
132
+
133
+ tokens = [
134
+ "TOKEN_1",
135
+ "TOKEN_2"
136
+ ]
137
+
138
+ async def main():
139
+ for token in tokens:
140
+ async with Client(token) as bot:
141
+ get_me = await bot.get_me()
142
+ print(get_me.asjson())
143
+
144
+ asyncio.run(main())
145
+ ```
146
+
147
+ ## Rubino
148
+ ```python
149
+ from rubigram.rubino import Rubino
150
+ import asyncio
151
+
152
+ async def main():
153
+ auth = "YOUR_AUTH_ACCOUNT"
154
+ async with Rubino(auth) as app:
155
+ info = await app.get_my_profile_info()
156
+ print(info)
157
+
158
+ asyncio.run(main())
159
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "RubigramClient"
3
- version = "1.6.9"
3
+ version = "1.7.1"
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"
@@ -15,6 +15,5 @@ classifiers = [
15
15
  ]
16
16
  dependencies = [
17
17
  "aiohttp",
18
- "aiofiles",
19
- "pydantic"
18
+ "aiofiles"
20
19
  ]
@@ -36,6 +36,8 @@ class Client(Method):
36
36
  self.ROUTES = []
37
37
  self.MESSAGE_HANDLER = []
38
38
  self.INLINE_HANDLER = []
39
+ self.EDIT_HANDLER = []
40
+ self.DELETE_HANDLER = []
39
41
  self.state = StateManager()
40
42
  super().__init__(token)
41
43
 
@@ -61,6 +63,28 @@ class Client(Method):
61
63
  self.INLINE_HANDLER.append(wrapper)
62
64
  return func
63
65
  return decorator
66
+
67
+ def on_edit_message(self, filters: Optional[Filter] = None):
68
+ def decorator(func: Callable) -> Callable:
69
+ async def wrapper(client: Client, update: Update):
70
+ if filters is None or await filters(update):
71
+ await func(client, update)
72
+ return True
73
+ return False
74
+ self.EDIT_HANDLER.append(wrapper)
75
+ return func
76
+ return decorator
77
+
78
+ def on_delete_message(self, filters: Optional[Filter] = None):
79
+ def decorator(func: Callable) -> Callable:
80
+ async def wrapper(client: Client, update: Update):
81
+ if filters is None or await filters(update):
82
+ await func(client, update)
83
+ return True
84
+ return False
85
+ self.DELETE_HANDLER.append(wrapper)
86
+ return func
87
+ return decorator
64
88
 
65
89
  def on_create_app(self, path: str, method: str = "GET"):
66
90
  def decorator(func):
@@ -69,7 +93,19 @@ class Client(Method):
69
93
  return decorator
70
94
 
71
95
  async def dispatch(self, update: Union[Update, InlineMessage]):
72
- handlers = self.MESSAGE_HANDLER if isinstance(update, Update) else self.INLINE_HANDLER
96
+ if isinstance(update, InlineMessage):
97
+ handlers = self.INLINE_HANDLER
98
+ else:
99
+ type = update.type
100
+ if type == "NewMessage":
101
+ handlers = self.MESSAGE_HANDLER
102
+ elif type == "UpdatedMessage":
103
+ handlers = self.EDIT_HANDLER
104
+ elif type == "RemovedMessage":
105
+ handlers = self.DELETE_HANDLER
106
+ else:
107
+ logging.warning("Update type invalid : {}".format(type))
108
+
73
109
  for handler in handlers:
74
110
  matched = await handler(self, update)
75
111
  if matched:
@@ -25,7 +25,7 @@ class Filter:
25
25
 
26
26
  async def TEXT(message: Update):
27
27
  if isinstance(message, Update):
28
- return True if message.new_message and message.new_message.text else False
28
+ return True if message.new_message and message.new_message.text or message.updated_message.text else False
29
29
  return False
30
30
 
31
31
  async def FILE(message: Update):
@@ -126,8 +126,12 @@ class command(Filter):
126
126
  super().__init__(self.filter)
127
127
 
128
128
  async def filter(self, update: Update):
129
- if isinstance(update, Update) and update.type == "NewMessage":
130
- text = update.new_message.text or ""
129
+ if isinstance(update, Update):
130
+ if update.new_message:
131
+ text = update.new_message.text
132
+ elif update.updated_message:
133
+ text = update.updated_message.text
134
+ else: return False
131
135
  text = text if self.case_sensitive else text.lower()
132
136
  return any(text.startswith(cmd) for cmd in self.cmds)
133
137
  return False
@@ -163,9 +167,7 @@ class regex(Filter):
163
167
  elif isinstance(update, InlineMessage):
164
168
  text = getattr(update, "text", "")
165
169
 
166
- if text:
167
- return bool(re.search(self.pattern, text))
168
- return False
170
+ return bool(re.search(self.pattern, text)) if text else False
169
171
 
170
172
 
171
173
  class chat(Filter):
@@ -36,19 +36,19 @@ class Method(Network):
36
36
  return response
37
37
 
38
38
  async def delete_message(self, chat_id: str, message_id: str):
39
- await self.request("deleteMessage", {"chat_id": chat_id, "message_id": message_id})
39
+ return await self.request("deleteMessage", {"chat_id": chat_id, "message_id": message_id})
40
40
 
41
41
  async def remove_chat_keypad(self, chat_id: str):
42
- await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "Remove"})
42
+ return await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "Remove"})
43
43
 
44
44
  async def edit_chat_keypad(self, chat_id: str, chat_keypad: Keypad):
45
- await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "New", "chat_keypad": chat_keypad.asdict()})
45
+ return await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "New", "chat_keypad": chat_keypad.asdict()})
46
46
 
47
47
  async def edit_message_keypad(self, chat_id: str, message_id: str, inline_keypad: Keypad):
48
- await self.request("editMessageKeypad", {"chat_id": chat_id, "message_id": message_id, "inline_keypad": inline_keypad.asdict()})
48
+ return await self.request("editMessageKeypad", {"chat_id": chat_id, "message_id": message_id, "inline_keypad": inline_keypad.asdict()})
49
49
 
50
50
  async def edit_message_text(self, chat_id: str, message_id: str, text: str):
51
- await self.request("editMessageText", {"chat_id": chat_id, "message_id": message_id, "text": text})
51
+ return await self.request("editMessageText", {"chat_id": chat_id, "message_id": message_id, "text": text})
52
52
 
53
53
  async def edit_message(
54
54
  self,
@@ -33,7 +33,7 @@ class Network:
33
33
  async with self.session.post(self.api + method, json=json) as response:
34
34
  response.raise_for_status()
35
35
  data: dict = await response.json()
36
- return data.get("data")
36
+ return data.get("data", {})
37
37
 
38
38
  async def getBytes(self, url: str) -> bytes:
39
39
  await self.start()