RubigramClient 1.7.0__py3-none-any.whl → 1.7.2__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 +1 -5
- rubigram/client.py +102 -154
- rubigram/enums.py +4 -3
- rubigram/filters.py +600 -139
- rubigram/handler.py +24 -0
- rubigram/http.py +32 -0
- rubigram/logger.py +20 -0
- rubigram/method/__init__.py +18 -0
- rubigram/method/chat/__init__.py +10 -0
- rubigram/method/chat/get_chat.py +26 -0
- rubigram/method/chat/get_me.py +22 -0
- rubigram/method/chat/get_update.py +32 -0
- rubigram/method/decorator/__init__.py +8 -0
- rubigram/method/decorator/on_delete_message.py +37 -0
- rubigram/method/decorator/on_edit_message.py +37 -0
- rubigram/method/decorator/on_inline_message.py +40 -0
- rubigram/method/decorator/on_message.py +38 -0
- rubigram/method/decorator/on_start.py +30 -0
- rubigram/method/decorator/on_stop.py +29 -0
- rubigram/method/decorator/register.py +43 -0
- rubigram/method/file/__init__.py +32 -0
- rubigram/method/file/download_file.py +34 -0
- rubigram/method/file/get_bytes.py +25 -0
- rubigram/method/file/get_file.py +27 -0
- rubigram/method/file/get_file_name.py +29 -0
- rubigram/method/file/request_download_file.py +35 -0
- rubigram/method/file/request_send_file.py +28 -0
- rubigram/method/file/request_upload_file.py +62 -0
- rubigram/method/file/send_document.py +58 -0
- rubigram/method/file/send_file.py +78 -0
- rubigram/method/file/send_gif.py +58 -0
- rubigram/method/file/send_music.py +58 -0
- rubigram/method/file/send_photo.py +58 -0
- rubigram/method/file/send_video.py +58 -0
- rubigram/method/file/send_voice.py +55 -0
- rubigram/method/messages/__init__.py +29 -0
- rubigram/method/messages/delete_message.py +50 -0
- rubigram/method/messages/edit_chat_keypad.py +34 -0
- rubigram/method/messages/edit_message.py +41 -0
- rubigram/method/messages/edit_message_keypad.py +38 -0
- rubigram/method/messages/edit_message_text.py +34 -0
- rubigram/method/messages/forward_message.py +43 -0
- rubigram/method/messages/remove_chat_keypad.py +28 -0
- rubigram/method/messages/send_contact.py +74 -0
- rubigram/method/messages/send_location.py +70 -0
- rubigram/method/messages/send_message.py +67 -0
- rubigram/method/messages/send_poll.py +71 -0
- rubigram/method/messages/send_sticker.py +66 -0
- rubigram/method/network/__init__.py +7 -0
- rubigram/method/network/request.py +20 -0
- rubigram/method/setting/__init__.py +9 -0
- rubigram/method/setting/set_command.py +32 -0
- rubigram/method/setting/update_bot_endpoint.py +31 -0
- rubigram/method/utilities/__init__.py +11 -0
- rubigram/method/utilities/dispatch.py +25 -0
- rubigram/method/utilities/setup_endpoint.py +16 -0
- rubigram/method/utilities/updater.py +17 -0
- rubigram/state.py +14 -19
- rubigram/types/__init__.py +3 -0
- rubigram/types/messages.py +175 -0
- rubigram/types/object.py +112 -0
- rubigram/types/types.py +211 -0
- rubigram/types/updates.py +572 -0
- {rubigramclient-1.7.0.dist-info → rubigramclient-1.7.2.dist-info}/METADATA +12 -8
- rubigramclient-1.7.2.dist-info/RECORD +68 -0
- rubigram/method.py +0 -354
- rubigram/network.py +0 -80
- rubigram/rubino/__init__.py +0 -1
- rubigram/rubino/client.py +0 -480
- rubigram/types.py +0 -538
- rubigramclient-1.7.0.dist-info/RECORD +0 -15
- {rubigramclient-1.7.0.dist-info → rubigramclient-1.7.2.dist-info}/WHEEL +0 -0
- {rubigramclient-1.7.0.dist-info → rubigramclient-1.7.2.dist-info}/licenses/LICENSE +0 -0
- {rubigramclient-1.7.0.dist-info → rubigramclient-1.7.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
rubigram/__init__.py,sha256=sn1Rt8Wy0xALHUfuJ3UItSBmFxQniBAOkwFIrifO7-E,63
|
|
2
|
+
rubigram/client.py,sha256=LCjXLbnpj-A6sHA-hK9--Q-pttrGtXrjNePbuC2yR7g,4638
|
|
3
|
+
rubigram/enums.py,sha256=vsqi2z5oh88ld84uu8JacQuuUbO-3yAbnvcpVXu7r_U,2831
|
|
4
|
+
rubigram/filters.py,sha256=yBpXgBBLfdmYATdgG3CArWgjQkavhYsk4KxPQTK--uk,22520
|
|
5
|
+
rubigram/handler.py,sha256=8Odr47k4plVsxDM4XWx8KBH5Jra6EaC8CqwMOxqZ8SI,579
|
|
6
|
+
rubigram/http.py,sha256=sOb8Dge0Cumrqq7LANLQ9PyJcHcQepWgsrjjfC0yol4,947
|
|
7
|
+
rubigram/logger.py,sha256=laZsNXUO_xQLLBgi-fgdgcJK05Fo5icOHe_mbib6ggg,595
|
|
8
|
+
rubigram/state.py,sha256=A9HV4WC8pCvwyhUtnPjZo3sC7ANxdlaoqgoia08YGgo,948
|
|
9
|
+
rubigram/method/__init__.py,sha256=Hi7S1TKYRtYRPGFxP5UNp4xPQR0ItO3Yqbv344Og6NI,331
|
|
10
|
+
rubigram/method/chat/__init__.py,sha256=96XDMbiM8EtjsN5mflWNJYwwR5kEXUQHYnXgDG38TbA,163
|
|
11
|
+
rubigram/method/chat/get_chat.py,sha256=13ya3lsZXVlRKCHRprMQVpW3ulhyCJVJvcDlApQFsfI,782
|
|
12
|
+
rubigram/method/chat/get_me.py,sha256=TB5SrB76ipJKN5xvFB5IXSzHV2fpzjIwm14mV4GoXi4,749
|
|
13
|
+
rubigram/method/chat/get_update.py,sha256=1DTZA8tY1xn-5f13hnvruuF7NfQeYi6gWlF9E5_HL9U,1158
|
|
14
|
+
rubigram/method/decorator/__init__.py,sha256=4t4VbkZvoywmWZDeumU40WAXFdAzTT3_dsyld5biXNE,129
|
|
15
|
+
rubigram/method/decorator/on_delete_message.py,sha256=X4FQ4qtu_HcLGrgvB2Bx-PmjD-XeDh3zuc9IzJUhCJY,1407
|
|
16
|
+
rubigram/method/decorator/on_edit_message.py,sha256=paxlFV5huK7QShZP6M41WsjCPUS_Wj2RGp9hBrkapkM,1382
|
|
17
|
+
rubigram/method/decorator/on_inline_message.py,sha256=GByo-f4LsdHD9Iai-4VlEP2tnFU9-qljB9VP363ggW0,1455
|
|
18
|
+
rubigram/method/decorator/on_message.py,sha256=8v5aAoff2deONTL5SzHpA8pcyL4SIsKa2HehZVoKBs4,1376
|
|
19
|
+
rubigram/method/decorator/on_start.py,sha256=2T0qImfwS2YhRoT_L5yVbyps1YCs3mikq4CRMuAFEb0,976
|
|
20
|
+
rubigram/method/decorator/on_stop.py,sha256=uUjIIsKOw8lwDTW1eUatsZAD9zYzj4DyXGNVvlqgTkA,935
|
|
21
|
+
rubigram/method/decorator/register.py,sha256=t0vWgapNEU0IQErhfeZoV1ghPcA3D2zHJcpaSoQI-6Y,1717
|
|
22
|
+
rubigram/method/file/__init__.py,sha256=KBOWQE7MrDZ51i-VYkxJ-5wqYslkS1XbSnbgWKHU4FE,822
|
|
23
|
+
rubigram/method/file/download_file.py,sha256=6k6DfZbAAgQBfoPMnqN3CHOneF-jtB9fuKnckyTG834,1216
|
|
24
|
+
rubigram/method/file/get_bytes.py,sha256=rIRQAF_NIF388A33-IROLFUt50MgoQ_92QAXFmfEeIE,754
|
|
25
|
+
rubigram/method/file/get_file.py,sha256=5-TtwjiQw_KaKVn6y0poW5H73NvEybCJyT2C73taCsY,784
|
|
26
|
+
rubigram/method/file/get_file_name.py,sha256=9kz6Tuyz3WSOgNLeUpKFzcqohBS-AAoklTo9lnRkxEU,834
|
|
27
|
+
rubigram/method/file/request_download_file.py,sha256=hkP6SslKZ6Ijv4b04weX4rtQjxcH22_QJtEQfYXdpVU,1103
|
|
28
|
+
rubigram/method/file/request_send_file.py,sha256=9cuMvA6YVih8yqEzVAhzve6NWUpoznnAbtNq34qFF5A,883
|
|
29
|
+
rubigram/method/file/request_upload_file.py,sha256=J__u6IZce6rXtnfL42WHNn7RwoQIh56FJ1falzlw7y0,2264
|
|
30
|
+
rubigram/method/file/send_document.py,sha256=5i9pvizZd2VwyeG_nSv1LUDqNjhWAwbJKhM_FMVExOU,2731
|
|
31
|
+
rubigram/method/file/send_file.py,sha256=p-TcElAKtbEgISYC6SdXq03pJyARH8p3mDO2KFMR14s,3387
|
|
32
|
+
rubigram/method/file/send_gif.py,sha256=84IAoWbPJO0BoJXVc5ers3Y2WLG6Fs55lOIli6DokDo,2666
|
|
33
|
+
rubigram/method/file/send_music.py,sha256=Bg084LDQOEWDTdp22htgT4FiKPPg-iTfNAjHm0CWauQ,2702
|
|
34
|
+
rubigram/method/file/send_photo.py,sha256=J8Duj37e02LVc0RL1Xy86mkuQuL5rPgipXpQoxON8F4,2730
|
|
35
|
+
rubigram/method/file/send_video.py,sha256=kX2pUVvy3nZ8chfe02m376ABxtdcW6UI30OKJDYbU5o,2725
|
|
36
|
+
rubigram/method/file/send_voice.py,sha256=omGtXeXl-SXFSN0V0bKxesmcLAfSH-SZZM6BWhuqZk0,2544
|
|
37
|
+
rubigram/method/messages/__init__.py,sha256=dpWTrOohcZ8eJk7jTdMmcPNt_rYfiNN7exnLlTyHRbQ,782
|
|
38
|
+
rubigram/method/messages/delete_message.py,sha256=ABWasWR5UaQ2HgdTd4WNmumoF5FIJuhR9ZXVqMnKW5s,1540
|
|
39
|
+
rubigram/method/messages/edit_chat_keypad.py,sha256=VkF1cuOGAbHVkXieP9MDaRjCsWQzMqgge54RFCorvDk,1126
|
|
40
|
+
rubigram/method/messages/edit_message.py,sha256=fne5WPXYV29_aeU16VLVo6gHYXbsaGuEzvpE17KGcoI,1785
|
|
41
|
+
rubigram/method/messages/edit_message_keypad.py,sha256=KQ0I3Rf8jt3RcOrfYNQA_OrfAg1DEDYably-8Zq_mX0,1439
|
|
42
|
+
rubigram/method/messages/edit_message_text.py,sha256=5NJ-WpC-hgExYMuKUzcI_d7VYLqTiBzB3KpJQY1SsDQ,1092
|
|
43
|
+
rubigram/method/messages/forward_message.py,sha256=ZlPDVDi7XG5boLgTsM9X2gP80E0aSvJ-pX21fGuhJKM,1694
|
|
44
|
+
rubigram/method/messages/remove_chat_keypad.py,sha256=eL4ebghrVnnIZp5zrCqJiZAPQQM0PcSOdcW5yF1bZHM,805
|
|
45
|
+
rubigram/method/messages/send_contact.py,sha256=9kBbmLqA8RtCC1jSE1RcomdL6ThxbsauXSijWMnwbc8,3140
|
|
46
|
+
rubigram/method/messages/send_location.py,sha256=np4AoCRsFYoNmJfuIMAUw3GIChGebeWdYTxk9fw6pY0,2974
|
|
47
|
+
rubigram/method/messages/send_message.py,sha256=Pb3NhbbCPDTxKim93R_vI1jidGDWecA_aVLGne4J-Sg,2874
|
|
48
|
+
rubigram/method/messages/send_poll.py,sha256=u3QUY-fciE7VkYd6neNaC0F3tXggFCfIoyypoNKdznY,3043
|
|
49
|
+
rubigram/method/messages/send_sticker.py,sha256=DAG9EpTjl-U2chD9Hjxw9aVSkzysA2VjtMs_5GtAm30,2843
|
|
50
|
+
rubigram/method/network/__init__.py,sha256=Vp7CyfWgU0AmkEWXwWkpXKPlB3h_7rWpgwY0baQ0pIs,75
|
|
51
|
+
rubigram/method/network/request.py,sha256=ECBAygYsoKiT8DQgUqCrjZFHLacG0358CX43Udu7VV8,570
|
|
52
|
+
rubigram/method/setting/__init__.py,sha256=fc29gUps7yI6cQDDwhLfVprE3oOXEq2IjDFcWiwrHEg,165
|
|
53
|
+
rubigram/method/setting/set_command.py,sha256=kg16vacEUoLdJ4gALIhVzjg0NGxetIrTfyq8NkDUBZI,933
|
|
54
|
+
rubigram/method/setting/update_bot_endpoint.py,sha256=SEFngT5LvYbPQ7w2aPbQy75MOdEfyn6ixmTsEWygu2I,972
|
|
55
|
+
rubigram/method/utilities/__init__.py,sha256=F098uwyxCHhtfxgvQnCzS4GTPywMlFbPdWHC-DPS5fU,189
|
|
56
|
+
rubigram/method/utilities/dispatch.py,sha256=f30aBDwcfYig4HFQ88msdtIZVcpm0YFWQL5KkFk7K-A,805
|
|
57
|
+
rubigram/method/utilities/setup_endpoint.py,sha256=BypRjeg4ECX6xf72-mNZ6DTW99GVRlwAIPeZJ9Dycmo,539
|
|
58
|
+
rubigram/method/utilities/updater.py,sha256=bGmu7PdFDRYAWckPXCAjtS0M-3DcOO8zB4draVDp_2Q,438
|
|
59
|
+
rubigram/types/__init__.py,sha256=i5VL2yv2HlyQdQdx2Qxv0Y3luT5GYVnYuI5Vm7MtvSg,69
|
|
60
|
+
rubigram/types/messages.py,sha256=Go5LVw9kX-7FrxRpxK3S2sS-427zCbtg_2Q3CNdZc-0,5744
|
|
61
|
+
rubigram/types/object.py,sha256=UhzOrPTsLrLv9pWVwiyWbaXqwAeNJczQ0cBsf0bHPU0,4139
|
|
62
|
+
rubigram/types/types.py,sha256=ti-JGIxhEvjl8hwfIucJkW_PDorh2gDCDUtVMYofT78,5744
|
|
63
|
+
rubigram/types/updates.py,sha256=HDAJaA8bg9GwbGXSDSwAZ5JFyDwAhVxAXByv4pIGvGA,23624
|
|
64
|
+
rubigramclient-1.7.2.dist-info/licenses/LICENSE,sha256=W2bekuLJMG2c-8SvTkJflMF5wY_Mx6rsXfXoCQvRzOI,1081
|
|
65
|
+
rubigramclient-1.7.2.dist-info/METADATA,sha256=W9_gUkK4KnNWXLDFEqDxN5MV_WgEd6Phk2m4lHX10nI,4550
|
|
66
|
+
rubigramclient-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
67
|
+
rubigramclient-1.7.2.dist-info/top_level.txt,sha256=Mhg5HfkL6rLec5sI4ClGmwoqYUANAZUz8sVa1sT_cas,9
|
|
68
|
+
rubigramclient-1.7.2.dist-info/RECORD,,
|
rubigram/method.py
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
from .network import Network
|
|
2
|
-
from rubigram import enums
|
|
3
|
-
from typing import Optional, Union
|
|
4
|
-
from rubigram.types import Bot, Chat, Keypad, MessageId, Updates, BotCommand
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Method(Network):
|
|
8
|
-
def __init__(self, token: str):
|
|
9
|
-
super().__init__(token)
|
|
10
|
-
|
|
11
|
-
def clean_data(self, data: dict):
|
|
12
|
-
return {key: value for key, value in data.items() if value is not None}
|
|
13
|
-
|
|
14
|
-
async def get_me(self) -> "Bot":
|
|
15
|
-
response = await self.request("getMe", {})
|
|
16
|
-
return Bot.from_dict(response["bot"])
|
|
17
|
-
|
|
18
|
-
async def get_chat(self, chat_id: str) -> "Chat":
|
|
19
|
-
response = await self.request("getChat", {"chat_id": chat_id})
|
|
20
|
-
return Chat.from_dict(response["chat"])
|
|
21
|
-
|
|
22
|
-
async def get_update(self, limit: int = 1, offset_id: Optional[int] = None) -> "Updates":
|
|
23
|
-
response = await self.request("getUpdates", {"limit": limit, "offset_id": offset_id})
|
|
24
|
-
return Updates.from_dict(response)
|
|
25
|
-
|
|
26
|
-
async def get_file(self, file_id: str) -> str:
|
|
27
|
-
response = await self.request("getFile", {"file_id": file_id})
|
|
28
|
-
return response["download_url"]
|
|
29
|
-
|
|
30
|
-
async def set_command(self, commands: list[BotCommand]):
|
|
31
|
-
response = await self.request("setCommands", {"bot_commands": [command.asdict() for command in commands]})
|
|
32
|
-
return response
|
|
33
|
-
|
|
34
|
-
async def update_bot_endpoint(self, url: str, type: enums.UpdateEndpointType):
|
|
35
|
-
response = await self.request("updateBotEndpoints", {"url": url, "type": type})
|
|
36
|
-
return response
|
|
37
|
-
|
|
38
|
-
async def delete_message(self, chat_id: str, message_id: str):
|
|
39
|
-
return await self.request("deleteMessage", {"chat_id": chat_id, "message_id": message_id})
|
|
40
|
-
|
|
41
|
-
async def remove_chat_keypad(self, chat_id: str):
|
|
42
|
-
return await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "Remove"})
|
|
43
|
-
|
|
44
|
-
async def edit_chat_keypad(self, chat_id: str, chat_keypad: Keypad):
|
|
45
|
-
return await self.request("editChatKeypad", {"chat_id": chat_id, "chat_keypad_type": "New", "chat_keypad": chat_keypad.asdict()})
|
|
46
|
-
|
|
47
|
-
async def edit_message_keypad(self, chat_id: str, message_id: str, inline_keypad: Keypad):
|
|
48
|
-
return await self.request("editMessageKeypad", {"chat_id": chat_id, "message_id": message_id, "inline_keypad": inline_keypad.asdict()})
|
|
49
|
-
|
|
50
|
-
async def edit_message_text(self, chat_id: str, message_id: str, text: str):
|
|
51
|
-
return await self.request("editMessageText", {"chat_id": chat_id, "message_id": message_id, "text": text})
|
|
52
|
-
|
|
53
|
-
async def edit_message(
|
|
54
|
-
self,
|
|
55
|
-
chat_id: str,
|
|
56
|
-
message_id: str,
|
|
57
|
-
text: Optional[str] = None,
|
|
58
|
-
chat_keypad: Optional[Keypad] = None,
|
|
59
|
-
inline_keypad: Optional[Keypad] = None
|
|
60
|
-
):
|
|
61
|
-
if text:
|
|
62
|
-
await self.edit_message_text(chat_id, message_id, text)
|
|
63
|
-
if chat_keypad:
|
|
64
|
-
await self.edit_chat_keypad(chat_id, chat_keypad)
|
|
65
|
-
if inline_keypad:
|
|
66
|
-
await self.edit_message_keypad(chat_id, message_id, inline_keypad)
|
|
67
|
-
|
|
68
|
-
async def forward_message(self, from_chat_id: str, message_id: str, to_chat_id: str, disable_notification: bool = False) -> "MessageId":
|
|
69
|
-
data = {"from_chat_id": from_chat_id, "message_id": message_id, "to_chat_id": to_chat_id, "disable_notification": disable_notification}
|
|
70
|
-
response = await self.request("forwardMessage", data)
|
|
71
|
-
message = MessageId.from_dict(response)
|
|
72
|
-
message.chat_id = to_chat_id
|
|
73
|
-
message.client = self
|
|
74
|
-
return message
|
|
75
|
-
|
|
76
|
-
async def send_message(
|
|
77
|
-
self,
|
|
78
|
-
chat_id: str,
|
|
79
|
-
text: str,
|
|
80
|
-
chat_keypad: Keypad = None,
|
|
81
|
-
inline_keypad: Keypad = None,
|
|
82
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
83
|
-
disable_notification: bool = None,
|
|
84
|
-
reply_to_message_id=None
|
|
85
|
-
) -> "MessageId":
|
|
86
|
-
data = {
|
|
87
|
-
"chat_id": chat_id,
|
|
88
|
-
"text": text,
|
|
89
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
90
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
91
|
-
"chat_keypad_type": chat_keypad_type,
|
|
92
|
-
"disable_notification": disable_notification,
|
|
93
|
-
"reply_to_message_id": reply_to_message_id
|
|
94
|
-
}
|
|
95
|
-
response = await self.request("sendMessage", self.clean_data(data))
|
|
96
|
-
message = MessageId.from_dict(response)
|
|
97
|
-
message.chat_id = chat_id
|
|
98
|
-
message.client = self
|
|
99
|
-
return message
|
|
100
|
-
|
|
101
|
-
async def send_poll(
|
|
102
|
-
self,
|
|
103
|
-
chat_id: str,
|
|
104
|
-
question: str,
|
|
105
|
-
options: list[str],
|
|
106
|
-
chat_keypad: Keypad = None,
|
|
107
|
-
inline_keypad: Keypad = None,
|
|
108
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
109
|
-
disable_notification: bool = False,
|
|
110
|
-
reply_to_message_id: str = None,
|
|
111
|
-
) -> "MessageId":
|
|
112
|
-
data = {
|
|
113
|
-
"chat_id": chat_id,
|
|
114
|
-
"question": question,
|
|
115
|
-
"options": options,
|
|
116
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
117
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
118
|
-
"disable_notification": disable_notification,
|
|
119
|
-
"reply_to_message_id": reply_to_message_id,
|
|
120
|
-
"chat_keypad_type": chat_keypad_type
|
|
121
|
-
}
|
|
122
|
-
response = await self.request("sendPoll", self.clean_data(data))
|
|
123
|
-
message = MessageId.from_dict(response)
|
|
124
|
-
message.chat_id = chat_id
|
|
125
|
-
message.client = self
|
|
126
|
-
return message
|
|
127
|
-
|
|
128
|
-
async def send_location(
|
|
129
|
-
self,
|
|
130
|
-
chat_id: str,
|
|
131
|
-
latitude: str,
|
|
132
|
-
longitude: str,
|
|
133
|
-
chat_keypad: Keypad = None,
|
|
134
|
-
inline_keypad: Keypad = None,
|
|
135
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
136
|
-
disable_notification: bool = False,
|
|
137
|
-
reply_to_message_id: str = None,
|
|
138
|
-
) -> "MessageId":
|
|
139
|
-
data = {
|
|
140
|
-
"chat_id": chat_id,
|
|
141
|
-
"latitude": latitude,
|
|
142
|
-
"longitude": longitude,
|
|
143
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
144
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
145
|
-
"disable_notification": disable_notification,
|
|
146
|
-
"reply_to_message_id": reply_to_message_id,
|
|
147
|
-
"chat_keypad_type": chat_keypad_type
|
|
148
|
-
}
|
|
149
|
-
response = await self.request("sendLocation", self.clean_data(data))
|
|
150
|
-
message = MessageId.from_dict(response)
|
|
151
|
-
message.chat_id = chat_id
|
|
152
|
-
message.client = self
|
|
153
|
-
return message
|
|
154
|
-
|
|
155
|
-
async def send_contact(
|
|
156
|
-
self,
|
|
157
|
-
chat_id: str,
|
|
158
|
-
first_name: str,
|
|
159
|
-
last_name: str,
|
|
160
|
-
phone_number: str,
|
|
161
|
-
chat_keypad: Keypad = None,
|
|
162
|
-
inline_keypad: Keypad = None,
|
|
163
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
164
|
-
disable_notification: bool = False,
|
|
165
|
-
reply_to_message_id: str = None,
|
|
166
|
-
) -> "MessageId":
|
|
167
|
-
data = {
|
|
168
|
-
"chat_id": chat_id,
|
|
169
|
-
"first_name": first_name,
|
|
170
|
-
"last_name": last_name,
|
|
171
|
-
"phone_number": phone_number,
|
|
172
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
173
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
174
|
-
"disable_notification": disable_notification,
|
|
175
|
-
"reply_to_message_id": reply_to_message_id,
|
|
176
|
-
"chat_keypad_type": chat_keypad_type
|
|
177
|
-
}
|
|
178
|
-
response = await self.request("sendContact", self.clean_data(data))
|
|
179
|
-
message = MessageId.from_dict(response)
|
|
180
|
-
message.chat_id = chat_id
|
|
181
|
-
message.client = self
|
|
182
|
-
return message
|
|
183
|
-
|
|
184
|
-
async def send_sticker(
|
|
185
|
-
self,
|
|
186
|
-
chat_id: str,
|
|
187
|
-
sticker_id: str,
|
|
188
|
-
chat_keypad: Keypad = None,
|
|
189
|
-
inline_keypad: Keypad = None,
|
|
190
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
191
|
-
disable_notification: bool = False,
|
|
192
|
-
reply_to_message_id: str = None,
|
|
193
|
-
) -> "MessageId":
|
|
194
|
-
data = {
|
|
195
|
-
"chat_id": chat_id,
|
|
196
|
-
"sticker_id": sticker_id,
|
|
197
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
198
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
199
|
-
"disable_notification": disable_notification,
|
|
200
|
-
"reply_to_message_id": reply_to_message_id,
|
|
201
|
-
"chat_keypad_type": chat_keypad_type
|
|
202
|
-
}
|
|
203
|
-
response = await self.request("sendSticker", self.clean_data(data))
|
|
204
|
-
message = MessageId.from_dict(response)
|
|
205
|
-
message.chat_id = chat_id
|
|
206
|
-
message.client = self
|
|
207
|
-
return message
|
|
208
|
-
|
|
209
|
-
async def request_send_file(self, type: str):
|
|
210
|
-
response = await self.request("requestSendFile", {"type": type})
|
|
211
|
-
return response["upload_url"]
|
|
212
|
-
|
|
213
|
-
async def upload_file(self, file: Union[str, bytes], name: Optional[str] = None, type: str = "File"):
|
|
214
|
-
upload_url = await self.request_send_file(type)
|
|
215
|
-
response = await self.requestUpload(upload_url, file, name)
|
|
216
|
-
return response
|
|
217
|
-
|
|
218
|
-
async def download_file(self, file_id: str, filename: Optional[str] = None):
|
|
219
|
-
download_url = await self.get_file(file_id)
|
|
220
|
-
response = await self.requestDownload(download_url, filename)
|
|
221
|
-
return response
|
|
222
|
-
|
|
223
|
-
async def send_file(
|
|
224
|
-
self,
|
|
225
|
-
chat_id: str,
|
|
226
|
-
file: Union[str, bytes],
|
|
227
|
-
caption: Optional[str] = None,
|
|
228
|
-
file_name: Optional[str] = None,
|
|
229
|
-
type: enums.FileType = enums.FileType.File,
|
|
230
|
-
chat_keypad: Keypad = None,
|
|
231
|
-
inline_keypad: Keypad = None,
|
|
232
|
-
chat_keypad_type: Optional[enums.ChatKeypadType] = None,
|
|
233
|
-
disable_notification: bool = False,
|
|
234
|
-
reply_to_message_id: Optional[str] = None,
|
|
235
|
-
) -> "MessageId":
|
|
236
|
-
file_id = await self.upload_file(file, file_name, type)
|
|
237
|
-
|
|
238
|
-
data = {
|
|
239
|
-
"chat_id": chat_id,
|
|
240
|
-
"file_id": file_id,
|
|
241
|
-
"text": caption,
|
|
242
|
-
"chat_keypad": chat_keypad.asdict() if chat_keypad else None,
|
|
243
|
-
"inline_keypad": inline_keypad.asdict() if inline_keypad else None,
|
|
244
|
-
"disable_notification": disable_notification,
|
|
245
|
-
"reply_to_message_id": reply_to_message_id,
|
|
246
|
-
"chat_keypad_type": chat_keypad_type,
|
|
247
|
-
}
|
|
248
|
-
response = await self.request("sendFile", self.clean_data(data))
|
|
249
|
-
message = MessageId.from_dict(response)
|
|
250
|
-
message.chat_id = chat_id
|
|
251
|
-
message.file_id = file_id
|
|
252
|
-
message.client = self
|
|
253
|
-
return message
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
async def send_document(self, chat_id: str, document: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
258
|
-
return await self.send_file(chat_id, document, caption, file_name, "File", **kwargs)
|
|
259
|
-
|
|
260
|
-
async def send_photo(self, chat_id: str, photo: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
261
|
-
return await self.send_file(chat_id, photo, caption, file_name, "Image", **kwargs)
|
|
262
|
-
|
|
263
|
-
async def send_video(self, chat_id: str, video: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
264
|
-
return await self.send_file(chat_id, video, caption, file_name, "Video", **kwargs)
|
|
265
|
-
|
|
266
|
-
async def send_gif(self, chat_id: str, gif: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
267
|
-
return await self.send_file(chat_id, gif, caption, file_name, "Gif", **kwargs)
|
|
268
|
-
|
|
269
|
-
async def send_music(self, chat_id: str, music: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
270
|
-
return await self.send_file(chat_id, music, caption, file_name, "Music", **kwargs)
|
|
271
|
-
|
|
272
|
-
async def send_voice(self, chat_id: str, voice: Union[str, bytes], caption: Optional[str] = None, file_name: Optional[str] = None, **kwargs):
|
|
273
|
-
return await self.send_file(chat_id, voice, caption, file_name, "Voice", **kwargs)
|
|
274
|
-
|
|
275
|
-
# async def get_messages(self, chat_id: str, message_ids: Optional[list[str]] = None):
|
|
276
|
-
# return await self.request("getMessages", {"chat_id": chat_id, "message_ids": message_ids})
|
|
277
|
-
|
|
278
|
-
# async def get_bot_command(self):
|
|
279
|
-
# return await self.request("getBotCommands", {})
|
|
280
|
-
|
|
281
|
-
# async def send_chat_action(self, chat_id: str, action: enums.ChatAction):
|
|
282
|
-
# return await self.request("sendChatAction", {"chat_id": chat_id, "action": action})
|
|
283
|
-
|
|
284
|
-
# async def set_username(self, username: str):
|
|
285
|
-
# return await self.request("setUsername", {"username": username})
|
|
286
|
-
|
|
287
|
-
async def get_bot_name(self):
|
|
288
|
-
bot = await self.get_me()
|
|
289
|
-
return bot.bot_title
|
|
290
|
-
|
|
291
|
-
async def get_bot_id(self):
|
|
292
|
-
bot = await self.get_me()
|
|
293
|
-
return bot.bot_id
|
|
294
|
-
|
|
295
|
-
async def get_bot_username(self):
|
|
296
|
-
bot = await self.get_me()
|
|
297
|
-
return bot.username
|
|
298
|
-
|
|
299
|
-
async def get_bot_share_url(self):
|
|
300
|
-
bot = await self.get_me()
|
|
301
|
-
return bot.share_url
|
|
302
|
-
|
|
303
|
-
async def get_bot_descriptionl(self):
|
|
304
|
-
bot = await self.get_me()
|
|
305
|
-
return bot.description
|
|
306
|
-
|
|
307
|
-
async def get_bot_start_messagel(self):
|
|
308
|
-
bot = await self.get_me()
|
|
309
|
-
return bot.start_message
|
|
310
|
-
|
|
311
|
-
# async def pin_message(self):
|
|
312
|
-
# return
|
|
313
|
-
|
|
314
|
-
# async def unpin_message(self):
|
|
315
|
-
# return
|
|
316
|
-
|
|
317
|
-
# async def ban_chat_member(self):
|
|
318
|
-
# return
|
|
319
|
-
|
|
320
|
-
# async def unban_chat_member(self):
|
|
321
|
-
# return
|
|
322
|
-
|
|
323
|
-
# async def get_chat_member(self):
|
|
324
|
-
# return
|
|
325
|
-
|
|
326
|
-
# async def copy_message(self):
|
|
327
|
-
# return
|
|
328
|
-
|
|
329
|
-
# async def edit_message_caption(self):
|
|
330
|
-
# return
|
|
331
|
-
|
|
332
|
-
# async def get_chat_administrators(self):
|
|
333
|
-
# return
|
|
334
|
-
|
|
335
|
-
# async def get_chat_member_count(self):
|
|
336
|
-
# return
|
|
337
|
-
|
|
338
|
-
# async def join_chat(self):
|
|
339
|
-
# return
|
|
340
|
-
|
|
341
|
-
# async def leave_chat(self):
|
|
342
|
-
# return
|
|
343
|
-
|
|
344
|
-
# async def set_chat_description(self):
|
|
345
|
-
# return
|
|
346
|
-
|
|
347
|
-
# async def set_chat_photo(self):
|
|
348
|
-
# return
|
|
349
|
-
|
|
350
|
-
# async def set_chat_title(self):
|
|
351
|
-
# return
|
|
352
|
-
|
|
353
|
-
# async def unpin_all_message(self):
|
|
354
|
-
# return
|
rubigram/network.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
from aiohttp import ClientSession, FormData
|
|
2
|
-
from typing import Any, Optional, Union
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from urllib.parse import urlparse
|
|
5
|
-
import aiofiles
|
|
6
|
-
import os
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Network:
|
|
10
|
-
def __init__(self, token: str) -> None:
|
|
11
|
-
self.token: str = token
|
|
12
|
-
self.session: Optional[ClientSession] = None
|
|
13
|
-
self.api: str = f"https://botapi.rubika.ir/v3/{token}/"
|
|
14
|
-
|
|
15
|
-
async def start(self):
|
|
16
|
-
if not self.session:
|
|
17
|
-
self.session = ClientSession()
|
|
18
|
-
|
|
19
|
-
async def stop(self):
|
|
20
|
-
if self.session:
|
|
21
|
-
await self.session.close()
|
|
22
|
-
self.session = None
|
|
23
|
-
|
|
24
|
-
async def __aenter__(self):
|
|
25
|
-
await self.start()
|
|
26
|
-
return self
|
|
27
|
-
|
|
28
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
29
|
-
await self.stop()
|
|
30
|
-
|
|
31
|
-
async def request(self, method: str, json: dict[str, Any]):
|
|
32
|
-
await self.start()
|
|
33
|
-
async with self.session.post(self.api + method, json=json) as response:
|
|
34
|
-
response.raise_for_status()
|
|
35
|
-
data: dict = await response.json()
|
|
36
|
-
return data.get("data", {})
|
|
37
|
-
|
|
38
|
-
async def getBytes(self, url: str) -> bytes:
|
|
39
|
-
await self.start()
|
|
40
|
-
async with self.session.get(url) as response:
|
|
41
|
-
response.raise_for_status()
|
|
42
|
-
return await response.read()
|
|
43
|
-
|
|
44
|
-
async def getName(self, url: str) -> str:
|
|
45
|
-
parser = urlparse(url)
|
|
46
|
-
return os.path.basename(parser.path)
|
|
47
|
-
|
|
48
|
-
async def requestUpload(self, upload_url: str, file: Union[str, bytes], name: Optional[str] = None):
|
|
49
|
-
data, filename = None, None
|
|
50
|
-
if isinstance(file, str):
|
|
51
|
-
path = Path(file)
|
|
52
|
-
|
|
53
|
-
if path.is_file():
|
|
54
|
-
data, filename = path.read_bytes(), name if name else path.name
|
|
55
|
-
|
|
56
|
-
elif file.startswith("http"):
|
|
57
|
-
data, filename = await self.getBytes(file), name if name else await self.getName(file)
|
|
58
|
-
|
|
59
|
-
else:
|
|
60
|
-
raise Exception(f"Can't find this file : {file}")
|
|
61
|
-
|
|
62
|
-
elif isinstance(file, bytes):
|
|
63
|
-
if name:
|
|
64
|
-
data, filename = file, name
|
|
65
|
-
else:
|
|
66
|
-
raise Exception("choice name for bytes file")
|
|
67
|
-
|
|
68
|
-
form = FormData()
|
|
69
|
-
form.add_field("file", data, filename=filename, content_type="application/octet-stream")
|
|
70
|
-
await self.start()
|
|
71
|
-
async with self.session.post(upload_url, data=form) as response:
|
|
72
|
-
response.raise_for_status()
|
|
73
|
-
data: dict = await response.json()
|
|
74
|
-
return data.get("data", {})["file_id"]
|
|
75
|
-
|
|
76
|
-
async def requestDownload(self, url: str, filename: Optional[str] = None):
|
|
77
|
-
file, name = await self.getBytes(url), filename if filename else await self.getName(url)
|
|
78
|
-
async with aiofiles.open(name, "wb") as f:
|
|
79
|
-
await f.write(file)
|
|
80
|
-
return name
|
rubigram/rubino/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .client import Rubino
|