X Tutup
Skip to content

Commit 37c7af2

Browse files
committed
Add docstrings python-telegram-bot#302
1 parent e706257 commit 37c7af2

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

telegram/bot.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,26 @@ def setWebhook(self, webhook_url=None, certificate=None, **kwargs):
12611261

12621262
@log
12631263
def leaveChat(self, chat_id, **kwargs):
1264+
"""Use this method for your bot to leave a group, supergroup or
1265+
channel.
1266+
1267+
Args:
1268+
chat_id:
1269+
Unique identifier for the target chat or username of the target
1270+
channel (in the format @channelusername).
1271+
1272+
Keyword Args:
1273+
timeout (Optional[float]): If this value is specified, use it as
1274+
the definitive timeout (in seconds) for urlopen() operations.
1275+
1276+
Returns:
1277+
bool: On success, `True` is returned.
1278+
1279+
Raises:
1280+
:class:`telegram.TelegramError`
1281+
1282+
"""
1283+
12641284
url = '{0}/leaveChat'.format(self.base_url)
12651285

12661286
data = {'chat_id': chat_id}
@@ -1271,6 +1291,28 @@ def leaveChat(self, chat_id, **kwargs):
12711291

12721292
@log
12731293
def getChat(self, chat_id, **kwargs):
1294+
"""Use this method to get up to date information about the chat
1295+
(current name of the user for one-on-one conversations, current
1296+
username of a user, group or channel, etc.).
1297+
1298+
Args:
1299+
chat_id:
1300+
Unique identifier for the target chat or username of the target
1301+
channel (in the format @channelusername).
1302+
1303+
Keyword Args:
1304+
timeout (Optional[float]): If this value is specified, use it as
1305+
the definitive timeout (in seconds) for urlopen() operations.
1306+
1307+
Returns:
1308+
:class:`telegram.Chat`: On success, :class:`telegram.Chat` is
1309+
returned.
1310+
1311+
Raises:
1312+
:class:`telegram.TelegramError`
1313+
1314+
"""
1315+
12741316
url = '{0}/getChat'.format(self.base_url)
12751317

12761318
data = {'chat_id': chat_id}
@@ -1281,6 +1323,31 @@ def getChat(self, chat_id, **kwargs):
12811323

12821324
@log
12831325
def getChatAdministrators(self, chat_id, **kwargs):
1326+
"""Use this method to get a list of administrators in a chat. On
1327+
success, returns an Array of ChatMember objects that contains
1328+
information about all chat administrators except other bots. If the
1329+
chat is a group or a supergroup and no administrators were appointed,
1330+
only the creator will be returned.
1331+
1332+
Args:
1333+
chat_id:
1334+
Unique identifier for the target chat or username of the target
1335+
channel (in the format @channelusername).
1336+
1337+
1338+
Keyword Args:
1339+
timeout (Optional[float]): If this value is specified, use it as
1340+
the definitive timeout (in seconds) for urlopen() operations.
1341+
1342+
Returns:
1343+
list[:class:`telegram.ChatMember`]: On success, a list of
1344+
:class:`telegram.ChatMember` objects are returned.
1345+
1346+
Raises:
1347+
:class:`telegram.TelegramError`
1348+
1349+
"""
1350+
12841351
url = '{0}/getChatAdministrators'.format(self.base_url)
12851352

12861353
data = {'chat_id': chat_id}
@@ -1291,6 +1358,26 @@ def getChatAdministrators(self, chat_id, **kwargs):
12911358

12921359
@log
12931360
def getChatMembersCount(self, chat_id, **kwargs):
1361+
"""Use this method to get the number of members in a chat.
1362+
1363+
Args:
1364+
chat_id:
1365+
Unique identifier for the target chat or username of the target
1366+
channel (in the format @channelusername).
1367+
1368+
1369+
Keyword Args:
1370+
timeout (Optional[float]): If this value is specified, use it as
1371+
the definitive timeout (in seconds) for urlopen() operations.
1372+
1373+
Returns:
1374+
int: On success, an `int` is returned.
1375+
1376+
Raises:
1377+
:class:`telegram.TelegramError`
1378+
1379+
"""
1380+
12941381
url = '{0}/getChatMembersCount'.format(self.base_url)
12951382

12961383
data = {'chat_id': chat_id}
@@ -1301,6 +1388,29 @@ def getChatMembersCount(self, chat_id, **kwargs):
13011388

13021389
@log
13031390
def getChatMember(self, chat_id, user_id, **kwargs):
1391+
"""Use this method to get information about a member of a chat.
1392+
1393+
Args:
1394+
chat_id:
1395+
Unique identifier for the target chat or username of the target
1396+
channel (in the format @channelusername).
1397+
user_id:
1398+
Unique identifier of the target user.
1399+
1400+
1401+
Keyword Args:
1402+
timeout (Optional[float]): If this value is specified, use it as
1403+
the definitive timeout (in seconds) for urlopen() operations.
1404+
1405+
Returns:
1406+
:class:`telegram.ChatMember`: On success,
1407+
:class:`telegram.ChatMember` is returned.
1408+
1409+
Raises:
1410+
:class:`telegram.TelegramError`
1411+
1412+
"""
1413+
13041414
url = '{0}/getChatMember'.format(self.base_url)
13051415

13061416
data = {'chat_id': chat_id, 'user_id': user_id}

0 commit comments

Comments
 (0)
X Tutup