RubigramClient 1.6.4__py3-none-any.whl → 1.6.5__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 +3 -2
- rubigram/client.py +7 -3
- rubigram/enums.py +129 -0
- rubigram/filters.py +31 -37
- rubigram/method.py +52 -32
- rubigram/state.py +14 -77
- rubigram/{models.py → types.py} +301 -206
- {rubigramclient-1.6.4.dist-info → rubigramclient-1.6.5.dist-info}/METADATA +9 -10
- rubigramclient-1.6.5.dist-info/RECORD +13 -0
- rubigramclient-1.6.4.dist-info/RECORD +0 -12
- {rubigramclient-1.6.4.dist-info → rubigramclient-1.6.5.dist-info}/WHEEL +0 -0
- {rubigramclient-1.6.4.dist-info → rubigramclient-1.6.5.dist-info}/licenses/LICENSE +0 -0
- {rubigramclient-1.6.4.dist-info → rubigramclient-1.6.5.dist-info}/top_level.txt +0 -0
rubigram/{models.py → types.py}
RENAMED
|
@@ -1,169 +1,233 @@
|
|
|
1
|
-
from dataclasses import dataclass,
|
|
2
|
-
from typing import
|
|
1
|
+
from dataclasses import dataclass, is_dataclass, fields
|
|
2
|
+
from typing import Type, TypeVar, Union, Optional, get_origin, get_args
|
|
3
|
+
from json import dumps
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from . import enums
|
|
3
6
|
import rubigram
|
|
4
|
-
import json
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
T = TypeVar("T", bound="
|
|
9
|
+
T = TypeVar("T", bound="DataManager")
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
@dataclass
|
|
11
|
-
class
|
|
12
|
-
def to_dict(self) -> dict
|
|
13
|
+
class DataManager:
|
|
14
|
+
def to_dict(self) -> dict:
|
|
13
15
|
data = {}
|
|
14
16
|
for field in fields(self):
|
|
15
17
|
value = getattr(self, field.name)
|
|
16
|
-
if
|
|
18
|
+
if isinstance(value, Enum):
|
|
19
|
+
data[field.name] = value.value
|
|
20
|
+
elif is_dataclass(value):
|
|
17
21
|
data[field.name] = value.to_dict()
|
|
18
22
|
elif isinstance(value, list):
|
|
19
|
-
data[field.name] = [i.to_dict() if is_dataclass(i)else i for i in value]
|
|
23
|
+
data[field.name] = [i.to_dict() if is_dataclass(i) else i for i in value]
|
|
20
24
|
else:
|
|
21
25
|
data[field.name] = value
|
|
22
26
|
return data
|
|
23
27
|
|
|
28
|
+
|
|
24
29
|
@classmethod
|
|
25
|
-
def from_dict(
|
|
26
|
-
|
|
27
|
-
data = {}
|
|
30
|
+
def from_dict(Class: Type[T], data: dict) -> T:
|
|
31
|
+
data = data or {}
|
|
28
32
|
init_data = {}
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
for field in fields(Class):
|
|
30
35
|
value = data.get(field.name)
|
|
31
36
|
field_type = field.type
|
|
32
37
|
origin = get_origin(field_type)
|
|
33
|
-
|
|
38
|
+
|
|
39
|
+
if isinstance(value, dict) and isinstance(field_type, type) and issubclass(field_type, DataManager):
|
|
34
40
|
init_data[field.name] = field_type.from_dict(value)
|
|
41
|
+
|
|
35
42
|
elif origin == list:
|
|
36
43
|
inner_type = get_args(field_type)[0]
|
|
37
|
-
if isinstance(inner_type, type) and issubclass(inner_type,
|
|
44
|
+
if isinstance(inner_type, type) and issubclass(inner_type, DataManager):
|
|
38
45
|
init_data[field.name] = [inner_type.from_dict(
|
|
39
46
|
v) if isinstance(v, dict) else v for v in (value or [])]
|
|
40
47
|
else:
|
|
41
48
|
init_data[field.name] = value or []
|
|
42
|
-
|
|
49
|
+
|
|
50
|
+
elif origin == Union:
|
|
43
51
|
args = get_args(field_type)
|
|
44
52
|
dict_type = next((a for a in args if isinstance(
|
|
45
|
-
a, type) and issubclass(a,
|
|
53
|
+
a, type) and issubclass(a, DataManager)), None)
|
|
46
54
|
if dict_type and isinstance(value, dict):
|
|
47
55
|
init_data[field.name] = dict_type.from_dict(value)
|
|
48
56
|
else:
|
|
49
57
|
init_data[field.name] = value
|
|
58
|
+
|
|
50
59
|
else:
|
|
51
60
|
init_data[field.name] = value
|
|
52
|
-
return cls(**init_data)
|
|
53
61
|
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
return Class(**init_data)
|
|
63
|
+
|
|
64
|
+
def json(self):
|
|
65
|
+
def clear(object):
|
|
66
|
+
if isinstance(object, dict):
|
|
67
|
+
return {key: clear(value) for key, value in object.items() if value is not None}
|
|
68
|
+
elif isinstance(object, list):
|
|
69
|
+
return [clear(i) for i in object if i is not None]
|
|
70
|
+
else:
|
|
71
|
+
return object
|
|
72
|
+
|
|
73
|
+
data = self.to_dict()
|
|
56
74
|
data.pop("client", None)
|
|
57
|
-
|
|
75
|
+
clean_data = clear(data)
|
|
76
|
+
return dumps(clean_data, ensure_ascii=False, indent=4)
|
|
58
77
|
|
|
59
78
|
|
|
60
79
|
@dataclass
|
|
61
|
-
class
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
class Chat(DataManager):
|
|
81
|
+
chat_id: Optional[str] = None
|
|
82
|
+
chat_type: Optional[enums.ChatType] = None
|
|
83
|
+
user_id: Optional[str] = None
|
|
84
|
+
first_name: Optional[str] = None
|
|
85
|
+
last_name: Optional[str] = None
|
|
86
|
+
title: Optional[str] = None
|
|
87
|
+
username: Optional[str] = None
|
|
64
88
|
|
|
65
89
|
def __repr__(self):
|
|
66
|
-
return self.
|
|
90
|
+
return self.json()
|
|
67
91
|
|
|
68
92
|
|
|
69
93
|
@dataclass
|
|
70
|
-
class
|
|
71
|
-
|
|
72
|
-
|
|
94
|
+
class File(DataManager):
|
|
95
|
+
file_id: Optional[str] = None
|
|
96
|
+
file_name: Optional[str] = None
|
|
97
|
+
size: Optional[str] = None
|
|
73
98
|
|
|
74
99
|
def __repr__(self):
|
|
75
|
-
return self.
|
|
100
|
+
return self.json()
|
|
76
101
|
|
|
77
102
|
|
|
78
103
|
@dataclass
|
|
79
|
-
class
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
class ForwardedFrom(DataManager):
|
|
105
|
+
type_from: Optional[enums.ForwardedFrom] = None
|
|
106
|
+
message_id: Optional[str] = None
|
|
107
|
+
from_chat_id: Optional[str] = None
|
|
108
|
+
from_sender_id: Optional[str] = None
|
|
82
109
|
|
|
83
110
|
def __repr__(self):
|
|
84
|
-
return self.
|
|
111
|
+
return self.json()
|
|
85
112
|
|
|
86
113
|
|
|
87
114
|
@dataclass
|
|
88
|
-
class
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
joinchannel_data: Optional[JoinChannelData] = None
|
|
92
|
-
open_chat_data: Optional[OpenChatData] = None
|
|
115
|
+
class PaymentStatus(DataManager):
|
|
116
|
+
payment_id: Optional[str] = None
|
|
117
|
+
status: Optional[enums.PaymentStatus] = None
|
|
93
118
|
|
|
94
119
|
def __repr__(self):
|
|
95
|
-
return self.
|
|
120
|
+
return self.json()
|
|
96
121
|
|
|
97
122
|
|
|
98
123
|
@dataclass
|
|
99
|
-
class
|
|
124
|
+
class MessageTextUpdate(DataManager):
|
|
125
|
+
message_id: Optional[str] = None
|
|
100
126
|
text: Optional[str] = None
|
|
101
|
-
image_url: Optional[str] = None
|
|
102
|
-
type: Optional[Literal["TextOnly", "TextImgThu", "TextImgBig"]] = None
|
|
103
127
|
|
|
104
128
|
def __repr__(self):
|
|
105
|
-
return self.
|
|
129
|
+
return self.json()
|
|
106
130
|
|
|
107
131
|
|
|
108
132
|
@dataclass
|
|
109
|
-
class
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
class Bot(DataManager):
|
|
134
|
+
bot_id: Optional[str] = None
|
|
135
|
+
bot_title: Optional[str] = None
|
|
136
|
+
avatar: Optional[File] = None
|
|
137
|
+
description: Optional[str] = None
|
|
138
|
+
username: Optional[str] = None
|
|
139
|
+
start_message: Optional[str] = None
|
|
140
|
+
share_url: Optional[str] = None
|
|
115
141
|
|
|
116
142
|
def __repr__(self):
|
|
117
|
-
return self.
|
|
143
|
+
return self.json()
|
|
118
144
|
|
|
119
145
|
|
|
120
146
|
@dataclass
|
|
121
|
-
class
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
type: Optional[Literal["Picker", "View"]] = None
|
|
125
|
-
title: Optional[str] = None
|
|
126
|
-
location_image_url: Optional[str] = None
|
|
147
|
+
class BotCommand(DataManager):
|
|
148
|
+
command: Optional[str] = None
|
|
149
|
+
description: Optional[str] = None
|
|
127
150
|
|
|
128
151
|
def __repr__(self):
|
|
129
|
-
return self.
|
|
152
|
+
return self.json()
|
|
130
153
|
|
|
131
154
|
|
|
132
155
|
@dataclass
|
|
133
|
-
class
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
class Sticker(DataManager):
|
|
157
|
+
sticker_id: Optional[str] = None
|
|
158
|
+
file: Optional[File] = None
|
|
159
|
+
emoji_character: Optional[str] = None
|
|
137
160
|
|
|
138
161
|
def __repr__(self):
|
|
139
|
-
return self.
|
|
162
|
+
return self.json()
|
|
140
163
|
|
|
141
164
|
|
|
142
165
|
@dataclass
|
|
143
|
-
class
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
title: Optional[str] = None
|
|
166
|
+
class ContactMessage(DataManager):
|
|
167
|
+
phone_number: Optional[str] = None
|
|
168
|
+
first_name: Optional[str] = None
|
|
169
|
+
last_name: Optional[str] = None
|
|
148
170
|
|
|
149
171
|
def __repr__(self):
|
|
150
|
-
return self.
|
|
172
|
+
return self.json()
|
|
151
173
|
|
|
152
174
|
|
|
153
175
|
@dataclass
|
|
154
|
-
class
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
class PollStatus(DataManager):
|
|
177
|
+
state: Optional[enums.PollStatus] = None
|
|
178
|
+
selection_index: Optional[int] = None
|
|
179
|
+
percent_vote_options: Optional[list[int]] = None
|
|
180
|
+
total_vote: Optional[int] = None
|
|
181
|
+
show_total_votes: Optional[bool] = None
|
|
182
|
+
|
|
183
|
+
def __repr__(self):
|
|
184
|
+
return self.json()
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@dataclass
|
|
188
|
+
class Poll(DataManager):
|
|
189
|
+
question: Optional[str] = None
|
|
190
|
+
options: Optional[list[str]] = None
|
|
191
|
+
poll_status: Optional[PollStatus] = None
|
|
192
|
+
|
|
193
|
+
def __repr__(self):
|
|
194
|
+
return self.json()
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass
|
|
198
|
+
class Location(DataManager):
|
|
199
|
+
longitude: Optional[str] = None
|
|
200
|
+
latitude: Optional[str] = None
|
|
201
|
+
|
|
202
|
+
def __repr__(self):
|
|
203
|
+
return self.json()
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@dataclass
|
|
207
|
+
class LiveLocation(DataManager):
|
|
208
|
+
start_time: Optional[str] = None
|
|
209
|
+
live_period: Optional[int] = None
|
|
210
|
+
current_location: Optional[Location] = None
|
|
211
|
+
user_id: Optional[str] = None
|
|
212
|
+
status: Optional[enums.LiveLocationStatus] = None
|
|
213
|
+
last_update_time: Optional[str] = None
|
|
214
|
+
|
|
215
|
+
def __repr__(self):
|
|
216
|
+
return self.json()
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@dataclass
|
|
220
|
+
class ButtonSelectionItem(DataManager):
|
|
221
|
+
text: Optional[str] = None
|
|
222
|
+
image_url: Optional[str] = None
|
|
223
|
+
type: Optional[enums.ButtonSelectionType] = None
|
|
160
224
|
|
|
161
225
|
def __repr__(self):
|
|
162
|
-
return self.
|
|
226
|
+
return self.json()
|
|
163
227
|
|
|
164
228
|
|
|
165
229
|
@dataclass
|
|
166
|
-
class ButtonSelection(
|
|
230
|
+
class ButtonSelection(DataManager):
|
|
167
231
|
selection_id: Optional[str] = None
|
|
168
232
|
search_type: Optional[str] = None
|
|
169
233
|
get_type: Optional[str] = None
|
|
@@ -173,149 +237,152 @@ class ButtonSelection(Dict):
|
|
|
173
237
|
title: Optional[str] = None
|
|
174
238
|
|
|
175
239
|
def __repr__(self):
|
|
176
|
-
return self.
|
|
240
|
+
return self.json()
|
|
177
241
|
|
|
178
242
|
|
|
179
243
|
@dataclass
|
|
180
|
-
class
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"MyPhoneNumber", "MyLocation", "Textbox", "Link", "AskMyPhoneNumber", "AskLocation", "Barcode"
|
|
187
|
-
] = "Simple"
|
|
188
|
-
button_selection: Optional[ButtonSelection] = None
|
|
189
|
-
button_calendar: Optional[ButtonCalendar] = None
|
|
190
|
-
button_number_picker: Optional[ButtonNumberPicker] = None
|
|
191
|
-
button_string_picker: Optional[ButtonStringPicker] = None
|
|
192
|
-
button_location: Optional[ButtonLocation] = None
|
|
193
|
-
button_textbox: Optional[ButtonTextbox] = None
|
|
194
|
-
button_link: Optional[ButtonLink] = None
|
|
244
|
+
class ButtonCalendar(DataManager):
|
|
245
|
+
default_value: Optional[str] = None
|
|
246
|
+
type: Optional[enums.ButtonCalendarType] = None
|
|
247
|
+
min_year: Optional[str] = None
|
|
248
|
+
max_year: Optional[str] = None
|
|
249
|
+
title: Optional[str] = None
|
|
195
250
|
|
|
196
251
|
def __repr__(self):
|
|
197
|
-
return self.
|
|
252
|
+
return self.json()
|
|
198
253
|
|
|
199
254
|
|
|
200
255
|
@dataclass
|
|
201
|
-
class
|
|
202
|
-
|
|
256
|
+
class ButtonNumberPicker(DataManager):
|
|
257
|
+
min_value: Optional[str] = None
|
|
258
|
+
max_value: Optional[str] = None
|
|
259
|
+
default_value: Optional[str] = None
|
|
260
|
+
title: Optional[str] = None
|
|
203
261
|
|
|
204
262
|
def __repr__(self):
|
|
205
|
-
return self.
|
|
263
|
+
return self.json()
|
|
206
264
|
|
|
207
265
|
|
|
208
266
|
@dataclass
|
|
209
|
-
class
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
267
|
+
class ButtonStringPicker(DataManager):
|
|
268
|
+
items: Optional[list[str]] = None
|
|
269
|
+
default_value: Optional[str] = None
|
|
270
|
+
title: Optional[str] = None
|
|
213
271
|
|
|
214
272
|
def __repr__(self):
|
|
215
|
-
return self.
|
|
273
|
+
return self.json()
|
|
216
274
|
|
|
217
275
|
|
|
218
276
|
@dataclass
|
|
219
|
-
class
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
277
|
+
class ButtonTextbox(DataManager):
|
|
278
|
+
type_line: Optional[enums.ButtonTextboxTypeLine] = None
|
|
279
|
+
type_keypad: Optional[enums.ButtonTextboxTypeKeypad] = None
|
|
280
|
+
place_holder: Optional[str] = None
|
|
281
|
+
title: Optional[str] = None
|
|
282
|
+
default_value: Optional[str] = None
|
|
225
283
|
|
|
226
284
|
def __repr__(self):
|
|
227
|
-
return self.
|
|
285
|
+
return self.json()
|
|
228
286
|
|
|
229
287
|
|
|
230
288
|
@dataclass
|
|
231
|
-
class
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
289
|
+
class ButtonLocation(DataManager):
|
|
290
|
+
default_pointer_location: Optional[Location] = None
|
|
291
|
+
default_map_location: Optional[Location] = None
|
|
292
|
+
type: Optional[enums.ButtonLocationType] = None
|
|
293
|
+
title: Optional[str] = None
|
|
294
|
+
location_image_url: Optional[str] = None
|
|
235
295
|
|
|
236
296
|
def __repr__(self):
|
|
237
|
-
return self.
|
|
297
|
+
return self.json()
|
|
238
298
|
|
|
239
299
|
|
|
240
300
|
@dataclass
|
|
241
|
-
class
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
current_location: Optional[Location] = None
|
|
245
|
-
user_id: Optional[str] = None
|
|
246
|
-
status: Optional[Literal["Stopped", "Live"]] = None
|
|
247
|
-
last_update_time: Optional[str] = None
|
|
301
|
+
class OpenChatData(DataManager):
|
|
302
|
+
object_guid: Optional[str] = None
|
|
303
|
+
object_type: Optional[enums.ChatType] = None
|
|
248
304
|
|
|
249
305
|
def __repr__(self):
|
|
250
|
-
return self.
|
|
306
|
+
return self.json()
|
|
251
307
|
|
|
252
308
|
|
|
253
309
|
@dataclass
|
|
254
|
-
class
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
poll_status: Optional[PollStatus] = None
|
|
310
|
+
class JoinChannelData(DataManager):
|
|
311
|
+
username: Optional[str] = None
|
|
312
|
+
ask_join: bool = False
|
|
258
313
|
|
|
259
314
|
def __repr__(self):
|
|
260
|
-
return self.
|
|
315
|
+
return self.json()
|
|
261
316
|
|
|
262
317
|
|
|
263
318
|
@dataclass
|
|
264
|
-
class
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
319
|
+
class ButtonLink(DataManager):
|
|
320
|
+
type: Optional[enums.ButtonLinkType] = None
|
|
321
|
+
link_url: Optional[str] = None
|
|
322
|
+
joinchannel_data: Optional[JoinChannelData] = None
|
|
323
|
+
open_chat_data: Optional[OpenChatData] = None
|
|
268
324
|
|
|
269
325
|
def __repr__(self):
|
|
270
|
-
return self.
|
|
326
|
+
return self.json()
|
|
271
327
|
|
|
272
328
|
|
|
273
329
|
@dataclass
|
|
274
|
-
class
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
emoji_character: Optional[str] = None
|
|
330
|
+
class AuxData(DataManager):
|
|
331
|
+
start_id: Optional[str] = None
|
|
332
|
+
button_id: Optional[str] = None
|
|
278
333
|
|
|
279
334
|
def __repr__(self):
|
|
280
|
-
return self.
|
|
335
|
+
return self.json()
|
|
281
336
|
|
|
282
337
|
|
|
283
338
|
@dataclass
|
|
284
|
-
class
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
339
|
+
class Button(DataManager):
|
|
340
|
+
id: Optional[str] = None
|
|
341
|
+
button_text: Optional[str] = None
|
|
342
|
+
type: enums.ButtonType = enums.ButtonType.Simple
|
|
343
|
+
button_selection: Optional[ButtonSelection] = None
|
|
344
|
+
button_calendar: Optional[ButtonCalendar] = None
|
|
345
|
+
button_number_picker: Optional[ButtonNumberPicker] = None
|
|
346
|
+
button_string_picker: Optional[ButtonStringPicker] = None
|
|
347
|
+
button_location: Optional[ButtonLocation] = None
|
|
348
|
+
button_textbox: Optional[ButtonTextbox] = None
|
|
349
|
+
button_link: Optional[ButtonLink] = None
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
@dataclass
|
|
353
|
+
class KeypadRow(DataManager):
|
|
354
|
+
buttons: list[Button]
|
|
289
355
|
|
|
290
356
|
def __repr__(self):
|
|
291
|
-
return self.
|
|
357
|
+
return self.json()
|
|
292
358
|
|
|
293
359
|
|
|
294
360
|
@dataclass
|
|
295
|
-
class
|
|
296
|
-
|
|
297
|
-
|
|
361
|
+
class Keypad(DataManager):
|
|
362
|
+
rows: list[KeypadRow]
|
|
363
|
+
resize_keyboard: bool = True
|
|
364
|
+
on_time_keyboard: bool = False
|
|
298
365
|
|
|
299
366
|
def __repr__(self):
|
|
300
|
-
return self.
|
|
367
|
+
return self.json()
|
|
301
368
|
|
|
302
369
|
|
|
303
370
|
@dataclass
|
|
304
|
-
class
|
|
305
|
-
|
|
306
|
-
|
|
371
|
+
class MessageKeypadUpdate(DataManager):
|
|
372
|
+
message_id: Optional[str] = None
|
|
373
|
+
inline_keypad: Optional[Keypad] = None
|
|
307
374
|
|
|
308
375
|
def __repr__(self):
|
|
309
|
-
return self.
|
|
376
|
+
return self.json()
|
|
310
377
|
|
|
311
378
|
|
|
312
379
|
@dataclass
|
|
313
|
-
class Message(
|
|
380
|
+
class Message(DataManager):
|
|
314
381
|
message_id: Optional[str] = None
|
|
315
382
|
text: Optional[str] = None
|
|
316
383
|
time: Optional[str] = None
|
|
317
384
|
is_edited: Optional[bool] = None
|
|
318
|
-
sender_type: Optional[
|
|
385
|
+
sender_type: Optional[enums.MessageSender] = None
|
|
319
386
|
sender_id: Optional[str] = None
|
|
320
387
|
aux_data: Optional[AuxData] = None
|
|
321
388
|
file: Optional[File] = None
|
|
@@ -329,98 +396,111 @@ class Message(Dict):
|
|
|
329
396
|
live_location: Optional[LiveLocation] = None
|
|
330
397
|
|
|
331
398
|
def __repr__(self):
|
|
332
|
-
return self.
|
|
399
|
+
return self.json()
|
|
333
400
|
|
|
334
401
|
|
|
335
402
|
@dataclass
|
|
336
|
-
class
|
|
337
|
-
client: Optional["rubigram.Client"] = None
|
|
338
|
-
sender_id: Optional[str] = None
|
|
339
|
-
text: Optional[str] = None
|
|
403
|
+
class MessageId(DataManager):
|
|
340
404
|
message_id: Optional[str] = None
|
|
405
|
+
file_id: Optional[str] = None
|
|
341
406
|
chat_id: Optional[str] = None
|
|
342
|
-
|
|
343
|
-
location: Optional[Location] = None
|
|
344
|
-
aux_data: Optional[AuxData] = None
|
|
407
|
+
client: Optional["rubigram.Client"] = None
|
|
345
408
|
|
|
346
409
|
def __repr__(self):
|
|
347
|
-
return self.
|
|
410
|
+
return self.json()
|
|
348
411
|
|
|
412
|
+
async def delete(self):
|
|
413
|
+
return await self.client.delete_message(self.chat_id, self.message_id)
|
|
349
414
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
bot_id: Optional[str] = None
|
|
353
|
-
bot_title: Optional[str] = None
|
|
354
|
-
avatar: Optional[File] = None
|
|
355
|
-
description: Optional[str] = None
|
|
356
|
-
username: Optional[str] = None
|
|
357
|
-
start_message: Optional[str] = None
|
|
358
|
-
share_url: Optional[str] = None
|
|
415
|
+
async def edit_text(self, text: str):
|
|
416
|
+
return await self.client.edit_message_text(self.chat_id, self.message_id, text)
|
|
359
417
|
|
|
360
|
-
def
|
|
361
|
-
return self.
|
|
418
|
+
async def edit_message_keypad(self, keypad: Keypad):
|
|
419
|
+
return await self.client.edit_message_keypad(self.chat_id, self.message_id, keypad)
|
|
362
420
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
class Chat(Dict):
|
|
366
|
-
chat_id: Optional[str] = None
|
|
367
|
-
chat_type: Optional[Literal["User", "Bot", "Group", "Channel"]] = None
|
|
368
|
-
user_id: Optional[str] = None
|
|
369
|
-
first_name: Optional[str] = None
|
|
370
|
-
last_name: Optional[str] = None
|
|
371
|
-
title: Optional[str] = None
|
|
372
|
-
username: Optional[str] = None
|
|
373
|
-
|
|
374
|
-
def __repr__(self):
|
|
375
|
-
return self.to_json()
|
|
421
|
+
async def forward(self, chat_id: str):
|
|
422
|
+
return await self.client.forward_message(self.chat_id, self.message_id, chat_id)
|
|
376
423
|
|
|
377
424
|
|
|
378
425
|
@dataclass
|
|
379
|
-
class
|
|
380
|
-
message_id: Optional[str] = None
|
|
381
|
-
|
|
382
|
-
def __repr__(self):
|
|
383
|
-
return self.to_json()
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
@dataclass
|
|
387
|
-
class Update(Dict):
|
|
426
|
+
class Update(DataManager):
|
|
388
427
|
client: Optional["rubigram.Client"] = None
|
|
389
|
-
type: Optional[
|
|
428
|
+
type: Optional[enums.UpdateType] = None
|
|
390
429
|
chat_id: Optional[str] = None
|
|
391
430
|
removed_message_id: Optional[str] = None
|
|
392
431
|
new_message: Optional[Message] = None
|
|
393
432
|
updated_message: Optional[Message] = None
|
|
394
433
|
updated_payment: Optional[PaymentStatus] = None
|
|
395
434
|
|
|
396
|
-
def
|
|
397
|
-
return self.
|
|
398
|
-
|
|
399
|
-
async def send_text(self, text: str,) -> "MessageId":
|
|
400
|
-
return await self.client.send_message(self.chat_id, text)
|
|
435
|
+
def __repr__(self):
|
|
436
|
+
return self.json()
|
|
401
437
|
|
|
402
|
-
async def download(self,
|
|
403
|
-
return await self.client.download_file(self.new_message.file.file_id,
|
|
438
|
+
async def download(self, file_name: str):
|
|
439
|
+
return await self.client.download_file(self.new_message.file.file_id, file_name)
|
|
404
440
|
|
|
405
441
|
async def reply(
|
|
406
442
|
self,
|
|
407
443
|
text: str,
|
|
408
444
|
chat_keypad: Keypad = None,
|
|
409
445
|
inline_keypad: Keypad = None,
|
|
410
|
-
chat_keypad_type:
|
|
446
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
411
447
|
disable_notification: bool = None,
|
|
412
448
|
) -> "MessageId":
|
|
413
449
|
return await self.client.send_message(self.chat_id, text, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
450
|
+
|
|
451
|
+
async def reply_poll(
|
|
452
|
+
self,
|
|
453
|
+
question: str,
|
|
454
|
+
options: list[str],
|
|
455
|
+
chat_keypad: Keypad = None,
|
|
456
|
+
inline_keypad: Keypad = None,
|
|
457
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
458
|
+
disable_notification: bool = False
|
|
459
|
+
) -> "MessageId":
|
|
460
|
+
return await self.client.send_poll(self.chat_id, question, options, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
461
|
+
|
|
462
|
+
async def reply_location(
|
|
463
|
+
self,
|
|
464
|
+
latitude: str,
|
|
465
|
+
longitude: str,
|
|
466
|
+
chat_keypad: Keypad = None,
|
|
467
|
+
inline_keypad: Keypad = None,
|
|
468
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
469
|
+
disable_notification: bool = False,
|
|
470
|
+
) -> "MessageId":
|
|
471
|
+
return await self.client.send_location(self.chat_id, latitude, longitude, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
472
|
+
|
|
473
|
+
async def reply_contact(
|
|
474
|
+
self,
|
|
475
|
+
first_name: str,
|
|
476
|
+
last_name: str,
|
|
477
|
+
phone_number: str,
|
|
478
|
+
chat_keypad: Keypad = None,
|
|
479
|
+
inline_keypad: Keypad = None,
|
|
480
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
481
|
+
disable_notification: bool = False,
|
|
482
|
+
) -> "MessageId":
|
|
483
|
+
return await self.client.send_location(self.chat_id, first_name, last_name, phone_number, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
484
|
+
|
|
485
|
+
async def reply_sticker(
|
|
486
|
+
self,
|
|
487
|
+
sticker_id: str,
|
|
488
|
+
chat_keypad: Keypad = None,
|
|
489
|
+
inline_keypad: Keypad = None,
|
|
490
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
491
|
+
disable_notification: bool = False,
|
|
492
|
+
) -> "MessageId":
|
|
493
|
+
return await self.client.send_message(self.chat_id, sticker_id, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
414
494
|
|
|
415
495
|
async def reply_file(
|
|
416
496
|
self,
|
|
417
497
|
file: str,
|
|
418
498
|
file_name: str,
|
|
419
499
|
caption: str = None,
|
|
420
|
-
type:
|
|
500
|
+
type: enums.FileType = enums.FileType.File,
|
|
421
501
|
chat_keypad: Keypad = None,
|
|
422
502
|
inline_keypad: Keypad = None,
|
|
423
|
-
chat_keypad_type:
|
|
503
|
+
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
424
504
|
disable_notification: bool = False,
|
|
425
505
|
) -> "MessageId":
|
|
426
506
|
return await self.client.send_file(self.chat_id, file, file_name, caption, type, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
|
|
@@ -445,9 +525,24 @@ class Update(Dict):
|
|
|
445
525
|
|
|
446
526
|
|
|
447
527
|
@dataclass
|
|
448
|
-
class Updates(
|
|
528
|
+
class Updates(DataManager):
|
|
449
529
|
updates: list[Update] = None
|
|
450
530
|
next_offset_id: Optional[str] = None
|
|
451
531
|
|
|
452
532
|
def __repr__(self):
|
|
453
|
-
return self.
|
|
533
|
+
return self.json()
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
@dataclass
|
|
537
|
+
class InlineMessage(DataManager):
|
|
538
|
+
client: Optional["rubigram.Client"] = None
|
|
539
|
+
sender_id: Optional[str] = None
|
|
540
|
+
text: Optional[str] = None
|
|
541
|
+
message_id: Optional[str] = None
|
|
542
|
+
chat_id: Optional[str] = None
|
|
543
|
+
file: Optional[File] = None
|
|
544
|
+
location: Optional[Location] = None
|
|
545
|
+
aux_data: Optional[AuxData] = None
|
|
546
|
+
|
|
547
|
+
def __repr__(self):
|
|
548
|
+
return self.json()
|