RubigramClient 1.3.1__py3-none-any.whl → 1.3.3__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 CHANGED
@@ -1,4 +1,4 @@
1
- from rubigram.types import Update, MessageId, Keypad, Chat, Bot
1
+ from rubigram.types import Update, MessageId, InlineMessage, Keypad, Chat, Bot
2
2
  from aiohttp import ClientSession, FormData, web
3
3
  from typing import Literal, Optional
4
4
  import aiofiles
@@ -26,7 +26,7 @@ class Client:
26
26
  return decorator
27
27
 
28
28
  async def update(self, data: dict):
29
- event = Update.read(data["update"], self)
29
+ event = Update.read(data["update"], self) if data.get("update") else InlineMessage.read(data["inline_message"])
30
30
  for handler in self.messages_handler:
31
31
  await handler(self, event)
32
32
 
rubigram/filters.py CHANGED
@@ -1,50 +1,58 @@
1
- from rubigram.types import Update
1
+ from rubigram.types import Update, InlineMessage
2
2
  from typing import Union
3
3
 
4
4
 
5
5
  class filter:
6
6
  @staticmethod
7
- def text():
8
- def inner(update: Update):
9
- return update.new_message.text
10
- return inner
11
-
12
- @staticmethod
13
- def private():
7
+ def command(command: Union[str, list[str]], prefixes: Union[str, list[str]] = "/"):
14
8
  def inner(update: Update):
15
- return update.new_message.sender_type == "User"
9
+ if isinstance(update, Update) and update.new_message and update.new_message.text:
10
+ message = update.new_message
11
+ commands = command if isinstance(command, list) else [command]
12
+ commands = [c.lower() for c in commands]
13
+ prefix_list = [] if prefixes is None else prefixes
14
+ prefix_list = prefix_list if isinstance(prefix_list, list) else [prefix_list]
15
+ for prefix in prefix_list:
16
+ if message.text.startswith(prefix) and commands:
17
+ return message.text[len(prefix):].split()[0].lower() in commands
18
+ return False
19
+ return False
16
20
  return inner
17
21
 
18
22
  @staticmethod
19
- def command(cmd: Union[str, list[str]]):
23
+ def text():
20
24
  def inner(update: Update):
21
- if not update.new_message.text:
22
- return False
23
- if not update.new_message.text.startswith("/"):
24
- return False
25
- return update.new_message.text.lstrip("/").split()[0] == cmd
25
+ if isinstance(update, Update) and update.new_message:
26
+ return update.new_message.text is not None
27
+ return False
26
28
  return inner
27
-
29
+
28
30
  @staticmethod
29
- def text_filter(text: str):
31
+ def private():
30
32
  def inner(update: Update):
31
- return update.new_message.text == text if update.new_message.text else False
33
+ if isinstance(update, Update) and update.new_message:
34
+ return update.new_message.sender_type == "User"
35
+ return False
32
36
  return inner
33
37
 
34
38
  @staticmethod
35
39
  def chat(chat_id: str):
36
40
  def inner(update: Update):
37
- return update.chat_id == chat_id
41
+ return getattr(update, "chat_id", None) == chat_id
38
42
  return inner
39
43
 
40
44
  @staticmethod
41
45
  def file():
42
46
  def inner(update: Update):
43
- return update.new_message.file
47
+ if isinstance(update, Update) and update.new_message:
48
+ return update.new_message.file is not None
49
+ return False
44
50
  return inner
45
51
 
46
52
  @staticmethod
47
53
  def button(id: str):
48
- def inner(update: Update):
49
- return update.new_message.aux_data.button_id == id if update.new_message.aux_data else False
54
+ def inner(update: InlineMessage):
55
+ if isinstance(update, InlineMessage):
56
+ return update.aux_data.button_id == id
57
+ return False
50
58
  return inner
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RubigramClient
3
- Version: 1.3.1
3
+ Version: 1.3.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
5
  Author-email: Javad RZ <Javad.Py1385@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -10,7 +10,6 @@ Requires-Python: >=3.7
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: aiohttp>=3.8.0
13
- Requires-Dist: pydantic<3.0,>=2.0
14
13
  Dynamic: license-file
15
14
 
16
15
  # Rubigram
@@ -0,0 +1,9 @@
1
+ rubigram/__init__.py,sha256=K1WXGcBx9-1cLmImtnruqFk91nb_6XuhY_Ud0KS_IUk,55
2
+ rubigram/client.py,sha256=bwt5209q4wcT9nUP67KLWryWF4TWmz1r1PR1lNuM1S8,11591
3
+ rubigram/filters.py,sha256=nvROwHxBdjokWezfAZBjRgBdJdcOcjz0IuR3BShyiJw,2153
4
+ rubigram/types.py,sha256=GIGvTGdDURuwJ3oHPvRR7B8oJ3V1f8MDaMAqjvOOO-0,16813
5
+ rubigramclient-1.3.3.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ rubigramclient-1.3.3.dist-info/METADATA,sha256=JAm-gGFFLj-ea9Br1sx8GhREUYLGx-JO7dBTSbsLxKA,984
7
+ rubigramclient-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ rubigramclient-1.3.3.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
9
+ rubigramclient-1.3.3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- rubigram/__init__.py,sha256=K1WXGcBx9-1cLmImtnruqFk91nb_6XuhY_Ud0KS_IUk,55
2
- rubigram/client.py,sha256=5xaA_HOMQIU5HyEadUdT-WpD9CxGE0wxbwImqQg29Zw,11506
3
- rubigram/filters.py,sha256=HuW_Rscb02TK3Qm7jKVyvy-83FP-plIjTLTccypVniw,1468
4
- rubigram/types.py,sha256=GIGvTGdDURuwJ3oHPvRR7B8oJ3V1f8MDaMAqjvOOO-0,16813
5
- rubigramclient-1.3.1.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- rubigramclient-1.3.1.dist-info/METADATA,sha256=U-bfJY1MaOHP4U81eFcVdPqQyHAocD9uMfEK02DhdBM,1019
7
- rubigramclient-1.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- rubigramclient-1.3.1.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
9
- rubigramclient-1.3.1.dist-info/RECORD,,