RubigramClient 1.6.4__py3-none-any.whl → 1.6.6__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/models.py DELETED
@@ -1,453 +0,0 @@
1
- from dataclasses import dataclass, fields, is_dataclass
2
- from typing import Any, Type, Union, TypeVar, Literal, Optional, get_origin, get_args
3
- import rubigram
4
- import json
5
-
6
-
7
- T = TypeVar("T", bound="Dict")
8
-
9
-
10
- @dataclass
11
- class Dict:
12
- def to_dict(self) -> dict[str, Any]:
13
- data = {}
14
- for field in fields(self):
15
- value = getattr(self, field.name)
16
- if is_dataclass(value):
17
- data[field.name] = value.to_dict()
18
- elif isinstance(value, list):
19
- data[field.name] = [i.to_dict() if is_dataclass(i)else i for i in value]
20
- else:
21
- data[field.name] = value
22
- return data
23
-
24
- @classmethod
25
- def from_dict(cls: Type[T], data: dict[str, Any]) -> Optional[T]:
26
- if data is None:
27
- data = {}
28
- init_data = {}
29
- for field in fields(cls):
30
- value = data.get(field.name)
31
- field_type = field.type
32
- origin = get_origin(field_type)
33
- if isinstance(value, dict) and isinstance(field_type, type) and issubclass(field_type, Dict):
34
- init_data[field.name] = field_type.from_dict(value)
35
- elif origin == list:
36
- inner_type = get_args(field_type)[0]
37
- if isinstance(inner_type, type) and issubclass(inner_type, Dict):
38
- init_data[field.name] = [inner_type.from_dict(
39
- v) if isinstance(v, dict) else v for v in (value or [])]
40
- else:
41
- init_data[field.name] = value or []
42
- elif get_origin(field_type) is Union:
43
- args = get_args(field_type)
44
- dict_type = next((a for a in args if isinstance(
45
- a, type) and issubclass(a, Dict)), None)
46
- if dict_type and isinstance(value, dict):
47
- init_data[field.name] = dict_type.from_dict(value)
48
- else:
49
- init_data[field.name] = value
50
- else:
51
- init_data[field.name] = value
52
- return cls(**init_data)
53
-
54
- def to_json(self):
55
- data = self.to_dict().copy()
56
- data.pop("client", None)
57
- return json.dumps(data, ensure_ascii=False, indent=4)
58
-
59
-
60
- @dataclass
61
- class Location(Dict):
62
- longitude: Optional[str] = None
63
- latitude: Optional[str] = None
64
-
65
- def __repr__(self):
66
- return self.to_json()
67
-
68
-
69
- @dataclass
70
- class OpenChatData(Dict):
71
- object_guid: Optional[str] = None
72
- object_type: Optional[Literal["User", "Bot", "Group", "Channel"]] = None
73
-
74
- def __repr__(self):
75
- return self.to_json()
76
-
77
-
78
- @dataclass
79
- class JoinChannelData(Dict):
80
- username: Optional[str] = None
81
- ask_join: Optional[bool] = False
82
-
83
- def __repr__(self):
84
- return self.to_json()
85
-
86
-
87
- @dataclass
88
- class ButtonLink(Dict):
89
- type: Optional[Literal["joinchannel", "url"]] = None
90
- link_url: Optional[str] = None
91
- joinchannel_data: Optional[JoinChannelData] = None
92
- open_chat_data: Optional[OpenChatData] = None
93
-
94
- def __repr__(self):
95
- return self.to_json()
96
-
97
-
98
- @dataclass
99
- class ButtonSelectionItem(Dict):
100
- text: Optional[str] = None
101
- image_url: Optional[str] = None
102
- type: Optional[Literal["TextOnly", "TextImgThu", "TextImgBig"]] = None
103
-
104
- def __repr__(self):
105
- return self.to_json()
106
-
107
-
108
- @dataclass
109
- class ButtonTextbox(Dict):
110
- type_line: Optional[Literal["SingleLine", "MultiLine"]] = None
111
- type_keypad: Optional[Literal["String", "Number"]] = None
112
- place_holder: Optional[str] = None
113
- title: Optional[str] = None
114
- default_value: Optional[str] = None
115
-
116
- def __repr__(self):
117
- return self.to_json()
118
-
119
-
120
- @dataclass
121
- class ButtonLocation(Dict):
122
- default_pointer_location: Optional[Location] = None
123
- default_map_location: Optional[Location] = None
124
- type: Optional[Literal["Picker", "View"]] = None
125
- title: Optional[str] = None
126
- location_image_url: Optional[str] = None
127
-
128
- def __repr__(self):
129
- return self.to_json()
130
-
131
-
132
- @dataclass
133
- class ButtonStringPicker(Dict):
134
- items: Optional[list[str]] = None
135
- default_value: Optional[str] = None
136
- title: Optional[str] = None
137
-
138
- def __repr__(self):
139
- return self.to_json()
140
-
141
-
142
- @dataclass
143
- class ButtonNumberPicker(Dict):
144
- min_value: Optional[str] = None
145
- max_value: Optional[str] = None
146
- default_value: Optional[str] = None
147
- title: Optional[str] = None
148
-
149
- def __repr__(self):
150
- return self.to_json()
151
-
152
-
153
- @dataclass
154
- class ButtonCalendar(Dict):
155
- default_value: Optional[str] = None
156
- type: Optional[Literal["DatePersian", "DateGregorian"]] = None
157
- min_year: Optional[str] = None
158
- max_year: Optional[str] = None
159
- title: Optional[str] = None
160
-
161
- def __repr__(self):
162
- return self.to_json()
163
-
164
-
165
- @dataclass
166
- class ButtonSelection(Dict):
167
- selection_id: Optional[str] = None
168
- search_type: Optional[str] = None
169
- get_type: Optional[str] = None
170
- items: Optional[list[ButtonSelectionItem]] = None
171
- is_multi_selection: Optional[bool] = None
172
- columns_count: Optional[str] = None
173
- title: Optional[str] = None
174
-
175
- def __repr__(self):
176
- return self.to_json()
177
-
178
-
179
- @dataclass
180
- class Button(Dict):
181
- id: Optional[str] = None
182
- button_text: Optional[str] = None
183
- type: Literal[
184
- "Simple", "Selection", "Calendar", "NumberPicker", "StringPicker", "Location", "Payment",
185
- "CameraImage", "CameraVideo", "GalleryImage", "GalleryVideo", "File", "Audio", "RecordAudio",
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
195
-
196
- def __repr__(self):
197
- return self.to_json()
198
-
199
-
200
- @dataclass
201
- class KeypadRow(Dict):
202
- buttons: list[Button]
203
-
204
- def __repr__(self):
205
- return self.to_json()
206
-
207
-
208
- @dataclass
209
- class Keypad(Dict):
210
- rows: list[KeypadRow]
211
- resize_keyboard: bool = True
212
- on_time_keyboard: bool = False
213
-
214
- def __repr__(self):
215
- return self.to_json()
216
-
217
-
218
- @dataclass
219
- class PollStatus(Dict):
220
- state: Optional[Literal["Open", "Closed"]] = None
221
- selection_index: Optional[int] = None
222
- percent_vote_options: Optional[list[int]] = None
223
- total_vote: Optional[int] = None
224
- show_total_votes: Optional[bool] = None
225
-
226
- def __repr__(self):
227
- return self.to_json()
228
-
229
-
230
- @dataclass
231
- class File(Dict):
232
- file_id: Optional[str] = None
233
- file_name: Optional[str] = None
234
- size: Optional[str] = None
235
-
236
- def __repr__(self):
237
- return self.to_json()
238
-
239
-
240
- @dataclass
241
- class LiveLocation(Dict):
242
- start_time: Optional[str] = None
243
- live_period: Optional[int] = None
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
248
-
249
- def __repr__(self):
250
- return self.to_json()
251
-
252
-
253
- @dataclass
254
- class Poll(Dict):
255
- question: Optional[str] = None
256
- options: Optional[list[str]] = None
257
- poll_status: Optional[PollStatus] = None
258
-
259
- def __repr__(self):
260
- return self.to_json()
261
-
262
-
263
- @dataclass
264
- class ContactMessage(Dict):
265
- phone_number: Optional[str] = None
266
- first_name: Optional[str] = None
267
- last_name: Optional[str] = None
268
-
269
- def __repr__(self):
270
- return self.to_json()
271
-
272
-
273
- @dataclass
274
- class Sticker(Dict):
275
- sticker_id: Optional[str] = None
276
- file: Optional[File] = None
277
- emoji_character: Optional[str] = None
278
-
279
- def __repr__(self):
280
- return self.to_json()
281
-
282
-
283
- @dataclass
284
- class ForwardedFrom(Dict):
285
- type_from: Optional[Literal["User", "Channel", "Bot"]] = None
286
- message_id: Optional[str] = None
287
- from_chat_id: Optional[str] = None
288
- from_sender_id: Optional[str] = None
289
-
290
- def __repr__(self):
291
- return self.to_json()
292
-
293
-
294
- @dataclass
295
- class AuxData(Dict):
296
- start_id: Optional[str] = None
297
- button_id: Optional[str] = None
298
-
299
- def __repr__(self):
300
- return self.to_json()
301
-
302
-
303
- @dataclass
304
- class PaymentStatus(Dict):
305
- payment_id: Optional[str] = None
306
- status: Optional[Literal["Paid", "NotPaid"]] = None
307
-
308
- def __repr__(self):
309
- return self.to_json()
310
-
311
-
312
- @dataclass
313
- class Message(Dict):
314
- message_id: Optional[str] = None
315
- text: Optional[str] = None
316
- time: Optional[str] = None
317
- is_edited: Optional[bool] = None
318
- sender_type: Optional[Literal["User", "Bot"]] = None
319
- sender_id: Optional[str] = None
320
- aux_data: Optional[AuxData] = None
321
- file: Optional[File] = None
322
- reply_to_message_id: Optional[str] = None
323
- forwarded_from: Optional[ForwardedFrom] = None
324
- forwarded_no_link: Optional[str] = None
325
- location: Optional[Location] = None
326
- sticker: Optional[Sticker] = None
327
- contact_message: Optional[ContactMessage] = None
328
- poll: Optional[Poll] = None
329
- live_location: Optional[LiveLocation] = None
330
-
331
- def __repr__(self):
332
- return self.to_json()
333
-
334
-
335
- @dataclass
336
- class InlineMessage(Dict):
337
- client: Optional["rubigram.Client"] = None
338
- sender_id: Optional[str] = None
339
- text: Optional[str] = None
340
- message_id: Optional[str] = None
341
- chat_id: Optional[str] = None
342
- file: Optional[File] = None
343
- location: Optional[Location] = None
344
- aux_data: Optional[AuxData] = None
345
-
346
- def __repr__(self):
347
- return self.to_json()
348
-
349
-
350
- @dataclass
351
- class Bot(Dict):
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
359
-
360
- def __repr__(self):
361
- return self.to_json()
362
-
363
-
364
- @dataclass
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()
376
-
377
-
378
- @dataclass
379
- class MessageId(Dict):
380
- message_id: Optional[str] = None
381
-
382
- def __repr__(self):
383
- return self.to_json()
384
-
385
-
386
- @dataclass
387
- class Update(Dict):
388
- client: Optional["rubigram.Client"] = None
389
- type: Optional[Literal["NewMessage", "UpdatedMessage", "RemovedMessage", "StartedBot", "StoppedBot", "UpdatedPayment"]] = None
390
- chat_id: Optional[str] = None
391
- removed_message_id: Optional[str] = None
392
- new_message: Optional[Message] = None
393
- updated_message: Optional[Message] = None
394
- updated_payment: Optional[PaymentStatus] = None
395
-
396
- def __str__(self):
397
- return self.to_json()
398
-
399
- async def send_text(self, text: str,) -> "MessageId":
400
- return await self.client.send_message(self.chat_id, text)
401
-
402
- async def download(self, name: str):
403
- return await self.client.download_file(self.new_message.file.file_id, name)
404
-
405
- async def reply(
406
- self,
407
- text: str,
408
- chat_keypad: Keypad = None,
409
- inline_keypad: Keypad = None,
410
- chat_keypad_type: Literal["New", "Remove"] = None,
411
- disable_notification: bool = None,
412
- ) -> "MessageId":
413
- return await self.client.send_message(self.chat_id, text, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
414
-
415
- async def reply_file(
416
- self,
417
- file: str,
418
- file_name: str,
419
- caption: str = None,
420
- type: Literal["File", "Image", "Voice", "Music", "Gif", "Video"] = "File",
421
- chat_keypad: Keypad = None,
422
- inline_keypad: Keypad = None,
423
- chat_keypad_type: Literal["New", "Remove"] = None,
424
- disable_notification: bool = False,
425
- ) -> "MessageId":
426
- 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)
427
-
428
- async def reply_document(self, document: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
429
- return await self.reply_file(document, name, caption, "File", **kwargs)
430
-
431
- async def reply_photo(self, photo: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
432
- return await self.reply_file(photo, name, caption, "Image", **kwargs)
433
-
434
- async def reply_video(self, video: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
435
- return await self.reply_file(video, name, caption, "Video", **kwargs)
436
-
437
- async def reply_gif(self, gif: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
438
- return await self.reply_file(gif, name, caption, "Gif", **kwargs)
439
-
440
- async def reply_music(self, music: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
441
- return await self.reply_file(music, name, caption, "Music", **kwargs)
442
-
443
- async def reply_voice(self, voice: str, name: str, caption: Optional[str] = None, **kwargs) -> "MessageId":
444
- return await self.reply_file(voice, name, caption, "Voice", **kwargs)
445
-
446
-
447
- @dataclass
448
- class Updates(Dict):
449
- updates: list[Update] = None
450
- next_offset_id: Optional[str] = None
451
-
452
- def __repr__(self):
453
- return self.to_json()
@@ -1,12 +0,0 @@
1
- rubigram/__init__.py,sha256=IWNCN7oDaIBzaP54cGiA-4Sa31ehGBlqj0SuqhNQVgU,162
2
- rubigram/client.py,sha256=IWDzhie2l4kfBaIhHFjOwbV4yZKPWctcE5eqVpLteMM,4900
3
- rubigram/filters.py,sha256=JN2p4Aff6A-scEfV3c_KIDRp9gr47FSgOaY_YiJ4tWY,6584
4
- rubigram/method.py,sha256=R4IkK-CJmgyfBiX68VemUMzkOYM1e0j12VYAVuKBbMM,10645
5
- rubigram/models.py,sha256=42WK68VPKqgKCy14jrRyoP_XRsZ-04S5rUbdpO_UfaQ,13831
6
- rubigram/network.py,sha256=84-2Grde0GUDOpia6O-7oJNlupBw30ga5VE4sve31dY,2361
7
- rubigram/state.py,sha256=BxeKMh2aEyAYJu6VluZBwJAkHoF06r_VWeclHPWubI4,4054
8
- rubigramclient-1.6.4.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- rubigramclient-1.6.4.dist-info/METADATA,sha256=kHEqF0Yr6hfg7J0exUwjVDGthznyU84tU6ROXTUmWM8,2280
10
- rubigramclient-1.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- rubigramclient-1.6.4.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
12
- rubigramclient-1.6.4.dist-info/RECORD,,