RubigramClient 1.6.7__py3-none-any.whl → 1.6.8__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/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from .client import Client
2
+ from .rubino import Rubino
2
3
  from .state import StateManager
3
4
  from . import enums
4
5
  from . import filters
rubigram/enums.py CHANGED
@@ -126,4 +126,12 @@ class FileType(str, Enum):
126
126
  Video = "Video"
127
127
  Gif = "Gif"
128
128
  Music = "Music"
129
- Voice = "Voice"
129
+ Voice = "Voice"
130
+
131
+
132
+ class ChatAction(str, Enum):
133
+ Typing = "Typing"
134
+ Uploading = "Uploading"
135
+ Recording = "Recording"
136
+
137
+
rubigram/method.py CHANGED
@@ -49,6 +49,21 @@ class Method(Network):
49
49
 
50
50
  async def edit_message_text(self, chat_id: str, message_id: str, text: str):
51
51
  await self.request("editMessageText", {"chat_id": chat_id, "message_id": message_id, "text": text})
52
+
53
+ async def edit_message(
54
+ self,
55
+ chat_id: str,
56
+ message_id: str,
57
+ text: Optional[str] = None,
58
+ chat_keypad: Optional[Keypad] = None,
59
+ inline_keypad: Optional[Keypad] = None
60
+ ):
61
+ if text:
62
+ await self.edit_message_text(chat_id, message_id, text)
63
+ if chat_keypad:
64
+ await self.edit_chat_keypad(chat_id, chat_keypad)
65
+ if inline_keypad:
66
+ await self.edit_message_keypad(chat_id, message_id, inline_keypad)
52
67
 
53
68
  async def forward_message(self, from_chat_id: str, message_id: str, to_chat_id: str, disable_notification: bool = False) -> "MessageId":
54
69
  data = {"from_chat_id": from_chat_id, "message_id": message_id, "to_chat_id": to_chat_id, "disable_notification": disable_notification}
@@ -255,4 +270,40 @@ class Method(Network):
255
270
  return await self.send_file(chat_id, music, caption, file_name, "Music", **kwargs)
256
271
 
257
272
  async def send_voice(self, chat_id: str, voice: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
258
- return await self.send_file(chat_id, voice, caption, file_name, "Voice", **kwargs)
273
+ return await self.send_file(chat_id, voice, caption, file_name, "Voice", **kwargs)
274
+
275
+ # async def get_messages(self, chat_id: str, message_ids: Optional[list[str]] = None):
276
+ # return await self.request("getMessages", {"chat_id": chat_id, "message_ids": message_ids})
277
+
278
+ # async def get_bot_command(self):
279
+ # return await self.request("getBotCommands", {})
280
+
281
+ # async def send_chat_action(self, chat_id: str, action: enums.ChatAction):
282
+ # return await self.request("sendChatAction", {"chat_id": chat_id, "action": action})
283
+
284
+ # async def set_username(self, username: str):
285
+ # return await self.request("setUsername", {"username": username})
286
+
287
+ async def get_bot_name(self):
288
+ bot = await self.get_me()
289
+ return bot.bot_title
290
+
291
+ async def get_bot_id(self):
292
+ bot = await self.get_me()
293
+ return bot.bot_id
294
+
295
+ async def get_bot_username(self):
296
+ bot = await self.get_me()
297
+ return bot.username
298
+
299
+ async def get_bot_share_url(self):
300
+ bot = await self.get_me()
301
+ return bot.share_url
302
+
303
+ async def get_bot_descriptionl(self):
304
+ bot = await self.get_me()
305
+ return bot.description
306
+
307
+ async def get_bot_start_messagel(self):
308
+ bot = await self.get_me()
309
+ return bot.start_message
rubigram/network.py CHANGED
@@ -2,6 +2,7 @@ from aiohttp import ClientSession, FormData
2
2
  from typing import Any, Optional, Union
3
3
  from pathlib import Path
4
4
  from urllib.parse import urlparse
5
+ from random import randint
5
6
  import aiofiles
6
7
  import os
7
8
 
@@ -64,7 +65,7 @@ class Network:
64
65
  data, filename = file, name
65
66
  else:
66
67
  raise Exception("choice name for bytes file")
67
-
68
+
68
69
  form = FormData()
69
70
  form.add_field("file", data, filename=filename, content_type="application/octet-stream")
70
71
  await self.start()
@@ -0,0 +1 @@
1
+ from .client import Rubino
@@ -0,0 +1,82 @@
1
+ from aiohttp import ClientSession
2
+ from typing import Literal, Optional, Union, Any
3
+ from random import randint
4
+
5
+
6
+ class Rubino:
7
+ def __init__(self, auth: str):
8
+ self.auth = auth
9
+ self.api = f"https://rubino{randint(1, 30)}.iranlms.ir"
10
+ self.client = {
11
+ "app_name": "Main",
12
+ "app_version": "3.0.2",
13
+ "lang_code": "fa",
14
+ "package": "app.rbmain.a",
15
+ "platform": "Android"
16
+ }
17
+
18
+
19
+ async def reauest(self, method: str, data: dict[str, Any]):
20
+ json = {
21
+ "api_version": "0",
22
+ "auth": self.auth,
23
+ "client": self.client,
24
+ "data": data,
25
+ "method": method
26
+ }
27
+ async with ClientSession() as session:
28
+ async with session.post(self.api, json=json) as response:
29
+ response.raise_for_status()
30
+ return await response.json()
31
+
32
+
33
+ async def get_post_by_share_link(self, post_link: str):
34
+ return await self.reauest("getPostByShareLink", {"share_string": post_link.split("/")[-1]})
35
+
36
+
37
+ async def add_post_view_count(self, post_id: str, post_profile_id: str):
38
+ data = {"post_id": post_id, "post_profile_id": post_profile_id}
39
+ return await self.reauest("addPostViewCount", data)
40
+
41
+
42
+ async def add_view_story(self, story_profile_id: str, story_ids: Union[str, list[str]], profile_id: Optional[str] = None):
43
+ story_ids = story_ids if isinstance(story_ids, list) else [story_ids]
44
+ data = {"story_profile_id": story_profile_id, "story_ids": story_ids, "profile_id": profile_id}
45
+ return await self.reauest("addViewStory", data)
46
+
47
+
48
+ async def is_exist_username(self, username: str):
49
+ username = username.replace("@", "")
50
+ return await self.reauest("isExistUsername", {"username": username})
51
+
52
+
53
+ async def create_page(self, username: str, name: str, bio: Optional[str] = None):
54
+ return await self.reauest("createPage", {"username": username, "name": name, "bio": bio})
55
+
56
+
57
+ async def add_comment(self, content: str, post_id: str, post_profile_id: str, profile_id: Optional[str] = None):
58
+ rnd = randint(100000, 999999999)
59
+ data = {"content": content, "post_id": post_id, "post_profile_id": post_profile_id, "profile_id": profile_id, "rnd": rnd}
60
+ return await self.reauest("addComment", data)
61
+
62
+
63
+ async def request_follow(self, followee_id: str, f_type: Literal["Follow", "Unfollow"] = "Follow", profile_id: Optional[str] = None):
64
+ data = {"f_type": f_type, "followee_id": followee_id, "profile_id": profile_id}
65
+ return self.reauest("requestFollow", data)
66
+
67
+
68
+ async def set_block_profile(self, block_id: str, action: Literal["Block", "Unblock"] = "Block", profile_id: Optional[str] = None):
69
+ data = {"block_id": block_id, "action": action, "profile_id": profile_id}
70
+ return self.reauest("setBlockProfile", data)
71
+
72
+
73
+ async def get_comments(self, post_id: str, post_profile_id: str, limit: Optional[int] = 100, profile_id: Optional[str] = None):
74
+ data = {
75
+ "post_id": post_id,
76
+ "post_profile_id": post_profile_id,
77
+ "limit": limit,
78
+ "profile_id": profile_id,
79
+ "equal": False,
80
+ "sort": "FromMax"
81
+ }
82
+ return await self.reauest("getComments", data)
rubigram/types.py CHANGED
@@ -731,12 +731,23 @@ class MessageId(DataManager):
731
731
 
732
732
  async def delete(self):
733
733
  return await self.client.delete_message(self.chat_id, self.message_id)
734
+
735
+ async def edit(self, text: Optional[str] = None, inline: Optional[Keypad] = None, keypad: Optional[Keypad] = None):
736
+ if text:
737
+ await self.edit_text(text)
738
+ if inline:
739
+ await self.edit_inline(inline)
740
+ if keypad:
741
+ await self.edit_keypad(keypad)
734
742
 
735
743
  async def edit_text(self, text: str):
736
744
  return await self.client.edit_message_text(self.chat_id, self.message_id, text)
737
745
 
738
- async def edit_message_keypad(self, keypad: Keypad):
739
- return await self.client.edit_message_keypad(self.chat_id, self.message_id, keypad)
746
+ async def edit_inline(self, inline: Keypad):
747
+ return await self.client.edit_message_keypad(self.chat_id, self.message_id, inline)
748
+
749
+ async def edit_keypad(self, keypad: Keypad):
750
+ return await self.client.edit_chat_keypad(self.chat_id, keypad)
740
751
 
741
752
  async def forward(self, chat_id: str):
742
753
  return await self.client.forward_message(self.chat_id, self.message_id, chat_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RubigramClient
3
- Version: 1.6.7
3
+ Version: 1.6.8
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
6
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,15 @@
1
+ rubigram/__init__.py,sha256=yyPILotyVazCcf1qrKEu_67yYsvLGns2oJlSfLmvhd8,152
2
+ rubigram/client.py,sha256=Pg50Za2idur97ZgphmXgQvu0n0N63oPE04sqhujgNk0,5940
3
+ rubigram/enums.py,sha256=oQf7TYe8zoQRJlE2iFIpAZlbvjlZSFoFjuO-4tIi7sc,2853
4
+ rubigram/filters.py,sha256=40znxAC7xAFYCeERlPYLSVtr0lxUcnQY2HRwt1zSfdk,6838
5
+ rubigram/method.py,sha256=VTk3czoRgcjHOipWGFGYtksS_jxlDdlmksrCT5zgWZE,13310
6
+ rubigram/network.py,sha256=XrNTfWKL_ZZEEIsPrAwy4YzWw_n1DPrtZFF_UeqTNzM,2882
7
+ rubigram/state.py,sha256=_g13o87MHfuudbgvbfu9vAOrSzw4GhdEYkD6dSn7t2s,997
8
+ rubigram/types.py,sha256=v0HV4jaI89wvqaNbPUJzqUtOelMCC74LVoCUidGu6mc,29760
9
+ rubigram/rubino/__init__.py,sha256=6-ztB6rLeIB3SV4tbVPPUxmNqHQUYQhDee6bnNQdECw,26
10
+ rubigram/rubino/client.py,sha256=3Z4lAItC0IKsp0vlRdUE_dhEw-IFolSZ2Aukg7Qeieg,3479
11
+ rubigramclient-1.6.8.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ rubigramclient-1.6.8.dist-info/METADATA,sha256=eKkcfCVKDRjcyZAJ3WVHuSTkkRqPDEJAA_m54NI96e8,2655
13
+ rubigramclient-1.6.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ rubigramclient-1.6.8.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
15
+ rubigramclient-1.6.8.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- rubigram/__init__.py,sha256=h2O7aVl3woDBTHX0MdZLbhgvVRTyXA0NTzOz7F8Y7Xg,124
2
- rubigram/client.py,sha256=Pg50Za2idur97ZgphmXgQvu0n0N63oPE04sqhujgNk0,5940
3
- rubigram/enums.py,sha256=UZKH1wROBVMuHVEjrnQSwpi-y2MxMI7zl2uThdPTWoc,2722
4
- rubigram/filters.py,sha256=40znxAC7xAFYCeERlPYLSVtr0lxUcnQY2HRwt1zSfdk,6838
5
- rubigram/method.py,sha256=T_JpN6pF-xjRaw__If48H-63tzjFM8VZaUCTqd4vL2I,11501
6
- rubigram/network.py,sha256=v_JQpVMrHUwDk5oBXgjIBmLGYtyDxUPu7Qvqvk2XUy0,2862
7
- rubigram/state.py,sha256=_g13o87MHfuudbgvbfu9vAOrSzw4GhdEYkD6dSn7t2s,997
8
- rubigram/types.py,sha256=MrggHVI62icQpVhVASXI7UV5pav-HuHB6wwVzyg9P90,29326
9
- rubigramclient-1.6.7.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- rubigramclient-1.6.7.dist-info/METADATA,sha256=RMfK7tSH7TDK1c2h5a_CocA5PVh5ogX8MPxZKtomGI4,2655
11
- rubigramclient-1.6.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- rubigramclient-1.6.7.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
13
- rubigramclient-1.6.7.dist-info/RECORD,,