RubigramClient 1.6.3__tar.gz → 1.6.5__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.3 → rubigramclient-1.6.5}/PKG-INFO +9 -10
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/README.md +7 -7
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/RubigramClient.egg-info/PKG-INFO +9 -10
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/RubigramClient.egg-info/SOURCES.txt +3 -2
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/RubigramClient.egg-info/requires.txt +0 -1
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/pyproject.toml +3 -5
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/rubigram/__init__.py +3 -2
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/rubigram/client.py +8 -8
- rubigramclient-1.6.5/rubigram/enums.py +129 -0
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/rubigram/filters.py +31 -37
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/rubigram/method.py +52 -32
- rubigramclient-1.6.5/rubigram/state.py +35 -0
- rubigramclient-1.6.3/rubigram/models.py → rubigramclient-1.6.5/rubigram/types.py +301 -206
- rubigramclient-1.6.3/rubigram/state.py +0 -105
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/LICENSE +0 -0
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/RubigramClient.egg-info/dependency_links.txt +0 -0
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/RubigramClient.egg-info/top_level.txt +0 -0
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/rubigram/network.py +0 -0
- {rubigramclient-1.6.3 → rubigramclient-1.6.5}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.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
|
-
Author-email: Javad RZ <
|
|
5
|
+
Author-email: Javad RZ <MrJavad.Email@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
@@ -11,7 +11,6 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: aiohttp
|
|
13
13
|
Requires-Dist: aiofiles
|
|
14
|
-
Requires-Dist: aiosqlite
|
|
15
14
|
Dynamic: license-file
|
|
16
15
|
|
|
17
16
|
# Rubigram
|
|
@@ -25,12 +24,12 @@ pip install RubigramClient
|
|
|
25
24
|
## Send Message
|
|
26
25
|
```python
|
|
27
26
|
from rubigram import Client, filters
|
|
28
|
-
from rubigram.
|
|
27
|
+
from rubigram.types import Update
|
|
29
28
|
|
|
30
|
-
bot = Client("
|
|
29
|
+
bot = Client(token="YOUR_TOKEN_BOT")
|
|
31
30
|
|
|
32
|
-
@bot.on_message(filters.
|
|
33
|
-
async def
|
|
31
|
+
@bot.on_message(filters.private)
|
|
32
|
+
async def welcome_message(client, message: Update):
|
|
34
33
|
await message.reply("Hi, WELCOME TO RUBIGRAM")
|
|
35
34
|
|
|
36
35
|
bot.run()
|
|
@@ -39,10 +38,10 @@ bot.run()
|
|
|
39
38
|
## Send Message & Get receiveInlineMessage
|
|
40
39
|
```python
|
|
41
40
|
from rubigram import Client, filters
|
|
42
|
-
from rubigram.
|
|
41
|
+
from rubigram.types import Update, Button, Keypad, KeypadRow, InlineMessage
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
bot = Client(token="
|
|
44
|
+
bot = Client(token="BOT_TOKEN", endpoint="ENDPOINT_URL")
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
@bot.on_message(filters.command("start"))
|
|
@@ -75,7 +74,7 @@ bot.run()
|
|
|
75
74
|
from rubigram import Client
|
|
76
75
|
import asyncio
|
|
77
76
|
|
|
78
|
-
bot = Client("
|
|
77
|
+
bot = Client("YOUR_BOT_TOKEN")
|
|
79
78
|
|
|
80
79
|
async def main():
|
|
81
80
|
async with bot:
|
|
@@ -9,12 +9,12 @@ pip install RubigramClient
|
|
|
9
9
|
## Send Message
|
|
10
10
|
```python
|
|
11
11
|
from rubigram import Client, filters
|
|
12
|
-
from rubigram.
|
|
12
|
+
from rubigram.types import Update
|
|
13
13
|
|
|
14
|
-
bot = Client("
|
|
14
|
+
bot = Client(token="YOUR_TOKEN_BOT")
|
|
15
15
|
|
|
16
|
-
@bot.on_message(filters.
|
|
17
|
-
async def
|
|
16
|
+
@bot.on_message(filters.private)
|
|
17
|
+
async def welcome_message(client, message: Update):
|
|
18
18
|
await message.reply("Hi, WELCOME TO RUBIGRAM")
|
|
19
19
|
|
|
20
20
|
bot.run()
|
|
@@ -23,10 +23,10 @@ bot.run()
|
|
|
23
23
|
## Send Message & Get receiveInlineMessage
|
|
24
24
|
```python
|
|
25
25
|
from rubigram import Client, filters
|
|
26
|
-
from rubigram.
|
|
26
|
+
from rubigram.types import Update, Button, Keypad, KeypadRow, InlineMessage
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
bot = Client(token="
|
|
29
|
+
bot = Client(token="BOT_TOKEN", endpoint="ENDPOINT_URL")
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
@bot.on_message(filters.command("start"))
|
|
@@ -59,7 +59,7 @@ bot.run()
|
|
|
59
59
|
from rubigram import Client
|
|
60
60
|
import asyncio
|
|
61
61
|
|
|
62
|
-
bot = Client("
|
|
62
|
+
bot = Client("YOUR_BOT_TOKEN")
|
|
63
63
|
|
|
64
64
|
async def main():
|
|
65
65
|
async with bot:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.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
|
-
Author-email: Javad RZ <
|
|
5
|
+
Author-email: Javad RZ <MrJavad.Email@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
@@ -11,7 +11,6 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: aiohttp
|
|
13
13
|
Requires-Dist: aiofiles
|
|
14
|
-
Requires-Dist: aiosqlite
|
|
15
14
|
Dynamic: license-file
|
|
16
15
|
|
|
17
16
|
# Rubigram
|
|
@@ -25,12 +24,12 @@ pip install RubigramClient
|
|
|
25
24
|
## Send Message
|
|
26
25
|
```python
|
|
27
26
|
from rubigram import Client, filters
|
|
28
|
-
from rubigram.
|
|
27
|
+
from rubigram.types import Update
|
|
29
28
|
|
|
30
|
-
bot = Client("
|
|
29
|
+
bot = Client(token="YOUR_TOKEN_BOT")
|
|
31
30
|
|
|
32
|
-
@bot.on_message(filters.
|
|
33
|
-
async def
|
|
31
|
+
@bot.on_message(filters.private)
|
|
32
|
+
async def welcome_message(client, message: Update):
|
|
34
33
|
await message.reply("Hi, WELCOME TO RUBIGRAM")
|
|
35
34
|
|
|
36
35
|
bot.run()
|
|
@@ -39,10 +38,10 @@ bot.run()
|
|
|
39
38
|
## Send Message & Get receiveInlineMessage
|
|
40
39
|
```python
|
|
41
40
|
from rubigram import Client, filters
|
|
42
|
-
from rubigram.
|
|
41
|
+
from rubigram.types import Update, Button, Keypad, KeypadRow, InlineMessage
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
bot = Client(token="
|
|
44
|
+
bot = Client(token="BOT_TOKEN", endpoint="ENDPOINT_URL")
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
@bot.on_message(filters.command("start"))
|
|
@@ -75,7 +74,7 @@ bot.run()
|
|
|
75
74
|
from rubigram import Client
|
|
76
75
|
import asyncio
|
|
77
76
|
|
|
78
|
-
bot = Client("
|
|
77
|
+
bot = Client("YOUR_BOT_TOKEN")
|
|
79
78
|
|
|
80
79
|
async def main():
|
|
81
80
|
async with bot:
|
|
@@ -8,8 +8,9 @@ RubigramClient.egg-info/requires.txt
|
|
|
8
8
|
RubigramClient.egg-info/top_level.txt
|
|
9
9
|
rubigram/__init__.py
|
|
10
10
|
rubigram/client.py
|
|
11
|
+
rubigram/enums.py
|
|
11
12
|
rubigram/filters.py
|
|
12
13
|
rubigram/method.py
|
|
13
|
-
rubigram/models.py
|
|
14
14
|
rubigram/network.py
|
|
15
|
-
rubigram/state.py
|
|
15
|
+
rubigram/state.py
|
|
16
|
+
rubigram/types.py
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "RubigramClient"
|
|
3
|
-
version = "1.6.
|
|
3
|
+
version = "1.6.5"
|
|
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
7
|
license = {file = "LICENSE"}
|
|
8
8
|
authors = [
|
|
9
|
-
{ name="Javad RZ", email="
|
|
9
|
+
{ name="Javad RZ", email="MrJavad.Email@gmail.com" }
|
|
10
10
|
]
|
|
11
11
|
classifiers = [
|
|
12
12
|
"Programming Language :: Python :: 3",
|
|
@@ -15,7 +15,5 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
17
|
"aiohttp",
|
|
18
|
-
"aiofiles",
|
|
19
|
-
"aiosqlite",
|
|
20
|
-
|
|
18
|
+
"aiofiles",
|
|
21
19
|
]
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
from typing import Optional, Callable, Literal, Union
|
|
2
|
-
from rubigram.
|
|
2
|
+
from rubigram.types import Update, InlineMessage
|
|
3
3
|
from rubigram.method import Method
|
|
4
4
|
from rubigram.filters import Filter
|
|
5
5
|
from rubigram.state import StateManager
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from aiohttp import web
|
|
8
8
|
import asyncio
|
|
9
|
+
import logging
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
logging.basicConfig(format=("%(levelname)s | %(message)s"))
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
class Client(Method):
|
|
13
16
|
def __init__(
|
|
@@ -25,7 +28,7 @@ class Client(Method):
|
|
|
25
28
|
self.ROUTES = []
|
|
26
29
|
self.MESSAGE_HANDLER = []
|
|
27
30
|
self.INLINE_HANDLER = []
|
|
28
|
-
|
|
31
|
+
self.state = StateManager()
|
|
29
32
|
super().__init__(token)
|
|
30
33
|
|
|
31
34
|
|
|
@@ -70,11 +73,9 @@ class Client(Method):
|
|
|
70
73
|
|
|
71
74
|
async def on_startup(self, app):
|
|
72
75
|
await self.set_endpoints()
|
|
73
|
-
# await self.state.start()
|
|
74
76
|
await self.start()
|
|
75
77
|
|
|
76
78
|
async def on_cleanup(self, app):
|
|
77
|
-
# await self.state.stop()
|
|
78
79
|
await self.stop()
|
|
79
80
|
|
|
80
81
|
def create_request_handler(self):
|
|
@@ -86,7 +87,6 @@ class Client(Method):
|
|
|
86
87
|
|
|
87
88
|
async def runner(self):
|
|
88
89
|
try:
|
|
89
|
-
# await self.state.start()
|
|
90
90
|
while True:
|
|
91
91
|
get_updates = await self.get_update(100, self.offset_id)
|
|
92
92
|
if get_updates.updates:
|
|
@@ -99,9 +99,8 @@ class Client(Method):
|
|
|
99
99
|
await self.dispatch(update, "message")
|
|
100
100
|
self.offset_id = get_updates.next_offset_id
|
|
101
101
|
except Exception as error:
|
|
102
|
-
|
|
102
|
+
logging.error(error)
|
|
103
103
|
finally:
|
|
104
|
-
# await self.state.stop()
|
|
105
104
|
await self.stop()
|
|
106
105
|
|
|
107
106
|
def create_app(self, path: str, method: str = "Get"):
|
|
@@ -126,5 +125,6 @@ class Client(Method):
|
|
|
126
125
|
else:
|
|
127
126
|
try:
|
|
128
127
|
asyncio.run(self.runner())
|
|
128
|
+
except KeyboardInterrupt:pass
|
|
129
129
|
except Exception as error:
|
|
130
|
-
|
|
130
|
+
logging.error(error)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ChatType(str, Enum):
|
|
5
|
+
User = "User"
|
|
6
|
+
Bot = "Bot"
|
|
7
|
+
Group = "Group"
|
|
8
|
+
Channel = "Channel"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ForwardedFrom(str, Enum):
|
|
12
|
+
User = "User"
|
|
13
|
+
Bot = "Bot"
|
|
14
|
+
Channel = "Channel"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PaymentStatus(str, Enum):
|
|
18
|
+
Paid = "Paid"
|
|
19
|
+
NotPaid = "NotPaid"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PollStatus(str, Enum):
|
|
23
|
+
Open = "Open"
|
|
24
|
+
Closed = "Closed"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class LiveLocationStatus(str, Enum):
|
|
28
|
+
Stopped = "Stopped"
|
|
29
|
+
Live = "Live"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ButtonSelectionType(str, Enum):
|
|
33
|
+
TextOnly = "TextOnly"
|
|
34
|
+
TextImgThu = "TextImgThu"
|
|
35
|
+
TextImgBig = "TextImgBig"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ButtonSelectionSearch(str, Enum):
|
|
39
|
+
Local = "Local"
|
|
40
|
+
Api = "Api"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ButtonSelectionGet(str, Enum):
|
|
44
|
+
Local = "Local"
|
|
45
|
+
Api = "Api"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ButtonCalendarType(str, Enum):
|
|
49
|
+
DatePersian = "DatePersian"
|
|
50
|
+
DateGregorian = "DateGregorian"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ButtonTextboxTypeKeypad(str, Enum):
|
|
54
|
+
String = "String"
|
|
55
|
+
Number = "Number"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ButtonTextboxTypeLine(str, Enum):
|
|
59
|
+
SingleLine = "SingleLine"
|
|
60
|
+
MultiLine = "MultiLine"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ButtonLocationType(str, Enum):
|
|
64
|
+
Picker = "Picker"
|
|
65
|
+
View = "View"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ButtonLinkType(str, Enum):
|
|
69
|
+
joinchannel = "joinchannel"
|
|
70
|
+
url = "url"
|
|
71
|
+
|
|
72
|
+
class MessageSender(str, Enum):
|
|
73
|
+
User = "User"
|
|
74
|
+
Bot = "Bot"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class UpdateType(str, Enum):
|
|
78
|
+
UpdatedMessage = "UpdatedMessage"
|
|
79
|
+
NewMessage = "NewMessage"
|
|
80
|
+
RemovedMessage = "RemovedMessage"
|
|
81
|
+
StartedBot = "StartedBot"
|
|
82
|
+
StoppedBot = "StoppedBot"
|
|
83
|
+
UpdatedPayment = "UpdatedPayment"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ChatKeypadType(str, Enum):
|
|
87
|
+
New = "New"
|
|
88
|
+
Remove = "Remove"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class UpdateEndpointType(str, Enum):
|
|
92
|
+
ReceiveUpdate = "ReceiveUpdate"
|
|
93
|
+
ReceiveInlineMessage = "ReceiveInlineMessage"
|
|
94
|
+
ReceiveQuery = "ReceiveQuery"
|
|
95
|
+
GetSelectionItem = "GetSelectionItem"
|
|
96
|
+
SearchSelectionItems = "SearchSelectionItems"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class ButtonType(str, Enum):
|
|
100
|
+
Simple = "Simple"
|
|
101
|
+
Selection = "Selection"
|
|
102
|
+
Calendar = "Calendar"
|
|
103
|
+
NumberPicker = "NumberPicker"
|
|
104
|
+
StringPicker = "StringPicker"
|
|
105
|
+
Location = "Location"
|
|
106
|
+
Payment = "Payment"
|
|
107
|
+
CameraImage = "CameraImage"
|
|
108
|
+
CameraVideo = "CameraVideo"
|
|
109
|
+
GalleryImage = "GalleryImage"
|
|
110
|
+
GalleryVideo = "GalleryVideo"
|
|
111
|
+
File = "File"
|
|
112
|
+
Audio = "Audio"
|
|
113
|
+
RecordAudio = "RecordAudio"
|
|
114
|
+
MyPhoneNumber = "MyPhoneNumber"
|
|
115
|
+
MyLocation = "MyLocation"
|
|
116
|
+
Textbox = "Textbox"
|
|
117
|
+
Link = "Link"
|
|
118
|
+
AskMyPhoneNumber = "AskMyPhoneNumber"
|
|
119
|
+
AskLocation = "AskLocation"
|
|
120
|
+
Barcode = "Barcode"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class FileType(str, Enum):
|
|
124
|
+
File = "File"
|
|
125
|
+
Image = "Image"
|
|
126
|
+
Video = "Video"
|
|
127
|
+
Gif = "Gif"
|
|
128
|
+
Music = "Music"
|
|
129
|
+
Voice = "Voice"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from rubigram.
|
|
1
|
+
from rubigram.types import Update, InlineMessage
|
|
2
2
|
from typing import Union
|
|
3
3
|
import re
|
|
4
4
|
|
|
@@ -108,36 +108,45 @@ forward_channel = Filter(FORWARD_CHANNEL)
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
class state(Filter):
|
|
111
|
-
def __init__(self,
|
|
112
|
-
self.states =
|
|
111
|
+
def __init__(self, state: Union[str, list[str]]):
|
|
112
|
+
self.states = state if isinstance(state, list) else [state]
|
|
113
113
|
super().__init__(self.filter)
|
|
114
114
|
|
|
115
115
|
async def filter(self, update: Union[Update, InlineMessage]):
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return user.lower() in states if user else False
|
|
116
|
+
user_state = await update.client.state.get_state(update.chat_id)
|
|
117
|
+
return user_state in self.states
|
|
119
118
|
|
|
120
119
|
|
|
121
120
|
class command(Filter):
|
|
122
|
-
def __init__(self,
|
|
123
|
-
self.
|
|
124
|
-
self.
|
|
121
|
+
def __init__(self, command: Union[str, list[str]], prefix: Union[str, list[str]] = "/", case_sensitive: bool = False):
|
|
122
|
+
self.commands = [c if case_sensitive else c.lower() for c in (command if isinstance(command, list) else [command])]
|
|
123
|
+
self.prefixs = prefix if isinstance(prefix, list) else [prefix]
|
|
124
|
+
self.cmds = [p + c for p in self.prefixs for c in self.commands]
|
|
125
|
+
self.case_sensitive = case_sensitive
|
|
125
126
|
super().__init__(self.filter)
|
|
126
127
|
|
|
127
128
|
async def filter(self, update: Update):
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
text = update.updated_message.text
|
|
135
|
-
if text:
|
|
136
|
-
for cmd in commands:
|
|
137
|
-
if text.lower().startswith(self.prefix + cmd.lower()):
|
|
138
|
-
return True
|
|
139
|
-
return False
|
|
129
|
+
if isinstance(update, Update) and update.type == "NewMessage":
|
|
130
|
+
text = update.new_message.text or ""
|
|
131
|
+
text = text if self.case_sensitive else text.lower()
|
|
132
|
+
return any(text.startswith(cmd) for cmd in self.cmds)
|
|
133
|
+
return False
|
|
134
|
+
|
|
140
135
|
|
|
136
|
+
class button(Filter):
|
|
137
|
+
def __init__(self, button_id: Union[str, list[str]], prefix: Union[str, list[str]] = "", case_sensitive: bool = False):
|
|
138
|
+
self.button_ids = [btn_id if case_sensitive else btn_id.lower() for btn_id in (button_id if isinstance(button_id, list) else [button_id])]
|
|
139
|
+
self.prefixs = prefix if isinstance(prefix, list) else [prefix]
|
|
140
|
+
self.btn_ids = [p + b for p in self.prefixs for b in self.button_ids]
|
|
141
|
+
self.case_sensitive = case_sensitive
|
|
142
|
+
super().__init__(self.filter)
|
|
143
|
+
|
|
144
|
+
async def filter(self, update: InlineMessage):
|
|
145
|
+
if isinstance(update, InlineMessage):
|
|
146
|
+
text = update.text or ""
|
|
147
|
+
text = text if self.case_sensitive else text.lower()
|
|
148
|
+
return any(text.startswith(btn) for btn in self.btn_ids)
|
|
149
|
+
return False
|
|
141
150
|
|
|
142
151
|
class regex(Filter):
|
|
143
152
|
def __init__(self, pattern: str):
|
|
@@ -166,19 +175,4 @@ class chat(Filter):
|
|
|
166
175
|
|
|
167
176
|
async def filter(self, update: Union[Update, InlineMessage]):
|
|
168
177
|
chat_ids = self.chat_id if isinstance(self.chat_id, list) else [self.chat_id]
|
|
169
|
-
return update.chat_id in chat_ids
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
class button(Filter):
|
|
173
|
-
def __init__(self, button_id: Union[str, list[str]], prefix: str = ""):
|
|
174
|
-
self.button_id = button_id
|
|
175
|
-
self.prefix = prefix
|
|
176
|
-
super().__init__(self.filter)
|
|
177
|
-
|
|
178
|
-
async def filter(self, update: InlineMessage):
|
|
179
|
-
if isinstance(update, InlineMessage):
|
|
180
|
-
button_ids = self.button_id if isinstance(self.button_id, list) else [self.button_id]
|
|
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
|
|
178
|
+
return update.chat_id in chat_ids
|