Rubka 3.2.5__tar.gz → 3.3.4__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.
- {rubka-3.2.5 → rubka-3.3.4}/PKG-INFO +1 -1
- {rubka-3.2.5 → rubka-3.3.4}/Rubka.egg-info/PKG-INFO +1 -1
- {rubka-3.2.5 → rubka-3.3.4}/Rubka.egg-info/SOURCES.txt +1 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/api.py +54 -3
- rubka-3.3.4/rubka/button.py +264 -0
- rubka-3.3.4/rubka/keypad.py +298 -0
- {rubka-3.2.5 → rubka-3.3.4}/setup.py +1 -1
- rubka-3.2.5/rubka/keypad.py +0 -48
- {rubka-3.2.5 → rubka-3.3.4}/README.md +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/Rubka.egg-info/dependency_links.txt +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/Rubka.egg-info/requires.txt +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/Rubka.egg-info/top_level.txt +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/client/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/client/client.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/crypto/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/crypto/crypto.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/enums.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/exceptions.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/methods/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/methods/methods.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/network/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/network/helper.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/network/network.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/network/socket.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/sessions/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/sessions/sessions.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/types/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/types/socket/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/types/socket/message.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/utils/__init__.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/utils/configs.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/adaptorrubka/utils/utils.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/config.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/context.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/decorators.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/exceptions.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/jobs.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/keyboards.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/logger.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/rubka/utils.py +0 -0
- {rubka-3.2.5 → rubka-3.3.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.4
|
|
4
4
|
Summary: A Python library for interacting with Rubika Bot API.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
6
|
Download-URL: https://github.com/Mahdy-Ahmadi/Rubka/archive/refs/tags/v0.1.0.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.4
|
|
4
4
|
Summary: A Python library for interacting with Rubika Bot API.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
6
|
Download-URL: https://github.com/Mahdy-Ahmadi/Rubka/archive/refs/tags/v0.1.0.tar.gz
|
|
@@ -222,9 +222,40 @@ class Robot:
|
|
|
222
222
|
|
|
223
223
|
return self._post("sendMessage", payload)
|
|
224
224
|
|
|
225
|
-
def
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
def _get_client(self):
|
|
226
|
+
return Client_get(show_last_six_words(self.token))
|
|
227
|
+
|
|
228
|
+
def check_join(self, channel_guid: str, chat_id: str = None) -> bool | list[str]:
|
|
229
|
+
client = self._get_client()
|
|
230
|
+
|
|
231
|
+
if chat_id:
|
|
232
|
+
chat_info = self.get_chat(chat_id).get('data', {}).get('chat', {})
|
|
233
|
+
username = chat_info.get('username')
|
|
234
|
+
user_id = chat_info.get('user_id')
|
|
235
|
+
|
|
236
|
+
if username:
|
|
237
|
+
members = self.get_all_member(channel_guid, search_text=username).get('in_chat_members', [])
|
|
238
|
+
return any(m.get('username') == username for m in members)
|
|
239
|
+
|
|
240
|
+
elif user_id:
|
|
241
|
+
member_guids = client.get_all_members(channel_guid, just_get_guids=True)
|
|
242
|
+
return user_id in member_guids
|
|
243
|
+
|
|
244
|
+
return False
|
|
245
|
+
|
|
246
|
+
return False
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def get_all_member(
|
|
250
|
+
self,
|
|
251
|
+
channel_guid: str,
|
|
252
|
+
search_text: str = None,
|
|
253
|
+
start_id: str = None,
|
|
254
|
+
just_get_guids: bool = False
|
|
255
|
+
):
|
|
256
|
+
client = self._get_client()
|
|
257
|
+
return client.get_all_members(channel_guid, search_text, start_id, just_get_guids)
|
|
258
|
+
|
|
228
259
|
def send_poll(
|
|
229
260
|
self,
|
|
230
261
|
chat_id: str,
|
|
@@ -373,3 +404,23 @@ class Robot:
|
|
|
373
404
|
"chat_keypad_type": "New",
|
|
374
405
|
"chat_keypad": chat_keypad
|
|
375
406
|
})
|
|
407
|
+
def get_name(self, chat_id: str) -> str:
|
|
408
|
+
try:
|
|
409
|
+
chat = self.get_chat(chat_id)
|
|
410
|
+
chat_info = chat.get("data", {}).get("chat", {})
|
|
411
|
+
first_name = chat_info.get("first_name", "")
|
|
412
|
+
last_name = chat_info.get("last_name", "")
|
|
413
|
+
|
|
414
|
+
if first_name and last_name:
|
|
415
|
+
return f"{first_name} {last_name}"
|
|
416
|
+
elif first_name:
|
|
417
|
+
return first_name
|
|
418
|
+
elif last_name:
|
|
419
|
+
return last_name
|
|
420
|
+
else:
|
|
421
|
+
return "Unknown"
|
|
422
|
+
except Exception:
|
|
423
|
+
return "Unknown"
|
|
424
|
+
def get_username(self, chat_id: str) -> str:
|
|
425
|
+
chat_info = self.get_chat(chat_id).get("data", {}).get("chat", {})
|
|
426
|
+
return chat_info.get("username", "None")
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Optional, Union
|
|
4
|
+
from typing import Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
class InlineBuilder:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self.rows: List[Dict] = []
|
|
9
|
+
|
|
10
|
+
def row(self, *buttons: Dict) -> "InlineBuilder":
|
|
11
|
+
"""
|
|
12
|
+
افزودن یک ردیف دکمه به کیبورد
|
|
13
|
+
حداقل یک دکمه باید داده شود.
|
|
14
|
+
"""
|
|
15
|
+
if not buttons:
|
|
16
|
+
raise ValueError("حداقل یک دکمه باید به row داده شود")
|
|
17
|
+
self.rows.append({"buttons": list(buttons)})
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def button_simple(self, id: str, text: str) -> Dict:
|
|
21
|
+
return {"id": id, "type": "Simple", "button_text": text}
|
|
22
|
+
|
|
23
|
+
def button_selection(self, id: str, text: str, selection: Dict) -> Dict:
|
|
24
|
+
"""
|
|
25
|
+
selection: dict با فیلدهای:
|
|
26
|
+
- selection_id (str)
|
|
27
|
+
- search_type (str) [ButtonSelectionSearchEnum: None, Local, Api]
|
|
28
|
+
- get_type (str) [ButtonSelectionGetEnum: Local, Api]
|
|
29
|
+
- items (list of ButtonSelectionItem)
|
|
30
|
+
- is_multi_selection (bool)
|
|
31
|
+
- columns_count (str)
|
|
32
|
+
- title (str)
|
|
33
|
+
"""
|
|
34
|
+
return {
|
|
35
|
+
"id": id,
|
|
36
|
+
"type": "Selection",
|
|
37
|
+
"button_text": text,
|
|
38
|
+
"button_selection": selection
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def button_calendar(self, id: str, title: str, type_: str,
|
|
42
|
+
default_value: Optional[str] = None,
|
|
43
|
+
min_year: Optional[str] = None,
|
|
44
|
+
max_year: Optional[str] = None) -> Dict:
|
|
45
|
+
"""
|
|
46
|
+
type_: ButtonCalendarTypeEnum = "DatePersian" | "DateGregorian"
|
|
47
|
+
"""
|
|
48
|
+
calendar = {
|
|
49
|
+
"title": title,
|
|
50
|
+
"type": type_,
|
|
51
|
+
}
|
|
52
|
+
if default_value:
|
|
53
|
+
calendar["default_value"] = default_value
|
|
54
|
+
if min_year:
|
|
55
|
+
calendar["min_year"] = min_year
|
|
56
|
+
if max_year:
|
|
57
|
+
calendar["max_year"] = max_year
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
"id": id,
|
|
61
|
+
"type": "Calendar",
|
|
62
|
+
"button_text": title,
|
|
63
|
+
"button_calendar": calendar
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
def button_number_picker(self, id: str, title: str, min_value: str, max_value: str,
|
|
67
|
+
default_value: Optional[str] = None) -> Dict:
|
|
68
|
+
picker = {
|
|
69
|
+
"title": title,
|
|
70
|
+
"min_value": min_value,
|
|
71
|
+
"max_value": max_value,
|
|
72
|
+
}
|
|
73
|
+
if default_value:
|
|
74
|
+
picker["default_value"] = default_value
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
"id": id,
|
|
78
|
+
"type": "NumberPicker",
|
|
79
|
+
"button_text": title,
|
|
80
|
+
"button_number_picker": picker
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
def button_string_picker(self, id: str, title: Optional[str], items: List[str],
|
|
84
|
+
default_value: Optional[str] = None) -> Dict:
|
|
85
|
+
picker = {
|
|
86
|
+
"items": items
|
|
87
|
+
}
|
|
88
|
+
if default_value:
|
|
89
|
+
picker["default_value"] = default_value
|
|
90
|
+
if title:
|
|
91
|
+
picker["title"] = title
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
"id": id,
|
|
95
|
+
"type": "StringPicker",
|
|
96
|
+
"button_text": title if title else "انتخاب",
|
|
97
|
+
"button_string_picker": picker
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
def button_location(self, id: str, type_: str, location_image_url: str,
|
|
101
|
+
default_pointer_location: Optional[Dict] = None,
|
|
102
|
+
default_map_location: Optional[Dict] = None,
|
|
103
|
+
title: Optional[str] = None) -> Dict:
|
|
104
|
+
"""
|
|
105
|
+
type_: ButtonLocationTypeEnum = "Picker" | "View"
|
|
106
|
+
location_image_url: str آدرس عکس دکمه موقعیت
|
|
107
|
+
default_pointer_location و default_map_location هر کدام دیکشنری Location (latitude, longitude)
|
|
108
|
+
"""
|
|
109
|
+
loc = {
|
|
110
|
+
"type": type_,
|
|
111
|
+
"location_image_url": location_image_url,
|
|
112
|
+
}
|
|
113
|
+
if default_pointer_location:
|
|
114
|
+
loc["default_pointer_location"] = default_pointer_location
|
|
115
|
+
if default_map_location:
|
|
116
|
+
loc["default_map_location"] = default_map_location
|
|
117
|
+
if title:
|
|
118
|
+
loc["title"] = title
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
"id": id,
|
|
122
|
+
"type": "Location",
|
|
123
|
+
"button_text": title if title else "موقعیت مکانی",
|
|
124
|
+
"button_location": loc
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
def button_textbox(self, id: str, title: Optional[str],
|
|
128
|
+
type_line: str, type_keypad: str,
|
|
129
|
+
place_holder: Optional[str] = None,
|
|
130
|
+
default_value: Optional[str] = None) -> Dict:
|
|
131
|
+
"""
|
|
132
|
+
type_line: ButtonTextboxTypeLineEnum = "SingleLine" | "MultiLine"
|
|
133
|
+
type_keypad: ButtonTextboxTypeKeypadEnum = "String" | "Number"
|
|
134
|
+
"""
|
|
135
|
+
textbox = {
|
|
136
|
+
"type_line": type_line,
|
|
137
|
+
"type_keypad": type_keypad
|
|
138
|
+
}
|
|
139
|
+
if place_holder:
|
|
140
|
+
textbox["place_holder"] = place_holder
|
|
141
|
+
if default_value:
|
|
142
|
+
textbox["default_value"] = default_value
|
|
143
|
+
if title:
|
|
144
|
+
textbox["title"] = title
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
"id": id,
|
|
148
|
+
"type": "Textbox",
|
|
149
|
+
"button_text": title if title else "متن",
|
|
150
|
+
"button_textbox": textbox
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
def button_payment(self, id: str, title: str, amount: int, description: Optional[str] = None) -> Dict:
|
|
154
|
+
"""
|
|
155
|
+
نمونهای ساده برای دکمه پرداخت (مقدار و توضیح دلخواه)
|
|
156
|
+
"""
|
|
157
|
+
payment = {
|
|
158
|
+
"title": title,
|
|
159
|
+
"amount": amount
|
|
160
|
+
}
|
|
161
|
+
if description:
|
|
162
|
+
payment["description"] = description
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
"id": id,
|
|
166
|
+
"type": "Payment",
|
|
167
|
+
"button_text": title,
|
|
168
|
+
"button_payment": payment
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
def button_camera_image(self, id: str, title: str) -> Dict:
|
|
172
|
+
return {
|
|
173
|
+
"id": id,
|
|
174
|
+
"type": "CameraImage",
|
|
175
|
+
"button_text": title
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
def button_camera_video(self, id: str, title: str) -> Dict:
|
|
179
|
+
return {
|
|
180
|
+
"id": id,
|
|
181
|
+
"type": "CameraVideo",
|
|
182
|
+
"button_text": title
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
def button_gallery_image(self, id: str, title: str) -> Dict:
|
|
186
|
+
return {
|
|
187
|
+
"id": id,
|
|
188
|
+
"type": "GalleryImage",
|
|
189
|
+
"button_text": title
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
def button_gallery_video(self, id: str, title: str) -> Dict:
|
|
193
|
+
return {
|
|
194
|
+
"id": id,
|
|
195
|
+
"type": "GalleryVideo",
|
|
196
|
+
"button_text": title
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
def button_file(self, id: str, title: str) -> Dict:
|
|
200
|
+
return {
|
|
201
|
+
"id": id,
|
|
202
|
+
"type": "File",
|
|
203
|
+
"button_text": title
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
def button_audio(self, id: str, title: str) -> Dict:
|
|
207
|
+
return {
|
|
208
|
+
"id": id,
|
|
209
|
+
"type": "Audio",
|
|
210
|
+
"button_text": title
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
def button_record_audio(self, id: str, title: str) -> Dict:
|
|
214
|
+
return {
|
|
215
|
+
"id": id,
|
|
216
|
+
"type": "RecordAudio",
|
|
217
|
+
"button_text": title
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
def button_my_phone_number(self, id: str, title: str) -> Dict:
|
|
221
|
+
return {
|
|
222
|
+
"id": id,
|
|
223
|
+
"type": "MyPhoneNumber",
|
|
224
|
+
"button_text": title
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
def button_my_location(self, id: str, title: str) -> Dict:
|
|
228
|
+
return {
|
|
229
|
+
"id": id,
|
|
230
|
+
"type": "MyLocation",
|
|
231
|
+
"button_text": title
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
def button_link(self, id: str, title: str, url: str) -> Dict:
|
|
235
|
+
return {
|
|
236
|
+
"id": id,
|
|
237
|
+
"type": "Link",
|
|
238
|
+
"button_text": title,
|
|
239
|
+
"url": url
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
def button_ask_my_phone_number(self, id: str, title: str) -> Dict:
|
|
243
|
+
return {
|
|
244
|
+
"id": id,
|
|
245
|
+
"type": "AskMyPhoneNumber",
|
|
246
|
+
"button_text": title
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
def button_ask_location(self, id: str, title: str) -> Dict:
|
|
250
|
+
return {
|
|
251
|
+
"id": id,
|
|
252
|
+
"type": "AskLocation",
|
|
253
|
+
"button_text": title
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
def button_barcode(self, id: str, title: str) -> Dict:
|
|
257
|
+
return {
|
|
258
|
+
"id": id,
|
|
259
|
+
"type": "Barcode",
|
|
260
|
+
"button_text": title
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
def build(self) -> Dict:
|
|
264
|
+
return {"rows": self.rows}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Optional, Union
|
|
4
|
+
from typing import Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
class InlineBuilder:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self.rows: List[Dict] = []
|
|
9
|
+
|
|
10
|
+
def row(self, *buttons: Dict) -> "InlineBuilder":
|
|
11
|
+
"""
|
|
12
|
+
افزودن یک ردیف دکمه به کیبورد
|
|
13
|
+
حداقل یک دکمه باید داده شود.
|
|
14
|
+
"""
|
|
15
|
+
if not buttons:
|
|
16
|
+
raise ValueError("حداقل یک دکمه باید به row داده شود")
|
|
17
|
+
self.rows.append({"buttons": list(buttons)})
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def button_simple(self, id: str, text: str) -> Dict:
|
|
21
|
+
return {"id": id, "type": "Simple", "button_text": text}
|
|
22
|
+
|
|
23
|
+
def button_selection(self, id: str, text: str, selection: Dict) -> Dict:
|
|
24
|
+
"""
|
|
25
|
+
selection: dict با فیلدهای:
|
|
26
|
+
- selection_id (str)
|
|
27
|
+
- search_type (str) [ButtonSelectionSearchEnum: None, Local, Api]
|
|
28
|
+
- get_type (str) [ButtonSelectionGetEnum: Local, Api]
|
|
29
|
+
- items (list of ButtonSelectionItem)
|
|
30
|
+
- is_multi_selection (bool)
|
|
31
|
+
- columns_count (str)
|
|
32
|
+
- title (str)
|
|
33
|
+
"""
|
|
34
|
+
return {
|
|
35
|
+
"id": id,
|
|
36
|
+
"type": "Selection",
|
|
37
|
+
"button_text": text,
|
|
38
|
+
"button_selection": selection
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def button_calendar(self, id: str, title: str, type_: str,
|
|
42
|
+
default_value: Optional[str] = None,
|
|
43
|
+
min_year: Optional[str] = None,
|
|
44
|
+
max_year: Optional[str] = None) -> Dict:
|
|
45
|
+
"""
|
|
46
|
+
type_: ButtonCalendarTypeEnum = "DatePersian" | "DateGregorian"
|
|
47
|
+
"""
|
|
48
|
+
calendar = {
|
|
49
|
+
"title": title,
|
|
50
|
+
"type": type_,
|
|
51
|
+
}
|
|
52
|
+
if default_value:
|
|
53
|
+
calendar["default_value"] = default_value
|
|
54
|
+
if min_year:
|
|
55
|
+
calendar["min_year"] = min_year
|
|
56
|
+
if max_year:
|
|
57
|
+
calendar["max_year"] = max_year
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
"id": id,
|
|
61
|
+
"type": "Calendar",
|
|
62
|
+
"button_text": title,
|
|
63
|
+
"button_calendar": calendar
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
def button_number_picker(self, id: str, title: str, min_value: str, max_value: str,
|
|
67
|
+
default_value: Optional[str] = None) -> Dict:
|
|
68
|
+
picker = {
|
|
69
|
+
"title": title,
|
|
70
|
+
"min_value": min_value,
|
|
71
|
+
"max_value": max_value,
|
|
72
|
+
}
|
|
73
|
+
if default_value:
|
|
74
|
+
picker["default_value"] = default_value
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
"id": id,
|
|
78
|
+
"type": "NumberPicker",
|
|
79
|
+
"button_text": title,
|
|
80
|
+
"button_number_picker": picker
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
def button_string_picker(self, id: str, title: Optional[str], items: List[str],
|
|
84
|
+
default_value: Optional[str] = None) -> Dict:
|
|
85
|
+
picker = {
|
|
86
|
+
"items": items
|
|
87
|
+
}
|
|
88
|
+
if default_value:
|
|
89
|
+
picker["default_value"] = default_value
|
|
90
|
+
if title:
|
|
91
|
+
picker["title"] = title
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
"id": id,
|
|
95
|
+
"type": "StringPicker",
|
|
96
|
+
"button_text": title if title else "انتخاب",
|
|
97
|
+
"button_string_picker": picker
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
def button_location(self, id: str, type_: str, location_image_url: str,
|
|
101
|
+
default_pointer_location: Optional[Dict] = None,
|
|
102
|
+
default_map_location: Optional[Dict] = None,
|
|
103
|
+
title: Optional[str] = None) -> Dict:
|
|
104
|
+
"""
|
|
105
|
+
type_: ButtonLocationTypeEnum = "Picker" | "View"
|
|
106
|
+
location_image_url: str آدرس عکس دکمه موقعیت
|
|
107
|
+
default_pointer_location و default_map_location هر کدام دیکشنری Location (latitude, longitude)
|
|
108
|
+
"""
|
|
109
|
+
loc = {
|
|
110
|
+
"type": type_,
|
|
111
|
+
"location_image_url": location_image_url,
|
|
112
|
+
}
|
|
113
|
+
if default_pointer_location:
|
|
114
|
+
loc["default_pointer_location"] = default_pointer_location
|
|
115
|
+
if default_map_location:
|
|
116
|
+
loc["default_map_location"] = default_map_location
|
|
117
|
+
if title:
|
|
118
|
+
loc["title"] = title
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
"id": id,
|
|
122
|
+
"type": "Location",
|
|
123
|
+
"button_text": title if title else "موقعیت مکانی",
|
|
124
|
+
"button_location": loc
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
def button_textbox(self, id: str, title: Optional[str],
|
|
128
|
+
type_line: str, type_keypad: str,
|
|
129
|
+
place_holder: Optional[str] = None,
|
|
130
|
+
default_value: Optional[str] = None) -> Dict:
|
|
131
|
+
"""
|
|
132
|
+
type_line: ButtonTextboxTypeLineEnum = "SingleLine" | "MultiLine"
|
|
133
|
+
type_keypad: ButtonTextboxTypeKeypadEnum = "String" | "Number"
|
|
134
|
+
"""
|
|
135
|
+
textbox = {
|
|
136
|
+
"type_line": type_line,
|
|
137
|
+
"type_keypad": type_keypad
|
|
138
|
+
}
|
|
139
|
+
if place_holder:
|
|
140
|
+
textbox["place_holder"] = place_holder
|
|
141
|
+
if default_value:
|
|
142
|
+
textbox["default_value"] = default_value
|
|
143
|
+
if title:
|
|
144
|
+
textbox["title"] = title
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
"id": id,
|
|
148
|
+
"type": "Textbox",
|
|
149
|
+
"button_text": title if title else "متن",
|
|
150
|
+
"button_textbox": textbox
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
def button_payment(self, id: str, title: str, amount: int, description: Optional[str] = None) -> Dict:
|
|
154
|
+
"""
|
|
155
|
+
نمونهای ساده برای دکمه پرداخت (مقدار و توضیح دلخواه)
|
|
156
|
+
"""
|
|
157
|
+
payment = {
|
|
158
|
+
"title": title,
|
|
159
|
+
"amount": amount
|
|
160
|
+
}
|
|
161
|
+
if description:
|
|
162
|
+
payment["description"] = description
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
"id": id,
|
|
166
|
+
"type": "Payment",
|
|
167
|
+
"button_text": title,
|
|
168
|
+
"button_payment": payment
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
def button_camera_image(self, id: str, title: str) -> Dict:
|
|
172
|
+
return {
|
|
173
|
+
"id": id,
|
|
174
|
+
"type": "CameraImage",
|
|
175
|
+
"button_text": title
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
def button_camera_video(self, id: str, title: str) -> Dict:
|
|
179
|
+
return {
|
|
180
|
+
"id": id,
|
|
181
|
+
"type": "CameraVideo",
|
|
182
|
+
"button_text": title
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
def button_gallery_image(self, id: str, title: str) -> Dict:
|
|
186
|
+
return {
|
|
187
|
+
"id": id,
|
|
188
|
+
"type": "GalleryImage",
|
|
189
|
+
"button_text": title
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
def button_gallery_video(self, id: str, title: str) -> Dict:
|
|
193
|
+
return {
|
|
194
|
+
"id": id,
|
|
195
|
+
"type": "GalleryVideo",
|
|
196
|
+
"button_text": title
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
def button_file(self, id: str, title: str) -> Dict:
|
|
200
|
+
return {
|
|
201
|
+
"id": id,
|
|
202
|
+
"type": "File",
|
|
203
|
+
"button_text": title
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
def button_audio(self, id: str, title: str) -> Dict:
|
|
207
|
+
return {
|
|
208
|
+
"id": id,
|
|
209
|
+
"type": "Audio",
|
|
210
|
+
"button_text": title
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
def button_record_audio(self, id: str, title: str) -> Dict:
|
|
214
|
+
return {
|
|
215
|
+
"id": id,
|
|
216
|
+
"type": "RecordAudio",
|
|
217
|
+
"button_text": title
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
def button_my_phone_number(self, id: str, title: str) -> Dict:
|
|
221
|
+
return {
|
|
222
|
+
"id": id,
|
|
223
|
+
"type": "MyPhoneNumber",
|
|
224
|
+
"button_text": title
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
def button_my_location(self, id: str, title: str) -> Dict:
|
|
228
|
+
return {
|
|
229
|
+
"id": id,
|
|
230
|
+
"type": "MyLocation",
|
|
231
|
+
"button_text": title
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
def button_link(self, id: str, title: str, url: str) -> Dict:
|
|
235
|
+
return {
|
|
236
|
+
"id": id,
|
|
237
|
+
"type": "Link",
|
|
238
|
+
"button_text": title,
|
|
239
|
+
"url": url
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
def button_ask_my_phone_number(self, id: str, title: str) -> Dict:
|
|
243
|
+
return {
|
|
244
|
+
"id": id,
|
|
245
|
+
"type": "AskMyPhoneNumber",
|
|
246
|
+
"button_text": title
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
def button_ask_location(self, id: str, title: str) -> Dict:
|
|
250
|
+
return {
|
|
251
|
+
"id": id,
|
|
252
|
+
"type": "AskLocation",
|
|
253
|
+
"button_text": title
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
def button_barcode(self, id: str, title: str) -> Dict:
|
|
257
|
+
return {
|
|
258
|
+
"id": id,
|
|
259
|
+
"type": "Barcode",
|
|
260
|
+
"button_text": title
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
def build(self) -> Dict:
|
|
264
|
+
return {"rows": self.rows}
|
|
265
|
+
|
|
266
|
+
from typing import List, Dict, Optional
|
|
267
|
+
|
|
268
|
+
class ChatKeypadBuilder:
|
|
269
|
+
def __init__(self):
|
|
270
|
+
self.rows: List[Dict[str, List[Dict[str, str]]]] = []
|
|
271
|
+
|
|
272
|
+
def row(self, *buttons: Dict[str, str]) -> "ChatKeypadBuilder":
|
|
273
|
+
"""
|
|
274
|
+
یک ردیف دکمه به کیپد اضافه میکند.
|
|
275
|
+
ورودی: چند دیکشنری که نماینده دکمهها هستند.
|
|
276
|
+
"""
|
|
277
|
+
self.rows.append({"buttons": list(buttons)})
|
|
278
|
+
return self
|
|
279
|
+
|
|
280
|
+
def button(self, id: str, text: str, type: str = "Simple") -> Dict[str, str]:
|
|
281
|
+
"""
|
|
282
|
+
دیکشنری یک دکمه میسازد.
|
|
283
|
+
"""
|
|
284
|
+
return {"id": id, "type": type, "button_text": text}
|
|
285
|
+
|
|
286
|
+
def build(
|
|
287
|
+
self,
|
|
288
|
+
resize_keyboard: bool = True,
|
|
289
|
+
on_time_keyboard: bool = False
|
|
290
|
+
) -> Dict[str, object]:
|
|
291
|
+
"""
|
|
292
|
+
ساختار نهایی chat_keypad را میسازد.
|
|
293
|
+
"""
|
|
294
|
+
return {
|
|
295
|
+
"rows": self.rows,
|
|
296
|
+
"resize_keyboard": resize_keyboard,
|
|
297
|
+
"on_time_keyboard": on_time_keyboard
|
|
298
|
+
}
|
rubka-3.2.5/rubka/keypad.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
from typing import Dict
|
|
2
|
-
|
|
3
|
-
class InlineBuilder:
|
|
4
|
-
def __init__(self):
|
|
5
|
-
self.rows = []
|
|
6
|
-
|
|
7
|
-
def row(self, *buttons: Dict[str, str]):
|
|
8
|
-
self.rows.append({"buttons": list(buttons)})
|
|
9
|
-
return self
|
|
10
|
-
|
|
11
|
-
def button(self, id: str, text: str, type: str = "Simple") -> Dict[str, str]:
|
|
12
|
-
return {"id": id, "type": type, "button_text": text}
|
|
13
|
-
|
|
14
|
-
def build(self):
|
|
15
|
-
return {"rows": self.rows}
|
|
16
|
-
from typing import List, Dict, Optional
|
|
17
|
-
|
|
18
|
-
class ChatKeypadBuilder:
|
|
19
|
-
def __init__(self):
|
|
20
|
-
self.rows: List[Dict[str, List[Dict[str, str]]]] = []
|
|
21
|
-
|
|
22
|
-
def row(self, *buttons: Dict[str, str]) -> "ChatKeypadBuilder":
|
|
23
|
-
"""
|
|
24
|
-
یک ردیف دکمه به کیپد اضافه میکند.
|
|
25
|
-
ورودی: چند دیکشنری که نماینده دکمهها هستند.
|
|
26
|
-
"""
|
|
27
|
-
self.rows.append({"buttons": list(buttons)})
|
|
28
|
-
return self
|
|
29
|
-
|
|
30
|
-
def button(self, id: str, text: str, type: str = "Simple") -> Dict[str, str]:
|
|
31
|
-
"""
|
|
32
|
-
دیکشنری یک دکمه میسازد.
|
|
33
|
-
"""
|
|
34
|
-
return {"id": id, "type": type, "button_text": text}
|
|
35
|
-
|
|
36
|
-
def build(
|
|
37
|
-
self,
|
|
38
|
-
resize_keyboard: bool = True,
|
|
39
|
-
on_time_keyboard: bool = False
|
|
40
|
-
) -> Dict[str, object]:
|
|
41
|
-
"""
|
|
42
|
-
ساختار نهایی chat_keypad را میسازد.
|
|
43
|
-
"""
|
|
44
|
-
return {
|
|
45
|
-
"rows": self.rows,
|
|
46
|
-
"resize_keyboard": resize_keyboard,
|
|
47
|
-
"on_time_keyboard": on_time_keyboard
|
|
48
|
-
}
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|