X Tutup
Skip to content

Commit f4ad703

Browse files
committed
Fixes python-telegram-bot#12 and changes to_data to to_dict
1 parent 859f04e commit f4ad703

16 files changed

+32
-32
lines changed

telegram/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def de_json(data):
2222
mime_type=data.get('mime_type', None),
2323
file_size=data.get('file_size', None))
2424

25-
def to_data(self):
25+
def to_dict(self):
2626
data = {'file_id': self.file_id,
2727
'duration': self.duration}
2828
if self.mime_type:

telegram/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TelegramObject(object):
1111
__metaclass__ = ABCMeta
1212

1313
def __str__(self):
14-
return self.to_data()
14+
return str(self.to_dict())
1515

1616
def __getitem__(self, item):
1717
return self.__dict__[item]
@@ -21,8 +21,8 @@ def de_json(data):
2121
raise NotImplementedError
2222

2323
def to_json(self):
24-
return json.dumps(self.to_data())
24+
return json.dumps(self.to_dict())
2525

2626
@abstractmethod
27-
def to_data(self):
27+
def to_dict(self):
2828
return

telegram/contact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def de_json(data):
2222
last_name=data.get('last_name', None),
2323
user_id=data.get('user_id', None))
2424

25-
def to_data(self):
25+
def to_dict(self):
2626
data = {'phone_number': self.phone_number,
2727
'first_name': self.first_name}
2828
if self.last_name:

telegram/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def de_json(data):
3131
mime_type=data.get('mime_type', None),
3232
file_size=data.get('file_size', None))
3333

34-
def to_data(self):
34+
def to_dict(self):
3535
data = {'file_id': self.file_id,
36-
'thumb': self.thumb.to_data()}
36+
'thumb': self.thumb.to_dict()}
3737
if self.file_name:
3838
data['file_name'] = self.file_name
3939
if self.mime_type:

telegram/forcereply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def de_json(data):
1616
return ForceReply(force_reply=data.get('force_reply', None),
1717
selective=data.get('selective', None))
1818

19-
def to_data(self):
19+
def to_dict(self):
2020
data = {'force_reply': self.force_reply}
2121
if self.selective:
2222
data['selective'] = self.selective

telegram/groupchat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def de_json(data):
1616
return GroupChat(id=data.get('id', None),
1717
title=data.get('title', None))
1818

19-
def to_data(self):
19+
def to_dict(self):
2020
data = {'id': self.id,
2121
'title': self.title}
2222
return data

telegram/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def de_json(data):
1616
return Location(longitude=data.get('longitude', None),
1717
latitude=data.get('latitude', None))
1818

19-
def to_data(self):
19+
def to_dict(self):
2020
data = {'longitude': self.longitude,
2121
'latitude': self.latitude}
2222
return data

telegram/message.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def de_json(data):
163163
delete_chat_photo=data.get('delete_chat_photo', None),
164164
group_chat_created=data.get('group_chat_created', None))
165165

166-
def to_data(self):
166+
def to_dict(self):
167167
data = {'message_id': self.message_id,
168-
'from': self.from_user.to_data(),
168+
'from': self.from_user.to_dict(),
169169
'date': self.date,
170-
'chat': self.chat.to_data()}
170+
'chat': self.chat.to_dict()}
171171
if self.forward_from:
172172
data['forward_from'] = self.forward_from
173173
if self.forward_date:
@@ -177,19 +177,19 @@ def to_data(self):
177177
if self.text:
178178
data['text'] = self.text
179179
if self.audio:
180-
data['audio'] = self.audio.to_data()
180+
data['audio'] = self.audio.to_dict()
181181
if self.document:
182-
data['document'] = self.document.to_data()
182+
data['document'] = self.document.to_dict()
183183
if self.photo:
184-
data['photo'] = self.photo.to_data()
184+
data['photo'] = [p.to_dict() for p in self.photo]
185185
if self.sticker:
186-
data['sticker'] = self.sticker.to_data()
186+
data['sticker'] = self.sticker.to_dict()
187187
if self.video:
188-
data['video'] = self.video.to_data()
188+
data['video'] = self.video.to_dict()
189189
if self.contact:
190-
data['contact'] = self.contact.to_data()
190+
data['contact'] = self.contact.to_dict()
191191
if self.location:
192-
data['location'] = self.location.to_data()
192+
data['location'] = self.location.to_dict()
193193
if self.new_chat_participant:
194194
data['new_chat_participant'] = self.new_chat_participant
195195
if self.left_chat_participant:

telegram/photosize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def de_json(data):
2222
height=data.get('height', None),
2323
file_size=data.get('file_size', None))
2424

25-
def to_data(self):
25+
def to_dict(self):
2626
data = {'file_id': self.file_id,
2727
'width': self.width,
2828
'height': self.height}

telegram/replykeyboardhide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def de_json(data):
1616
return ReplyKeyboardHide(hide_keyboard=data.get('hide_keyboard', None),
1717
selective=data.get('selective', None))
1818

19-
def to_data(self):
19+
def to_dict(self):
2020
data = {'hide_keyboard': self.hide_keyboard}
2121
if self.selective:
2222
data['selective'] = self.selective

0 commit comments

Comments
 (0)
X Tutup