diff --git a/telegram/audio.py b/telegram/audio.py index 926051d92..58880edc3 100644 --- a/telegram/audio.py +++ b/telegram/audio.py @@ -22,7 +22,7 @@ class Audio(TelegramObject): mime_type=data.get('mime_type', None), file_size=data.get('file_size', None)) - def to_data(self): + def to_dict(self): data = {'file_id': self.file_id, 'duration': self.duration} if self.mime_type: diff --git a/telegram/base.py b/telegram/base.py index cc7ac6d35..c8bfb6121 100644 --- a/telegram/base.py +++ b/telegram/base.py @@ -11,7 +11,7 @@ class TelegramObject(object): __metaclass__ = ABCMeta def __str__(self): - return self.to_data() + return str(self.to_dict()) def __getitem__(self, item): return self.__dict__[item] @@ -21,8 +21,8 @@ class TelegramObject(object): raise NotImplementedError def to_json(self): - return json.dumps(self.to_data()) + return json.dumps(self.to_dict()) @abstractmethod - def to_data(self): + def to_dict(self): return diff --git a/telegram/contact.py b/telegram/contact.py index 5dc39c130..bdffec867 100644 --- a/telegram/contact.py +++ b/telegram/contact.py @@ -22,7 +22,7 @@ class Contact(TelegramObject): last_name=data.get('last_name', None), user_id=data.get('user_id', None)) - def to_data(self): + def to_dict(self): data = {'phone_number': self.phone_number, 'first_name': self.first_name} if self.last_name: diff --git a/telegram/document.py b/telegram/document.py index 64a8decd3..14cc1efdb 100644 --- a/telegram/document.py +++ b/telegram/document.py @@ -31,9 +31,9 @@ class Document(TelegramObject): mime_type=data.get('mime_type', None), file_size=data.get('file_size', None)) - def to_data(self): + def to_dict(self): data = {'file_id': self.file_id, - 'thumb': self.thumb.to_data()} + 'thumb': self.thumb.to_dict()} if self.file_name: data['file_name'] = self.file_name if self.mime_type: diff --git a/telegram/forcereply.py b/telegram/forcereply.py index 8f2dcf78b..f677dd542 100644 --- a/telegram/forcereply.py +++ b/telegram/forcereply.py @@ -16,7 +16,7 @@ class ForceReply(TelegramObject): return ForceReply(force_reply=data.get('force_reply', None), selective=data.get('selective', None)) - def to_data(self): + def to_dict(self): data = {'force_reply': self.force_reply} if self.selective: data['selective'] = self.selective diff --git a/telegram/groupchat.py b/telegram/groupchat.py index e60f67115..6aed375da 100644 --- a/telegram/groupchat.py +++ b/telegram/groupchat.py @@ -16,7 +16,7 @@ class GroupChat(TelegramObject): return GroupChat(id=data.get('id', None), title=data.get('title', None)) - def to_data(self): + def to_dict(self): data = {'id': self.id, 'title': self.title} return data diff --git a/telegram/location.py b/telegram/location.py index 4e05b9e00..7a9c199f6 100644 --- a/telegram/location.py +++ b/telegram/location.py @@ -16,7 +16,7 @@ class Location(TelegramObject): return Location(longitude=data.get('longitude', None), latitude=data.get('latitude', None)) - def to_data(self): + def to_dict(self): data = {'longitude': self.longitude, 'latitude': self.latitude} return data diff --git a/telegram/message.py b/telegram/message.py index 4f22275b0..c641256a1 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -163,11 +163,11 @@ class Message(TelegramObject): delete_chat_photo=data.get('delete_chat_photo', None), group_chat_created=data.get('group_chat_created', None)) - def to_data(self): + def to_dict(self): data = {'message_id': self.message_id, - 'from': self.from_user.to_data(), + 'from': self.from_user.to_dict(), 'date': self.date, - 'chat': self.chat.to_data()} + 'chat': self.chat.to_dict()} if self.forward_from: data['forward_from'] = self.forward_from if self.forward_date: @@ -177,19 +177,19 @@ class Message(TelegramObject): if self.text: data['text'] = self.text if self.audio: - data['audio'] = self.audio.to_data() + data['audio'] = self.audio.to_dict() if self.document: - data['document'] = self.document.to_data() + data['document'] = self.document.to_dict() if self.photo: - data['photo'] = self.photo.to_data() + data['photo'] = [p.to_dict() for p in self.photo] if self.sticker: - data['sticker'] = self.sticker.to_data() + data['sticker'] = self.sticker.to_dict() if self.video: - data['video'] = self.video.to_data() + data['video'] = self.video.to_dict() if self.contact: - data['contact'] = self.contact.to_data() + data['contact'] = self.contact.to_dict() if self.location: - data['location'] = self.location.to_data() + data['location'] = self.location.to_dict() if self.new_chat_participant: data['new_chat_participant'] = self.new_chat_participant if self.left_chat_participant: diff --git a/telegram/photosize.py b/telegram/photosize.py index 82030926c..653ece6fe 100644 --- a/telegram/photosize.py +++ b/telegram/photosize.py @@ -22,7 +22,7 @@ class PhotoSize(TelegramObject): height=data.get('height', None), file_size=data.get('file_size', None)) - def to_data(self): + def to_dict(self): data = {'file_id': self.file_id, 'width': self.width, 'height': self.height} diff --git a/telegram/replykeyboardhide.py b/telegram/replykeyboardhide.py index 53d8c58b9..c59155d2f 100644 --- a/telegram/replykeyboardhide.py +++ b/telegram/replykeyboardhide.py @@ -16,7 +16,7 @@ class ReplyKeyboardHide(ReplyMarkup): return ReplyKeyboardHide(hide_keyboard=data.get('hide_keyboard', None), selective=data.get('selective', None)) - def to_data(self): + def to_dict(self): data = {'hide_keyboard': self.hide_keyboard} if self.selective: data['selective'] = self.selective diff --git a/telegram/replykeyboardmarkup.py b/telegram/replykeyboardmarkup.py index df52e2407..a3bd7ea78 100644 --- a/telegram/replykeyboardmarkup.py +++ b/telegram/replykeyboardmarkup.py @@ -26,7 +26,7 @@ class ReplyKeyboardMarkup(ReplyMarkup): ), selective=data.get('selective', None)) - def to_data(self): + def to_dict(self): data = {'keyboard': self.keyboard} if self.resize_keyboard: data['resize_keyboard'] = self.resize_keyboard diff --git a/telegram/sticker.py b/telegram/sticker.py index 46ef1af4c..b73dac993 100644 --- a/telegram/sticker.py +++ b/telegram/sticker.py @@ -31,11 +31,11 @@ class Sticker(TelegramObject): thumb=thumb, file_size=data.get('file_size', None)) - def to_data(self): + def to_dict(self): data = {'file_id': self.file_id, 'width': self.width, 'height': self.height, - 'thumb': self.thumb.to_data()} + 'thumb': self.thumb.to_dict()} if self.file_size: data['file_size'] = self.file_size return data diff --git a/telegram/update.py b/telegram/update.py index 9030fafbf..57c72b35e 100644 --- a/telegram/update.py +++ b/telegram/update.py @@ -22,8 +22,8 @@ class Update(TelegramObject): return Update(update_id=data.get('update_id', None), message=message) - def to_data(self): + def to_dict(self): data = {'update_id': self.update_id} if self.message: - data['message'] = self.message.to_data() + data['message'] = self.message.to_dict() return data diff --git a/telegram/user.py b/telegram/user.py index d9dd67701..68f06a2d4 100644 --- a/telegram/user.py +++ b/telegram/user.py @@ -30,7 +30,7 @@ class User(TelegramObject): last_name=data.get('last_name', None), username=data.get('username', None)) - def to_data(self): + def to_dict(self): data = {'id': self.id, 'first_name': self.first_name} if self.last_name: diff --git a/telegram/userprofilephotos.py b/telegram/userprofilephotos.py index 64395ff34..77290bd31 100644 --- a/telegram/userprofilephotos.py +++ b/telegram/userprofilephotos.py @@ -24,12 +24,12 @@ class UserProfilePhotos(TelegramObject): return UserProfilePhotos(total_count=data.get('total_count', None), photos=photos) - def to_data(self): + def to_dict(self): data = {} if self.total_count: data['total_count'] = self.total_count if self.photos: data['photos'] = [] for photo in self.photos: - data['photos'].append([x.to_data() for x in photo]) + data['photos'].append([x.to_dict() for x in photo]) return data diff --git a/telegram/video.py b/telegram/video.py index e5fac4f6e..e4690631c 100644 --- a/telegram/video.py +++ b/telegram/video.py @@ -40,12 +40,12 @@ class Video(TelegramObject): file_size=data.get('file_size', None), caption=data.get('caption', None)) - def to_data(self): + def to_dict(self): data = {'file_id': self.file_id, 'width': self.width, 'height': self.height, 'duration': self.duration, - 'thumb': self.thumb.to_data()} + 'thumb': self.thumb.to_dict()} if self.mime_type: data['mime_type'] = self.mime_type if self.file_size: