Skip to content

Commit b2a4d4f

Browse files
committed
PEP8
1 parent bfe5b79 commit b2a4d4f

File tree

9 files changed

+102
-114
lines changed

9 files changed

+102
-114
lines changed

telegram/contact.py

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

33

44
class Contact(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'phone_number': None,
8-
'first_name': None,
9-
'last_name': None,
10-
'user_id': None
11-
}
12-
13-
for (param, default) in param_defaults.iteritems():
14-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
phone_number,
7+
first_name,
8+
last_name=None,
9+
user_id=None):
10+
self.phone_number = phone_number
11+
self.first_name = first_name
12+
self.last_name = last_name
13+
self.user_id = user_id
1514

1615
@staticmethod
1716
def de_json(data):

telegram/forcereply.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66

77

88
class ForceReply(ReplyMarkup):
9-
def __init__(self, **kwargs):
10-
param_defaults = {
11-
'force_reply': True,
12-
'selective': None
13-
}
14-
15-
for (param, default) in param_defaults.iteritems():
16-
setattr(self, param, kwargs.get(param, default))
9+
def __init__(self,
10+
force_reply=True,
11+
selective=None):
12+
self.force_reply = force_reply
13+
self.selective = selective
1714

1815
@staticmethod
1916
def de_json(data):

telegram/groupchat.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22

33

44
class GroupChat(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'id': None,
8-
'title': None
9-
}
10-
11-
for (param, default) in param_defaults.iteritems():
12-
setattr(self, param, kwargs.get(param, default))
13-
14-
@property
15-
def chat_id(self):
16-
return self.id
5+
def __init__(self,
6+
id,
7+
title):
8+
self.id = id
9+
self.title = title
1710

1811
@staticmethod
1912
def de_json(data):

telegram/location.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33

44
class Location(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'longitude': None,
8-
'latitude': None,
9-
}
10-
11-
for (param, default) in param_defaults.iteritems():
12-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
longitude,
7+
latitude):
8+
self.longitude = longitude
9+
self.latitude = latitude
1310

1411
@staticmethod
1512
def de_json(data):

telegram/message.py

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,61 @@
22

33

44
class Message(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'message_id': None,
8-
'user': None,
9-
'date': None,
10-
'chat': None,
11-
'forward_from': None,
12-
'forward_date': None,
13-
'reply_to_message': None,
14-
'text': None,
15-
'audio': None,
16-
'document': None,
17-
'photo': None,
18-
'sticker': None,
19-
'video': None,
20-
'contact': None,
21-
'location': None,
22-
'new_chat_participant': None,
23-
'left_chat_participant': None,
24-
'new_chat_title': None,
25-
'new_chat_photo': None,
26-
'delete_chat_photo': None,
27-
'group_chat_created': None
28-
}
29-
30-
for (param, default) in param_defaults.iteritems():
31-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
message_id,
7+
from_user,
8+
date,
9+
chat,
10+
forward_from=None,
11+
forward_date=None,
12+
reply_to_message=None,
13+
text=None,
14+
audio=None,
15+
document=None,
16+
photo=None,
17+
sticker=None,
18+
video=None,
19+
contact=None,
20+
location=None,
21+
new_chat_participant=None,
22+
left_chat_participant=None,
23+
new_chat_title=None,
24+
new_chat_photo=None,
25+
delete_chat_photo=None,
26+
group_chat_created=None):
27+
self.message_id = message_id
28+
self.from_user = from_user
29+
self.date = date
30+
self.chat = chat
31+
self.forward_from = forward_from
32+
self.forward_date = forward_date
33+
self.reply_to_message = reply_to_message
34+
self.text = text
35+
self.audio = audio
36+
self.document = document
37+
self.photo = photo
38+
self.sticker = sticker
39+
self.video = video
40+
self.contact = contact
41+
self.location = location
42+
self.new_chat_participant = new_chat_participant
43+
self.left_chat_participant = left_chat_participant
44+
self.new_chat_title = new_chat_title
45+
self.new_chat_photo = new_chat_photo
46+
self.delete_chat_photo = delete_chat_photo
47+
self.group_chat_created = group_chat_created
3248

3349
@property
3450
def chat_id(self):
3551
return self.chat.id
3652

3753
@staticmethod
3854
def de_json(data):
39-
if 'from' in data: # from on api
55+
if 'from' in data: # from is a reserved word, use user_from instead.
4056
from telegram import User
41-
user = User.de_json(data['from'])
57+
from_user = User.de_json(data['from'])
4258
else:
43-
user = None
59+
from_user = None
4460

4561
if 'chat' in data:
4662
if 'username' in data['chat']:
@@ -59,9 +75,7 @@ def de_json(data):
5975
forward_from = None
6076

6177
if 'reply_to_message' in data:
62-
reply_to_message = Message.de_json(
63-
data['reply_to_message']
64-
)
78+
reply_to_message = Message.de_json(data['reply_to_message'])
6579
else:
6680
reply_to_message = None
6781

@@ -109,22 +123,18 @@ def de_json(data):
109123

110124
if 'new_chat_participant' in data:
111125
from telegram import User
112-
new_chat_participant = User.de_json(
113-
data['new_chat_participant']
114-
)
126+
new_chat_participant = User.de_json(data['new_chat_participant'])
115127
else:
116128
new_chat_participant = None
117129

118130
if 'left_chat_participant' in data:
119131
from telegram import User
120-
left_chat_participant = User.de_json(
121-
data['left_chat_participant']
122-
)
132+
left_chat_participant = User.de_json(data['left_chat_participant'])
123133
else:
124134
left_chat_participant = None
125135

126136
return Message(message_id=data.get('message_id', None),
127-
user=user,
137+
from_user=from_user,
128138
date=data.get('date', None),
129139
chat=chat,
130140
forward_from=forward_from,

telegram/photosize.py

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

33

44
class PhotoSize(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'file_id': None,
8-
'width': None,
9-
'height': None,
10-
'file_size': None
11-
}
12-
13-
for (param, default) in param_defaults.iteritems():
14-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
file_id,
7+
width,
8+
height,
9+
file_size=None):
10+
self.file_id = file_id
11+
self.width = width
12+
self.height = height
13+
self.file_size = file_size
1514

1615
@staticmethod
1716
def de_json(data):

telegram/update.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33

44
class Update(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'update_id': None,
8-
'message': None
9-
}
10-
11-
for (param, default) in param_defaults.iteritems():
12-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
update_id,
7+
message=None):
8+
self.update_id = update_id
9+
self.message = message
1310

1411
@staticmethod
1512
def de_json(data):

telegram/user.py

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

33

44
class User(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'id': None,
8-
'first_name': None,
9-
'last_name': None,
10-
'username': None
11-
}
12-
13-
for (param, default) in param_defaults.iteritems():
14-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
id,
7+
first_name,
8+
last_name=None,
9+
username=None):
10+
self.id = id
11+
self.first_name = first_name
12+
self.last_name = last_name
13+
self.username = username
1514

1615
@staticmethod
1716
def de_json(data):

telegram/userprofilephotos.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33

44
class UserProfilePhotos(object):
5-
def __init__(self, **kwargs):
6-
param_defaults = {
7-
'total_count': None,
8-
'photos': None
9-
}
10-
11-
for (param, default) in param_defaults.iteritems():
12-
setattr(self, param, kwargs.get(param, default))
5+
def __init__(self,
6+
total_count,
7+
photos):
8+
self.total_count = total_count
9+
self.photos = photos
1310

1411
@staticmethod
1512
def de_json(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