RubigramClient 1.3.2__tar.gz → 1.3.3__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.3.2 → rubigramclient-1.3.3}/PKG-INFO +1 -1
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/RubigramClient.egg-info/PKG-INFO +1 -1
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/pyproject.toml +1 -1
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/rubigram/client.py +2 -2
- rubigramclient-1.3.3/rubigram/filters.py +58 -0
- rubigramclient-1.3.2/rubigram/filters.py +0 -50
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/LICENSE +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/README.md +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/RubigramClient.egg-info/SOURCES.txt +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/RubigramClient.egg-info/dependency_links.txt +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/RubigramClient.egg-info/requires.txt +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/RubigramClient.egg-info/top_level.txt +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/rubigram/__init__.py +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/rubigram/types.py +0 -0
- {rubigramclient-1.3.2 → rubigramclient-1.3.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.3.
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.3.
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "RubigramClient"
|
|
3
|
-
version = "1.3.
|
|
3
|
+
version = "1.3.3"
|
|
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"
|
|
@@ -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
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from rubigram.types import Update, InlineMessage
|
|
2
|
+
from typing import Union
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class filter:
|
|
6
|
+
@staticmethod
|
|
7
|
+
def command(command: Union[str, list[str]], prefixes: Union[str, list[str]] = "/"):
|
|
8
|
+
def inner(update: Update):
|
|
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
|
|
20
|
+
return inner
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def text():
|
|
24
|
+
def inner(update: Update):
|
|
25
|
+
if isinstance(update, Update) and update.new_message:
|
|
26
|
+
return update.new_message.text is not None
|
|
27
|
+
return False
|
|
28
|
+
return inner
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def private():
|
|
32
|
+
def inner(update: Update):
|
|
33
|
+
if isinstance(update, Update) and update.new_message:
|
|
34
|
+
return update.new_message.sender_type == "User"
|
|
35
|
+
return False
|
|
36
|
+
return inner
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def chat(chat_id: str):
|
|
40
|
+
def inner(update: Update):
|
|
41
|
+
return getattr(update, "chat_id", None) == chat_id
|
|
42
|
+
return inner
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def file():
|
|
46
|
+
def inner(update: Update):
|
|
47
|
+
if isinstance(update, Update) and update.new_message:
|
|
48
|
+
return update.new_message.file is not None
|
|
49
|
+
return False
|
|
50
|
+
return inner
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def button(id: str):
|
|
54
|
+
def inner(update: InlineMessage):
|
|
55
|
+
if isinstance(update, InlineMessage):
|
|
56
|
+
return update.aux_data.button_id == id
|
|
57
|
+
return False
|
|
58
|
+
return inner
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from rubigram.types import Update
|
|
2
|
-
from typing import Union
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class filter:
|
|
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():
|
|
14
|
-
def inner(update: Update):
|
|
15
|
-
return update.new_message.sender_type == "User"
|
|
16
|
-
return inner
|
|
17
|
-
|
|
18
|
-
@staticmethod
|
|
19
|
-
def command(cmd: Union[str, list[str]]):
|
|
20
|
-
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
|
|
26
|
-
return inner
|
|
27
|
-
|
|
28
|
-
@staticmethod
|
|
29
|
-
def text_filter(text: str):
|
|
30
|
-
def inner(update: Update):
|
|
31
|
-
return update.new_message.text == text if update.new_message.text else False
|
|
32
|
-
return inner
|
|
33
|
-
|
|
34
|
-
@staticmethod
|
|
35
|
-
def chat(chat_id: str):
|
|
36
|
-
def inner(update: Update):
|
|
37
|
-
return update.chat_id == chat_id
|
|
38
|
-
return inner
|
|
39
|
-
|
|
40
|
-
@staticmethod
|
|
41
|
-
def file():
|
|
42
|
-
def inner(update: Update):
|
|
43
|
-
return update.new_message.file
|
|
44
|
-
return inner
|
|
45
|
-
|
|
46
|
-
@staticmethod
|
|
47
|
-
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
|
|
50
|
-
return inner
|
|
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
|