Skip to content

Commit 37271e4

Browse files
committed
Merge pull request python-telegram-bot#127 from python-telegram-bot/chatclass
API updates Oct and Nov
2 parents d791a6e + 0e78606 commit 37271e4

16 files changed

+107
-67
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
**2015-12-16**
2+
3+
*Released 3.1.0*
4+
5+
- The ``chat``-field in ``Message`` is now of type ``Chat``. (API update Oct 8 2015)
6+
- ``Message`` now contains the optional fields ``supergroup_chat_created``, ``migrate_to_chat_id``, ``migrate_from_chat_id`` and ``channel_chat_created``. (API update Nov 2015)
7+
18
**2015-12-08**
29

310
*Released 3.0.0*

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
# built documents.
5959
#
6060
# The short X.Y version.
61-
version = '3.0'
61+
version = '3.1'
6262
# The full version, including alpha/beta/rc tags.
63-
release = '3.0.0'
63+
release = '3.1.0'
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
telegram.groupchat module
1+
telegram.chat module
22
=========================
33

4-
.. automodule:: telegram.groupchat
4+
.. automodule:: telegram.chat
55
:members:
66
:undoc-members:
77
:show-inheritance:

docs/source/telegram.dispatcher.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
telegram.dispatcher module
2+
=========================
3+
4+
.. automodule:: telegram.dispatcher
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

docs/source/telegram.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ Submodules
99
telegram.audio
1010
telegram.base
1111
telegram.bot
12+
telegram.updater
13+
telegram.dispatcher
1214
telegram.chataction
1315
telegram.contact
1416
telegram.document
1517
telegram.emoji
1618
telegram.error
1719
telegram.forcereply
18-
telegram.groupchat
20+
telegram.chat
1921
telegram.inputfile
2022
telegram.location
2123
telegram.message

docs/source/telegram.updater.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
telegram.updater module
2+
=========================
3+
4+
.. automodule:: telegram.updater
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def requirements():
2626

2727
setup(
2828
name='python-telegram-bot',
29-
version='3.0.0',
29+
version='3.1.0',
3030
author='Leandro Toledo',
3131
author_email='leandrotoledodesouza@gmail.com',
3232
license='LGPLv3',

telegram/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"""A library that provides a Python interface to the Telegram Bot API"""
2020

2121
__author__ = 'leandrotoledodesouza@gmail.com'
22-
__version__ = '3.0.0'
22+
__version__ = '3.1.0'
2323

2424
from .base import TelegramObject
2525
from .user import User
26-
from .groupchat import GroupChat
26+
from .chat import Chat
2727
from .photosize import PhotoSize
2828
from .audio import Audio
2929
from .voice import Voice
@@ -54,5 +54,5 @@
5454
'InputFile', 'ReplyMarkup', 'ForceReply', 'ReplyKeyboardHide',
5555
'ReplyKeyboardMarkup', 'UserProfilePhotos', 'ChatAction',
5656
'Location', 'Contact', 'Video', 'Sticker', 'Document', 'File',
57-
'Audio', 'PhotoSize', 'GroupChat', 'Update', 'ParseMode', 'Message',
57+
'Audio', 'PhotoSize', 'Chat', 'Update', 'ParseMode', 'Message',
5858
'User', 'TelegramObject', 'NullHandler', 'Voice']

telegram/bot.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ def sendMessage(self,
191191
192192
Args:
193193
chat_id:
194-
Unique identifier for the message recipient - telegram.User or
195-
telegram.GroupChat id.
194+
Unique identifier for the message recipient - telegram.Chat id.
196195
parse_mode:
197196
Send Markdown, if you want Telegram apps to show bold, italic and
198197
inline URLs in your bot's message. For the moment, only Telegram
@@ -234,10 +233,10 @@ def forwardMessage(self,
234233
235234
Args:
236235
chat_id:
237-
Unique identifier for the message recipient - User or GroupChat id.
236+
Unique identifier for the message recipient - Chat id.
238237
from_chat_id:
239238
Unique identifier for the chat where the original message was sent
240-
- User or GroupChat id.
239+
- Chat id.
241240
message_id:
242241
Unique message identifier.
243242
@@ -268,7 +267,7 @@ def sendPhoto(self,
268267
269268
Args:
270269
chat_id:
271-
Unique identifier for the message recipient - User or GroupChat id.
270+
Unique identifier for the message recipient - Chat id.
272271
photo:
273272
Photo to send. You can either pass a file_id as String to resend a
274273
photo that is already on the Telegram servers, or upload a new
@@ -319,7 +318,7 @@ def sendAudio(self,
319318
320319
Args:
321320
chat_id:
322-
Unique identifier for the message recipient - User or GroupChat id.
321+
Unique identifier for the message recipient - Chat id.
323322
audio:
324323
Audio file to send. You can either pass a file_id as String to
325324
resend an audio that is already on the Telegram servers, or upload
@@ -366,7 +365,7 @@ def sendDocument(self,
366365
367366
Args:
368367
chat_id:
369-
Unique identifier for the message recipient - User or GroupChat id.
368+
Unique identifier for the message recipient - Chat id.
370369
document:
371370
File to send. You can either pass a file_id as String to resend a
372371
file that is already on the Telegram servers, or upload a new file
@@ -405,7 +404,7 @@ def sendSticker(self,
405404
406405
Args:
407406
chat_id:
408-
Unique identifier for the message recipient - User or GroupChat id.
407+
Unique identifier for the message recipient - Chat id.
409408
sticker:
410409
Sticker to send. You can either pass a file_id as String to resend
411410
a sticker that is already on the Telegram servers, or upload a new
@@ -441,7 +440,7 @@ def sendVideo(self,
441440
442441
Args:
443442
chat_id:
444-
Unique identifier for the message recipient - User or GroupChat id.
443+
Unique identifier for the message recipient - Chat id.
445444
video:
446445
Video to send. You can either pass a file_id as String to resend a
447446
video that is already on the Telegram servers, or upload a new
@@ -490,7 +489,7 @@ def sendVoice(self,
490489
491490
Args:
492491
chat_id:
493-
Unique identifier for the message recipient - User or GroupChat id.
492+
Unique identifier for the message recipient - Chat id.
494493
voice:
495494
Audio file to send. You can either pass a file_id as String to
496495
resend an audio that is already on the Telegram servers, or upload
@@ -529,7 +528,7 @@ def sendLocation(self,
529528
530529
Args:
531530
chat_id:
532-
Unique identifier for the message recipient - User or GroupChat id.
531+
Unique identifier for the message recipient - Chat id.
533532
latitude:
534533
Latitude of location.
535534
longitude:
@@ -565,7 +564,7 @@ def sendChatAction(self,
565564
566565
Args:
567566
chat_id:
568-
Unique identifier for the message recipient - User or GroupChat id.
567+
Unique identifier for the message recipient - Chat id.
569568
action:
570569
Type of action to broadcast. Choose one, depending on what the user
571570
is about to receive:

telegram/groupchat.py renamed to telegram/chat.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,25 @@
1717
# You should have received a copy of the GNU Lesser Public License
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919

20-
"""This module contains a object that represents a Telegram GroupChat"""
20+
"""This module contains a object that represents a Telegram Chat"""
2121

2222
from telegram import TelegramObject
2323

2424

25-
class GroupChat(TelegramObject):
26-
"""This object represents a Telegram GroupChat.
25+
class Chat(TelegramObject):
26+
"""This object represents a Telegram Chat.
2727
2828
Attributes:
2929
id (int):
30-
title (str):
31-
type (str):
30+
type (str): Can be 'private', 'group', 'supergroup' or 'channel'
31+
title (str): Title, for channels and group chats
32+
username (str): Username, for private chats and channels if available
33+
first_name (str): First name of the other party in a private chat
34+
last_name (str): Last name of the other party in a private chat
3235
3336
Args:
3437
id (int):
35-
title (str):
38+
type (str):
3639
**kwargs: Arbitrary keyword arguments.
3740
3841
Keyword Args:
@@ -41,24 +44,27 @@ class GroupChat(TelegramObject):
4144

4245
def __init__(self,
4346
id,
44-
title,
47+
type,
4548
**kwargs):
4649
# Required
4750
self.id = int(id)
48-
self.title = title
51+
self.type = type
4952
# Optionals
50-
self.type = kwargs.get('type', '')
53+
self.title = kwargs.get('title', '')
54+
self.username = kwargs.get('username', '')
55+
self.first_name = kwargs.get('first_name', '')
56+
self.last_name = kwargs.get('last_name', '')
5157

5258
@staticmethod
5359
def de_json(data):
5460
"""
5561
Args:
56-
data (str):
62+
data (dict):
5763
5864
Returns:
59-
telegram.GroupChat:
65+
telegram.Chat:
6066
"""
6167
if not data:
6268
return None
6369

64-
return GroupChat(**data)
70+
return Chat(**data)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy