RubigramClient 1.6.0__tar.gz → 1.6.2__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.
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/PKG-INFO +1 -1
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/RubigramClient.egg-info/PKG-INFO +1 -1
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/pyproject.toml +1 -1
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/client.py +15 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/filters.py +6 -2
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/LICENSE +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/README.md +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/RubigramClient.egg-info/SOURCES.txt +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/RubigramClient.egg-info/dependency_links.txt +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/RubigramClient.egg-info/requires.txt +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/RubigramClient.egg-info/top_level.txt +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/__init__.py +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/method.py +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/models.py +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/network.py +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/rubigram/state.py +0 -0
- {rubigramclient-1.6.0 → rubigramclient-1.6.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
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 <Javad.Py1385@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
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 <Javad.Py1385@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "RubigramClient"
|
|
3
|
-
version = "1.6.
|
|
3
|
+
version = "1.6.2"
|
|
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,6 +7,8 @@ from datetime import datetime
|
|
|
7
7
|
from aiohttp import web
|
|
8
8
|
import asyncio
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
|
|
10
12
|
class Client(Method):
|
|
11
13
|
def __init__(
|
|
12
14
|
self,
|
|
@@ -20,11 +22,13 @@ class Client(Method):
|
|
|
20
22
|
self.host = host
|
|
21
23
|
self.port = port
|
|
22
24
|
self.offset_id = None
|
|
25
|
+
self.ROUTES = []
|
|
23
26
|
self.MESSAGE_HANDLER = []
|
|
24
27
|
self.INLINE_HANDLER = []
|
|
25
28
|
self.state = StateManager()
|
|
26
29
|
super().__init__(token)
|
|
27
30
|
|
|
31
|
+
|
|
28
32
|
def create_handler(self, type: Literal["message", "inline"], filters: Optional[Filter] = None):
|
|
29
33
|
def decorator(func: Callable) -> Callable:
|
|
30
34
|
async def wrapper(client: Client, update: Update):
|
|
@@ -100,11 +104,22 @@ class Client(Method):
|
|
|
100
104
|
await self.state.stop()
|
|
101
105
|
await self.stop()
|
|
102
106
|
|
|
107
|
+
def create_app(self, path: str, method: str = "Get"):
|
|
108
|
+
def decorator(func):
|
|
109
|
+
self.ROUTES.append((path, func, method))
|
|
110
|
+
return func
|
|
111
|
+
return decorator
|
|
112
|
+
|
|
103
113
|
def run(self):
|
|
104
114
|
if self.endpoint:
|
|
105
115
|
app = web.Application()
|
|
106
116
|
app.on_startup(self.on_startup)
|
|
107
117
|
app.on_cleanup(self.on_cleanup)
|
|
118
|
+
for path, func, method in self.ROUTES:
|
|
119
|
+
if method.upper() == "GET":
|
|
120
|
+
app.router.add_get(path, func)
|
|
121
|
+
elif method.upper() == "POST":
|
|
122
|
+
app.router.add_post(path, func)
|
|
108
123
|
app.router.add_post("/ReceiveUpdate", self.create_request_handler())
|
|
109
124
|
app.router.add_post("/ReceiveInlineMessage", self.create_request_handler())
|
|
110
125
|
web.run_app(app, host=self.host, port=self.port)
|
|
@@ -170,11 +170,15 @@ class chat(Filter):
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
class button(Filter):
|
|
173
|
-
def __init__(self, button_id: Union[str, list[str]]):
|
|
173
|
+
def __init__(self, button_id: Union[str, list[str]], prefix: str = ""):
|
|
174
174
|
self.button_id = button_id
|
|
175
|
+
self.prefix = prefix
|
|
175
176
|
super().__init__(self.filter)
|
|
176
177
|
|
|
177
178
|
async def filter(self, update: InlineMessage):
|
|
178
179
|
if isinstance(update, InlineMessage):
|
|
179
180
|
button_ids = self.button_id if isinstance(self.button_id, list) else [self.button_id]
|
|
180
|
-
|
|
181
|
+
for btn_id in button_ids:
|
|
182
|
+
if update.aux_data.button_id.startswith(self.prefix + btn_id):
|
|
183
|
+
return True
|
|
184
|
+
return False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|