X Tutup
Skip to content

Commit ce852de

Browse files
committed
base class for telegram class
1 parent 5460671 commit ce852de

File tree

15 files changed

+65
-68
lines changed

15 files changed

+65
-68
lines changed

telegram/audio.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Audio(object):
8+
class Audio(Base):
89
def __init__(self,
910
file_id,
1011
duration,
@@ -30,6 +31,3 @@ def to_json(self):
3031
if self.file_size:
3132
json_data['file_size'] = self.file_size
3233
return json.dumps(json_data)
33-
34-
def __str__(self):
35-
return self.to_json()

telegram/contact.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Contact(object):
8+
class Contact(Base):
89
def __init__(self,
910
phone_number,
1011
first_name,
@@ -29,7 +30,4 @@ def to_json(self):
2930
json_data['last_name'] = self.last_name
3031
if self.user_id:
3132
json_data['user_id'] = self.user_id
32-
return json.dumps(json_data)
33-
34-
def __str__(self):
35-
return self.to_json()
33+
return json.dumps(json_data)

telegram/document.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Document(object):
8+
class Document(Base):
89
def __init__(self,
910
file_id,
1011
thumb,
@@ -40,7 +41,4 @@ def to_json(self):
4041
json_data['mime_type'] = self.mime_type
4142
if self.file_size:
4243
json_data['file_size'] = self.file_size
43-
return json.dumps(json_data)
44-
45-
def __str__(self):
46-
return self.to_json()
44+
return json.dumps(json_data)

telegram/forcereply.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ def to_json(self):
2121
json_data = {'force_reply': self.force_reply}
2222
if self.selective:
2323
json_data['selective'] = self.selective
24-
return json.dumps(json_data)
25-
26-
def __str__(self):
27-
return self.to_json()
24+
return json.dumps(json_data)

telegram/groupchat.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class GroupChat(object):
8+
class GroupChat(Base):
89
def __init__(self,
910
id,
1011
title):
@@ -19,7 +20,4 @@ def de_json(data):
1920
def to_json(self):
2021
json_data = {'id': self.id,
2122
'title': self.title}
22-
return json.dumps(json_data)
23-
24-
def __str__(self):
25-
return self.to_json()
23+
return json.dumps(json_data)

telegram/location.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Location(object):
8+
class Location(Base):
89
def __init__(self,
910
longitude,
1011
latitude):
@@ -19,7 +20,4 @@ def de_json(data):
1920
def to_json(self):
2021
json_data = {'longitude': self.longitude,
2122
'latitude': self.latitude}
22-
return json.dumps(json_data)
23-
24-
def __str__(self):
25-
return self.to_json()
23+
return json.dumps(json_data)

telegram/message.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Message(object):
8+
class Message(Base):
89
def __init__(self,
910
message_id,
1011
from_user,
@@ -202,7 +203,4 @@ def to_json(self):
202203
json_data['delete_chat_photo'] = self.delete_chat_photo
203204
if self.group_chat_created:
204205
json_data['group_chat_created'] = self.group_chat_created
205-
return json.dumps(json_data)
206-
207-
def __str__(self):
208-
return self.to_json()
206+
return json.dumps(json_data)

telegram/photosize.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class PhotoSize(object):
8+
class PhotoSize(Base):
89
def __init__(self,
910
file_id,
1011
width,
@@ -28,7 +29,4 @@ def to_json(self):
2829
'height': self.height}
2930
if self.file_size:
3031
json_data['file_size'] = self.file_size
31-
return json.dumps(json_data)
32-
33-
def __str__(self):
34-
return self.to_json()
32+
return json.dumps(json_data)

telegram/replymarkup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/usr/bin/env python
2+
from .telegram_boject_base import Base
23

34

4-
class ReplyMarkup(object):
5+
class ReplyMarkup(Base):
56
def to_json(self):
6-
raise NotImplementedError
7-
8-
def __str__(self):
9-
return self.to_json()
7+
raise NotImplementedError

telegram/sticker.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44
import json
5+
from .telegram_boject_base import Base
56

67

7-
class Sticker(object):
8+
class Sticker(Base):
89
def __init__(self,
910
file_id,
1011
width,
@@ -38,7 +39,4 @@ def to_json(self):
3839
'thumb': self.thumb.to_json()}
3940
if self.file_size:
4041
json_data['file_size'] = self.file_size
41-
return json.dumps(json_data)
42-
43-
def __str__(self):
44-
return self.to_json()
42+
return json.dumps(json_data)

0 commit comments

Comments
 (0)
X Tutup