RubigramClient 1.4.4__py3-none-any.whl → 1.4.5__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.
Potentially problematic release.
This version of RubigramClient might be problematic. Click here for more details.
- rubigram/client.py +5 -1
- rubigram/network.py +15 -26
- {rubigramclient-1.4.4.dist-info → rubigramclient-1.4.5.dist-info}/METADATA +1 -1
- rubigramclient-1.4.5.dist-info/RECORD +11 -0
- rubigramclient-1.4.4.dist-info/RECORD +0 -11
- {rubigramclient-1.4.4.dist-info → rubigramclient-1.4.5.dist-info}/WHEEL +0 -0
- {rubigramclient-1.4.4.dist-info → rubigramclient-1.4.5.dist-info}/licenses/LICENSE +0 -0
- {rubigramclient-1.4.4.dist-info → rubigramclient-1.4.5.dist-info}/top_level.txt +0 -0
rubigram/client.py
CHANGED
|
@@ -136,6 +136,9 @@ class Client(Method):
|
|
|
136
136
|
|
|
137
137
|
now = int(datetime.now().timestamp())
|
|
138
138
|
if message_time >= now or message_time + 2 >= now:
|
|
139
|
+
print(update)
|
|
140
|
+
if isinstance(update, Update):
|
|
141
|
+
update.client = self
|
|
139
142
|
await self.dispatch_update(update)
|
|
140
143
|
|
|
141
144
|
self.offset_id = get_update.next_offset_id
|
|
@@ -143,4 +146,5 @@ class Client(Method):
|
|
|
143
146
|
logger.exception(f"Polling error: {e}")
|
|
144
147
|
await asyncio.sleep(1)
|
|
145
148
|
|
|
146
|
-
asyncio.run(polling())
|
|
149
|
+
try:asyncio.run(polling())
|
|
150
|
+
except:pass
|
rubigram/network.py
CHANGED
|
@@ -10,47 +10,36 @@ class Network:
|
|
|
10
10
|
self.token: str = token
|
|
11
11
|
self.session: Optional[ClientSession] = None
|
|
12
12
|
self.api: str = f"https://botapi.rubika.ir/v3/{self.token}/"
|
|
13
|
-
|
|
14
|
-
async def get_session(self) -> ClientSession:
|
|
15
|
-
if self.session is None or self.session.closed:
|
|
16
|
-
self.session = ClientSession()
|
|
17
|
-
return self.session
|
|
18
|
-
|
|
19
|
-
async def close(self) -> None:
|
|
20
|
-
if self.session and not self.session.closed:
|
|
21
|
-
await self.session.close()
|
|
13
|
+
|
|
22
14
|
|
|
23
15
|
async def request(self, method: str, json: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
async with ClientSession() as session:
|
|
17
|
+
async with session.post(self.api + method, json=json) as response:
|
|
18
|
+
response.raise_for_status()
|
|
19
|
+
data: dict = await response.json()
|
|
20
|
+
return data.get("data")
|
|
29
21
|
|
|
30
22
|
async def request_bytes_file(self, url: str) -> bytes:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
async with ClientSession() as session:
|
|
24
|
+
async with session.get(url) as response:
|
|
25
|
+
response.raise_for_status()
|
|
26
|
+
return await response.read()
|
|
35
27
|
|
|
36
28
|
async def request_upload_file(self, upload_url: str, file: Union[str], name: str) -> str:
|
|
37
|
-
session = await self.get_session()
|
|
38
|
-
|
|
39
29
|
if isinstance(file, str) and re.match(r"^https?://", file):
|
|
40
30
|
file = await self.request_bytes_file(file)
|
|
41
|
-
|
|
42
31
|
elif isinstance(file, str) and os.path.isfile(file):
|
|
43
32
|
async with aiofiles.open(file, "rb") as f:
|
|
44
33
|
file = await f.read()
|
|
45
34
|
|
|
46
35
|
form = FormData()
|
|
47
36
|
form.add_field("file", file, filename=name, content_type="application/octet-stream")
|
|
37
|
+
async with ClientSession() as session:
|
|
38
|
+
async with session.post(upload_url, data=form) as response:
|
|
39
|
+
response.raise_for_status()
|
|
40
|
+
data = await response.json()
|
|
41
|
+
return data["data"]["file_id"]
|
|
48
42
|
|
|
49
|
-
async with session.post(upload_url, data=form) as response:
|
|
50
|
-
response.raise_for_status()
|
|
51
|
-
data = await response.json()
|
|
52
|
-
return data["data"]["file_id"]
|
|
53
|
-
|
|
54
43
|
async def request_download_file(self, url: str, name: str) -> dict[str, Union[str, bool]]:
|
|
55
44
|
file = await self.request_bytes_file(url)
|
|
56
45
|
async with aiofiles.open(name, "wb") as f:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.5
|
|
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
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
rubigram/__init__.py,sha256=Z0foTm6Hpy4CDEH5am-IFWifi0bo4jLvpkfj3JQQHPc,107
|
|
2
|
+
rubigram/client.py,sha256=92rSDmCsVKabWpFuoJhUw7jVSjVc0YkvR135E_z4MwI,6293
|
|
3
|
+
rubigram/filters.py,sha256=KTuhAtcfKVgRfXGUy5vlUOFDbFwnW70B0WpnAyfJ4pg,5422
|
|
4
|
+
rubigram/method.py,sha256=OnV4O3jLvA453qFxv8dLjX7Vd-XL5goZFnuM-BrjWZM,9920
|
|
5
|
+
rubigram/network.py,sha256=BbHXfLxA8-GqTbZBWfJ3A_F8PYVSRydWKIOEC1J2gO8,2024
|
|
6
|
+
rubigram/types.py,sha256=cQGbLlbVXIQfa8J8EcP2laRtZN6NX6rb3tlX4lsGIZc,13567
|
|
7
|
+
rubigramclient-1.4.5.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
rubigramclient-1.4.5.dist-info/METADATA,sha256=keyi6xvQpZH9eM7v550COlxwHVGpLxMQeE3Lhk7z6XI,2035
|
|
9
|
+
rubigramclient-1.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
rubigramclient-1.4.5.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
|
|
11
|
+
rubigramclient-1.4.5.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
rubigram/__init__.py,sha256=Z0foTm6Hpy4CDEH5am-IFWifi0bo4jLvpkfj3JQQHPc,107
|
|
2
|
-
rubigram/client.py,sha256=GqTECi0_rVHV5ZPF-GSL577bT5EEG6RWJqYg8BC1chY,6083
|
|
3
|
-
rubigram/filters.py,sha256=KTuhAtcfKVgRfXGUy5vlUOFDbFwnW70B0WpnAyfJ4pg,5422
|
|
4
|
-
rubigram/method.py,sha256=OnV4O3jLvA453qFxv8dLjX7Vd-XL5goZFnuM-BrjWZM,9920
|
|
5
|
-
rubigram/network.py,sha256=B5y_n7CC7wdMkzNqKpUG9cC7Cq86R0QJCwcScExluvM,2299
|
|
6
|
-
rubigram/types.py,sha256=cQGbLlbVXIQfa8J8EcP2laRtZN6NX6rb3tlX4lsGIZc,13567
|
|
7
|
-
rubigramclient-1.4.4.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
rubigramclient-1.4.4.dist-info/METADATA,sha256=kjJRn7E5MkoHCuQbhAraadUZRmevESMK0cDyB1qnob8,2035
|
|
9
|
-
rubigramclient-1.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
rubigramclient-1.4.4.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
|
|
11
|
-
rubigramclient-1.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|