pyrobale 0.2.9.4.1__py3-none-any.whl → 0.3.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.
- pyrobale/__init__.py +3 -0
- pyrobale/client/__init__.py +574 -0
- pyrobale/exceptions/__init__.py +0 -0
- pyrobale/exceptions/common.py +10 -0
- pyrobale/objects/__init__.py +86 -0
- pyrobale/objects/animation.py +33 -0
- pyrobale/objects/audio.py +24 -0
- pyrobale/objects/callbackquery.py +42 -0
- pyrobale/objects/chat.py +463 -0
- pyrobale/objects/chatmember.py +162 -0
- pyrobale/objects/chatphoto.py +18 -0
- pyrobale/objects/contact.py +16 -0
- pyrobale/objects/copytextbutton.py +5 -0
- pyrobale/objects/document.py +26 -0
- pyrobale/objects/enums.py +28 -0
- pyrobale/objects/file.py +15 -0
- pyrobale/objects/inlinekeyboardbutton.py +24 -0
- pyrobale/objects/inlinekeyboardmarkup.py +84 -0
- pyrobale/objects/inputfile.py +17 -0
- pyrobale/objects/inputmedias.py +166 -0
- pyrobale/objects/invoice.py +14 -0
- pyrobale/objects/keyboardbutton.py +19 -0
- pyrobale/objects/labeledprice.py +8 -0
- pyrobale/objects/location.py +4 -0
- pyrobale/objects/message.py +368 -0
- pyrobale/objects/messageid.py +3 -0
- pyrobale/objects/photosize.py +9 -0
- pyrobale/objects/precheckoutquery.py +21 -0
- pyrobale/objects/replykeyboardmarkup.py +54 -0
- pyrobale/objects/sticker.py +16 -0
- pyrobale/objects/stickerset.py +12 -0
- pyrobale/objects/successfulpayment.py +15 -0
- pyrobale/objects/update.py +23 -0
- pyrobale/objects/user.py +20 -0
- pyrobale/objects/utils.py +28 -0
- pyrobale/objects/video.py +20 -0
- pyrobale/objects/voice.py +4 -0
- pyrobale/objects/webappdata.py +3 -0
- pyrobale/objects/webappinfo.py +3 -0
- pyrobale-0.3.5.dist-info/METADATA +176 -0
- pyrobale-0.3.5.dist-info/RECORD +43 -0
- pyrobale-0.3.5.dist-info/licenses/LICENSE +21 -0
- pyrobale-0.2.9.4.1.dist-info/METADATA +0 -833
- pyrobale-0.2.9.4.1.dist-info/RECORD +0 -5
- pyrobale-0.2.9.4.1.dist-info/licenses/LICENSE +0 -678
- pyrobale.py +0 -2543
- {pyrobale-0.2.9.4.1.dist-info → pyrobale-0.3.5.dist-info}/WHEEL +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Optional
|
2
|
+
|
3
|
+
if TYPE_CHECKING:
|
4
|
+
from .utils import build_api_url
|
5
|
+
from .photosize import PhotoSize
|
6
|
+
|
7
|
+
|
8
|
+
class Animation:
|
9
|
+
"""Represents an animation file (GIF or H.264/MPEG-4 AVC video without
|
10
|
+
sound) to be sent."""
|
11
|
+
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
file_id: Optional[str] = None,
|
15
|
+
file_unique_id: Optional[str] = None,
|
16
|
+
width: Optional[int] = None,
|
17
|
+
height: Optional[int] = None,
|
18
|
+
duration: Optional[int] = None,
|
19
|
+
thumb: Optional["PhotoSize"] = None,
|
20
|
+
file_name: Optional[str] = None,
|
21
|
+
mime_type: Optional[str] = None,
|
22
|
+
file_size: Optional[int] = None,
|
23
|
+
**kwargs
|
24
|
+
):
|
25
|
+
self.file_id = file_id
|
26
|
+
self.file_unique_id = file_unique_id
|
27
|
+
self.width = width
|
28
|
+
self.height = height
|
29
|
+
self.duration = duration
|
30
|
+
self.thumb = thumb
|
31
|
+
self.file_name = file_name
|
32
|
+
self.mime_type = mime_type
|
33
|
+
self.file_size = file_size
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
3
|
+
|
4
|
+
class Audio:
|
5
|
+
"""Represents an audio file to be treated as music to be sent."""
|
6
|
+
|
7
|
+
def __init__(
|
8
|
+
self,
|
9
|
+
file_id: Optional[str] = None,
|
10
|
+
file_unique_id: Optional[str] = None,
|
11
|
+
duration: Optional[int] = None,
|
12
|
+
title: Optional[str] = None,
|
13
|
+
file_name: Optional[str] = None,
|
14
|
+
mime_type: Optional[str] = None,
|
15
|
+
file_size: Optional[int] = None,
|
16
|
+
**kwargs
|
17
|
+
):
|
18
|
+
self.file_id = file_id
|
19
|
+
self.file_unique_id = file_unique_id
|
20
|
+
self.duration = duration
|
21
|
+
self.title = title
|
22
|
+
self.file_name = file_name
|
23
|
+
self.mime_type = mime_type
|
24
|
+
self.file_size = file_size
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Optional
|
2
|
+
|
3
|
+
if TYPE_CHECKING:
|
4
|
+
from .user import User
|
5
|
+
from .message import Message
|
6
|
+
from ..client import Client
|
7
|
+
|
8
|
+
from .user import User
|
9
|
+
from .message import Message
|
10
|
+
from .chat import Chat
|
11
|
+
|
12
|
+
|
13
|
+
class CallbackQuery:
|
14
|
+
"""Represents a callback query from a user."""
|
15
|
+
|
16
|
+
def __init__(
|
17
|
+
self,
|
18
|
+
id: Optional[str] = None,
|
19
|
+
user: Optional["User"] = None,
|
20
|
+
message: Optional["Message"] = None,
|
21
|
+
data: Optional[str] = None,
|
22
|
+
**kwargs
|
23
|
+
):
|
24
|
+
self.id = id
|
25
|
+
self.user: "User" = User(**user) if user else None
|
26
|
+
self.message: "Message" = Message(**message) if message else None
|
27
|
+
self.chat: "Chat" = self.message.chat if self.message else None
|
28
|
+
self.data = data if data else None
|
29
|
+
self.bot: "Client" = kwargs.get("kwargs", {}).get("client", None)
|
30
|
+
|
31
|
+
async def answer(
|
32
|
+
self, text: Optional[str] = None, show_alert: bool = False
|
33
|
+
) -> bool:
|
34
|
+
"""Sends a response to the callback query.
|
35
|
+
|
36
|
+
:param text: The text of the response.
|
37
|
+
|
38
|
+
:param show_alert: Whether to show an alert to the user.
|
39
|
+
|
40
|
+
:return: true if the response was sent successfully.
|
41
|
+
"""
|
42
|
+
return await self.bot.answer_callback_query(self.id, text, show_alert)
|
pyrobale/objects/chat.py
ADDED
@@ -0,0 +1,463 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
from typing import Optional, Union
|
3
|
+
|
4
|
+
if TYPE_CHECKING:
|
5
|
+
from .utils import build_api_url
|
6
|
+
from .chatphoto import ChatPhoto
|
7
|
+
from .message import Message
|
8
|
+
from .user import User
|
9
|
+
from .chatmember import ChatMember
|
10
|
+
from ..client import Client
|
11
|
+
from ..objects.inlinekeyboardmarkup import InlineKeyboardMarkup
|
12
|
+
from ..objects.replykeyboardmarkup import ReplyKeyboardMarkup
|
13
|
+
from .enums import ChatType, ChatAction, UpdatesTypes
|
14
|
+
import asyncio
|
15
|
+
import aiohttp
|
16
|
+
|
17
|
+
|
18
|
+
class Chat:
|
19
|
+
"""Represents a chat in the Bale messenger.
|
20
|
+
|
21
|
+
Parameters:
|
22
|
+
id (Optional[int]): Unique identifier for this chat
|
23
|
+
type (Optional[str]): Type of chat, can be either "private", "group", or "channel"
|
24
|
+
title (Optional[str]): Title, for groups and channels
|
25
|
+
username (Optional[str]): Username, for private chats and channels if available
|
26
|
+
first_name (Optional[str]): First name of the other party in a private chat
|
27
|
+
last_name (Optional[str]): Last name of the other party in a private chat
|
28
|
+
photo (Optional[ChatPhoto]): Chat photo object
|
29
|
+
**kwargs: Additional keyword arguments
|
30
|
+
|
31
|
+
Attributes:
|
32
|
+
id (int): Unique identifier for this chat
|
33
|
+
type (str): Type of chat
|
34
|
+
PRIVATE (bool): True if chat is private
|
35
|
+
GROUP (bool): True if chat is group
|
36
|
+
CHANNEL (bool): True if chat is channel
|
37
|
+
title (str): Chat title
|
38
|
+
username (str): Chat username
|
39
|
+
first_name (str): First name
|
40
|
+
last_name (str): Last name
|
41
|
+
photo (ChatPhoto): Chat photo
|
42
|
+
client (Client): Client instance
|
43
|
+
"""
|
44
|
+
|
45
|
+
def __init__(
|
46
|
+
self,
|
47
|
+
id: Optional[int] = None,
|
48
|
+
type: Optional[str] = None,
|
49
|
+
title: Optional[str] = None,
|
50
|
+
username: Optional[str] = None,
|
51
|
+
first_name: Optional[str] = None,
|
52
|
+
last_name: Optional[str] = None,
|
53
|
+
photo: Optional["ChatPhoto"] = None,
|
54
|
+
**kwargs
|
55
|
+
):
|
56
|
+
self.id = id
|
57
|
+
self.type = type
|
58
|
+
self.PRIVATE = self.type == "private"
|
59
|
+
self.GROUP = self.type == "group"
|
60
|
+
self.CHANNEL = self.type == "channel"
|
61
|
+
self.title = title
|
62
|
+
self.username = username
|
63
|
+
self.first_name = first_name
|
64
|
+
self.last_name = last_name
|
65
|
+
self.photo: "ChatPhoto" = photo
|
66
|
+
self.client: "Client" = kwargs.get("kwargs", {}).get("client")
|
67
|
+
|
68
|
+
async def send_message(
|
69
|
+
self,
|
70
|
+
text: str,
|
71
|
+
reply_to_message_id: int = None,
|
72
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
73
|
+
) -> "Message":
|
74
|
+
"""Send a message to the chat.
|
75
|
+
|
76
|
+
Parameters:
|
77
|
+
text (str): Text of the message to be sent
|
78
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
79
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
Message: The sent message object
|
83
|
+
"""
|
84
|
+
self.client.send_message(
|
85
|
+
chat_id=self.id,
|
86
|
+
text=text,
|
87
|
+
reply_to_message_id=reply_to_message_id,
|
88
|
+
reply_markup=reply_markup,
|
89
|
+
)
|
90
|
+
|
91
|
+
async def get_chat_member(self, user_id: int) -> "ChatMember":
|
92
|
+
"""Get information about a member of a chat.
|
93
|
+
|
94
|
+
Parameters:
|
95
|
+
user_id (int): Unique identifier of the target user
|
96
|
+
|
97
|
+
Returns:
|
98
|
+
ChatMember: Information about the chat member
|
99
|
+
"""
|
100
|
+
return await self.client.get_chat_member(chat_id=self.id, user_id=user_id)
|
101
|
+
|
102
|
+
async def get_chat_members_count(self) -> int:
|
103
|
+
"""Get the number of members in the chat.
|
104
|
+
|
105
|
+
Returns:
|
106
|
+
int: Number of members in the chat
|
107
|
+
"""
|
108
|
+
return await self.client.get_chat_members_count(chat_id=self.id)
|
109
|
+
|
110
|
+
async def send_photo(
|
111
|
+
self,
|
112
|
+
photo: str,
|
113
|
+
caption: Optional[str] = None,
|
114
|
+
reply_to_message_id: int = None,
|
115
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
116
|
+
) -> "Message":
|
117
|
+
"""Send a photo to the chat.
|
118
|
+
|
119
|
+
Parameters:
|
120
|
+
photo (str): Photo to send (file_id or URL)
|
121
|
+
caption (Optional[str]): Photo caption
|
122
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
123
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
124
|
+
|
125
|
+
Returns:
|
126
|
+
Message: The sent message object
|
127
|
+
"""
|
128
|
+
self.client.send_photo(
|
129
|
+
chat_id=self.id,
|
130
|
+
photo=photo,
|
131
|
+
caption=caption,
|
132
|
+
reply_to_message_id=reply_to_message_id,
|
133
|
+
reply_markup=reply_markup,
|
134
|
+
)
|
135
|
+
|
136
|
+
async def send_video(
|
137
|
+
self,
|
138
|
+
video: str,
|
139
|
+
caption: Optional[str] = None,
|
140
|
+
reply_to_message_id: int = None,
|
141
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
142
|
+
) -> "Message":
|
143
|
+
"""Send a video to the chat.
|
144
|
+
|
145
|
+
Parameters:
|
146
|
+
video (str): Video to send (file_id or URL)
|
147
|
+
caption (Optional[str]): Video caption
|
148
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
149
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
150
|
+
|
151
|
+
Returns:
|
152
|
+
Message: The sent message object
|
153
|
+
"""
|
154
|
+
self.client.send_video(
|
155
|
+
chat_id=self.id,
|
156
|
+
video=video,
|
157
|
+
caption=caption,
|
158
|
+
reply_to_message_id=reply_to_message_id,
|
159
|
+
reply_markup=reply_markup,
|
160
|
+
)
|
161
|
+
|
162
|
+
async def send_audio(
|
163
|
+
self,
|
164
|
+
audio: str,
|
165
|
+
caption: Optional[str] = None,
|
166
|
+
reply_to_message_id: int = None,
|
167
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
168
|
+
) -> "Message":
|
169
|
+
"""Send an audio file to the chat.
|
170
|
+
|
171
|
+
Parameters:
|
172
|
+
audio (str): Audio file to send (file_id or URL)
|
173
|
+
caption (Optional[str]): Audio caption
|
174
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
175
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
176
|
+
|
177
|
+
Returns:
|
178
|
+
Message: The sent message object
|
179
|
+
"""
|
180
|
+
self.client.send_audio(
|
181
|
+
chat_id=self.id,
|
182
|
+
audio=audio,
|
183
|
+
caption=caption,
|
184
|
+
reply_to_message_id=reply_to_message_id,
|
185
|
+
reply_markup=reply_markup,
|
186
|
+
)
|
187
|
+
|
188
|
+
async def send_document(
|
189
|
+
self,
|
190
|
+
document: str,
|
191
|
+
caption: Optional[str] = None,
|
192
|
+
reply_to_message_id: int = None,
|
193
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
194
|
+
) -> "Message":
|
195
|
+
"""Send a document to the chat.
|
196
|
+
|
197
|
+
Parameters:
|
198
|
+
document (str): Document to send (file_id or URL)
|
199
|
+
caption (Optional[str]): Document caption
|
200
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
201
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
202
|
+
|
203
|
+
Returns:
|
204
|
+
Message: The sent message object
|
205
|
+
"""
|
206
|
+
self.client.send_document(
|
207
|
+
chat_id=self.id,
|
208
|
+
document=document,
|
209
|
+
caption=caption,
|
210
|
+
reply_to_message_id=reply_to_message_id,
|
211
|
+
reply_markup=reply_markup,
|
212
|
+
)
|
213
|
+
|
214
|
+
async def send_sticker(
|
215
|
+
self,
|
216
|
+
sticker: str,
|
217
|
+
reply_to_message_id: int = None,
|
218
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
219
|
+
) -> "Message":
|
220
|
+
"""Send a sticker to the chat.
|
221
|
+
|
222
|
+
Parameters:
|
223
|
+
sticker (str): Sticker to send (file_id or URL)
|
224
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
225
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
226
|
+
|
227
|
+
Returns:
|
228
|
+
Message: The sent message object
|
229
|
+
"""
|
230
|
+
self.client.send_sticker(
|
231
|
+
chat_id=self.id,
|
232
|
+
sticker=sticker,
|
233
|
+
reply_to_message_id=reply_to_message_id,
|
234
|
+
reply_markup=reply_markup,
|
235
|
+
)
|
236
|
+
|
237
|
+
async def send_voice(
|
238
|
+
self,
|
239
|
+
voice: str,
|
240
|
+
caption: Optional[str] = None,
|
241
|
+
reply_to_message_id: int = None,
|
242
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
243
|
+
) -> "Message":
|
244
|
+
"""Send a voice message to the chat.
|
245
|
+
|
246
|
+
Parameters:
|
247
|
+
voice (str): Voice message to send (file_id or URL)
|
248
|
+
caption (Optional[str]): Voice message caption
|
249
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
250
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
251
|
+
|
252
|
+
Returns:
|
253
|
+
Message: The sent message object
|
254
|
+
"""
|
255
|
+
self.client.send_voice(
|
256
|
+
chat_id=self.id,
|
257
|
+
voice=voice,
|
258
|
+
caption=caption,
|
259
|
+
reply_to_message_id=reply_to_message_id,
|
260
|
+
reply_markup=reply_markup,
|
261
|
+
)
|
262
|
+
|
263
|
+
async def send_location(
|
264
|
+
self,
|
265
|
+
latitude: float,
|
266
|
+
longitude: float,
|
267
|
+
reply_to_message_id: int = None,
|
268
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
269
|
+
) -> "Message":
|
270
|
+
"""Send a location to the chat.
|
271
|
+
|
272
|
+
Parameters:
|
273
|
+
latitude (float): Latitude of the location
|
274
|
+
longitude (float): Longitude of the location
|
275
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
276
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
277
|
+
|
278
|
+
Returns:
|
279
|
+
Message: The sent message object
|
280
|
+
"""
|
281
|
+
self.client.send_location(
|
282
|
+
chat_id=self.id,
|
283
|
+
latitude=latitude,
|
284
|
+
longitude=longitude,
|
285
|
+
reply_to_message_id=reply_to_message_id,
|
286
|
+
reply_markup=reply_markup,
|
287
|
+
)
|
288
|
+
|
289
|
+
async def send_contact(
|
290
|
+
self,
|
291
|
+
phone_number: str,
|
292
|
+
first_name: str,
|
293
|
+
last_name: Optional[str] = None,
|
294
|
+
reply_to_message_id: int = None,
|
295
|
+
reply_markup: Union["ReplyKeyboardMarkup", "InlineKeyboardMarkup"] = None,
|
296
|
+
) -> "Message":
|
297
|
+
"""Send a contact to the chat.
|
298
|
+
|
299
|
+
Parameters:
|
300
|
+
phone_number (str): Contact's phone number
|
301
|
+
first_name (str): Contact's first name
|
302
|
+
last_name (Optional[str]): Contact's last name
|
303
|
+
reply_to_message_id (int, optional): If the message is a reply, ID of the original message
|
304
|
+
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional): Additional interface options
|
305
|
+
|
306
|
+
Returns:
|
307
|
+
Message: The sent message object
|
308
|
+
"""
|
309
|
+
self.client.send_contact(
|
310
|
+
chat_id=self.id,
|
311
|
+
phone_number=phone_number,
|
312
|
+
first_name=first_name,
|
313
|
+
last_name=last_name,
|
314
|
+
reply_to_message_id=reply_to_message_id,
|
315
|
+
reply_markup=reply_markup,
|
316
|
+
)
|
317
|
+
|
318
|
+
async def ban(self, user_id: int) -> bool:
|
319
|
+
"""Ban a user from the chat.
|
320
|
+
|
321
|
+
Parameters:
|
322
|
+
user_id (int): Unique identifier of the target user
|
323
|
+
until_date (Optional[int]): Date when the user will be unbanned (Unix time)
|
324
|
+
|
325
|
+
Returns:
|
326
|
+
bool: True on success
|
327
|
+
"""
|
328
|
+
return await self.client.ban_chat_member(chat_id=self.id, user_id=user_id)
|
329
|
+
|
330
|
+
async def unban(self, user_id: int) -> bool:
|
331
|
+
"""Unban a previously banned user in the chat.
|
332
|
+
|
333
|
+
Parameters:
|
334
|
+
user_id (int): Unique identifier of the target user
|
335
|
+
|
336
|
+
Returns:
|
337
|
+
bool: True on success
|
338
|
+
"""
|
339
|
+
return await self.client.unban_chat_member(chat_id=self.id, user_id=user_id)
|
340
|
+
|
341
|
+
async def promote(
|
342
|
+
self,
|
343
|
+
user_id: int,
|
344
|
+
can_change_info: Optional[bool] = None,
|
345
|
+
can_post_messages: Optional[bool] = None,
|
346
|
+
can_edit_messages: Optional[bool] = None,
|
347
|
+
can_delete_messages: Optional[bool] = None,
|
348
|
+
can_invite_users: Optional[bool] = None,
|
349
|
+
can_restrict_members: Optional[bool] = None,
|
350
|
+
can_pin_messages: Optional[bool] = None,
|
351
|
+
can_promote_members: Optional[bool] = None,
|
352
|
+
):
|
353
|
+
"""Promote or demote a user in a chat.
|
354
|
+
|
355
|
+
Parameters:
|
356
|
+
user_id (int): Unique identifier of the target user
|
357
|
+
can_change_info (Optional[bool]): Pass True if the user can change chat title, photo and other settings
|
358
|
+
can_post_messages (Optional[bool]): Pass True if the user can post messages in channels
|
359
|
+
can_edit_messages (Optional[bool]): Pass True if the user can edit messages in channels
|
360
|
+
can_delete_messages (Optional[bool]): Pass True if the user can delete messages
|
361
|
+
can_invite_users (Optional[bool]): Pass True if the user can invite new users
|
362
|
+
can_restrict_members (Optional[bool]): Pass True if the user can restrict, ban or unban chat members
|
363
|
+
can_pin_messages (Optional[bool]): Pass True if the user can pin messages
|
364
|
+
can_promote_members (Optional[bool]): Pass True if the user can add new administrators
|
365
|
+
|
366
|
+
Returns:
|
367
|
+
bool: True on success
|
368
|
+
"""
|
369
|
+
return await self.client.promote_chat_member(
|
370
|
+
chat_id=self.id,
|
371
|
+
user_id=user_id,
|
372
|
+
can_change_info=can_change_info,
|
373
|
+
can_post_messages=can_post_messages,
|
374
|
+
can_edit_messages=can_edit_messages,
|
375
|
+
can_delete_messages=can_delete_messages,
|
376
|
+
can_invite_users=can_invite_users,
|
377
|
+
can_restrict_members=can_restrict_members,
|
378
|
+
can_pin_messages=can_pin_messages,
|
379
|
+
can_promote_members=can_promote_members,
|
380
|
+
)
|
381
|
+
|
382
|
+
async def leave(self) -> bool:
|
383
|
+
"""Leave the chat.
|
384
|
+
|
385
|
+
Returns:
|
386
|
+
bool: True on success
|
387
|
+
"""
|
388
|
+
return await self.client.leave_chat(chat_id=self.id)
|
389
|
+
|
390
|
+
async def pin(self, message_id: int) -> bool:
|
391
|
+
"""Pin a message in the chat.
|
392
|
+
|
393
|
+
Parameters:
|
394
|
+
message_id (int): Identifier of a message to pin
|
395
|
+
|
396
|
+
Returns:
|
397
|
+
bool: True on success
|
398
|
+
"""
|
399
|
+
return await self.client.pin_chat_message(
|
400
|
+
chat_id=self.id, message_id=message_id
|
401
|
+
)
|
402
|
+
|
403
|
+
async def unpin(self) -> bool:
|
404
|
+
"""Unpin a message in the chat.
|
405
|
+
|
406
|
+
Returns:
|
407
|
+
bool: True on success
|
408
|
+
"""
|
409
|
+
return await self.client.unpin_chat_message(chat_id=self.id)
|
410
|
+
|
411
|
+
async def unpin_all(self) -> bool:
|
412
|
+
"""Unpin all messages in the chat.
|
413
|
+
|
414
|
+
Returns:
|
415
|
+
bool: True on success
|
416
|
+
"""
|
417
|
+
return await self.client.unpin_all_chat_messages(chat_id=self.id)
|
418
|
+
|
419
|
+
async def set_title(self, title: str) -> bool:
|
420
|
+
"""Change the title of a chat.
|
421
|
+
|
422
|
+
Parameters:
|
423
|
+
title (str): New chat title, 1-255 characters
|
424
|
+
|
425
|
+
Returns:
|
426
|
+
bool: True on success
|
427
|
+
"""
|
428
|
+
return await self.client.set_chat_title(chat_id=self.id, title=title)
|
429
|
+
|
430
|
+
async def set_description(self, description: str) -> bool:
|
431
|
+
"""Change the description of a chat.
|
432
|
+
|
433
|
+
Parameters:
|
434
|
+
description (str): New chat description, 0-255 characters
|
435
|
+
|
436
|
+
Returns:
|
437
|
+
bool: True on success
|
438
|
+
"""
|
439
|
+
return await self.client.set_chat_description(
|
440
|
+
chat_id=self.id, description=description
|
441
|
+
)
|
442
|
+
|
443
|
+
async def set_photo(self, photo: str) -> bool:
|
444
|
+
"""Set the photo of the chat.
|
445
|
+
|
446
|
+
Parameters:
|
447
|
+
photo (str): Photo to set. Pass a file_id as string to send a photo that exists on the Telegram servers, pass an HTTP URL as a string for Telegram to get a photo from the Internet, or pass "attach://<file_attach_name>" to upload a new photo that exists on the local server.
|
448
|
+
|
449
|
+
Returns:
|
450
|
+
bool: True on success
|
451
|
+
"""
|
452
|
+
return await self.client.set_chat_photo(chat_id=self.id, photo=photo)
|
453
|
+
|
454
|
+
async def send_action(self, action: ChatAction) -> bool:
|
455
|
+
"""Send an action to the chat.
|
456
|
+
|
457
|
+
Parameters:
|
458
|
+
action (objects.enums.ChatAction): Action to send to the chat
|
459
|
+
|
460
|
+
Returns:
|
461
|
+
bool: True on success
|
462
|
+
"""
|
463
|
+
return await self.client.send_chat_action(chat_id=self.id, action=action)
|