mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-26 16:38:53 +01:00
PEP8
This commit is contained in:
parent
bfe5b79ad9
commit
b2a4d4f5fc
9 changed files with 102 additions and 114 deletions
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
|
|
||||||
class Contact(object):
|
class Contact(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
phone_number,
|
||||||
'phone_number': None,
|
first_name,
|
||||||
'first_name': None,
|
last_name=None,
|
||||||
'last_name': None,
|
user_id=None):
|
||||||
'user_id': None
|
self.phone_number = phone_number
|
||||||
}
|
self.first_name = first_name
|
||||||
|
self.last_name = last_name
|
||||||
for (param, default) in param_defaults.iteritems():
|
self.user_id = user_id
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -6,14 +6,11 @@ from replymarkup import ReplyMarkup
|
||||||
|
|
||||||
|
|
||||||
class ForceReply(ReplyMarkup):
|
class ForceReply(ReplyMarkup):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
force_reply=True,
|
||||||
'force_reply': True,
|
selective=None):
|
||||||
'selective': None
|
self.force_reply = force_reply
|
||||||
}
|
self.selective = selective
|
||||||
|
|
||||||
for (param, default) in param_defaults.iteritems():
|
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,18 +2,11 @@
|
||||||
|
|
||||||
|
|
||||||
class GroupChat(object):
|
class GroupChat(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
id,
|
||||||
'id': None,
|
title):
|
||||||
'title': None
|
self.id = id
|
||||||
}
|
self.title = title
|
||||||
|
|
||||||
for (param, default) in param_defaults.iteritems():
|
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def chat_id(self):
|
|
||||||
return self.id
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
|
|
||||||
class Location(object):
|
class Location(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
longitude,
|
||||||
'longitude': None,
|
latitude):
|
||||||
'latitude': None,
|
self.longitude = longitude
|
||||||
}
|
self.latitude = latitude
|
||||||
|
|
||||||
for (param, default) in param_defaults.iteritems():
|
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,33 +2,49 @@
|
||||||
|
|
||||||
|
|
||||||
class Message(object):
|
class Message(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
message_id,
|
||||||
'message_id': None,
|
from_user,
|
||||||
'user': None,
|
date,
|
||||||
'date': None,
|
chat,
|
||||||
'chat': None,
|
forward_from=None,
|
||||||
'forward_from': None,
|
forward_date=None,
|
||||||
'forward_date': None,
|
reply_to_message=None,
|
||||||
'reply_to_message': None,
|
text=None,
|
||||||
'text': None,
|
audio=None,
|
||||||
'audio': None,
|
document=None,
|
||||||
'document': None,
|
photo=None,
|
||||||
'photo': None,
|
sticker=None,
|
||||||
'sticker': None,
|
video=None,
|
||||||
'video': None,
|
contact=None,
|
||||||
'contact': None,
|
location=None,
|
||||||
'location': None,
|
new_chat_participant=None,
|
||||||
'new_chat_participant': None,
|
left_chat_participant=None,
|
||||||
'left_chat_participant': None,
|
new_chat_title=None,
|
||||||
'new_chat_title': None,
|
new_chat_photo=None,
|
||||||
'new_chat_photo': None,
|
delete_chat_photo=None,
|
||||||
'delete_chat_photo': None,
|
group_chat_created=None):
|
||||||
'group_chat_created': None
|
self.message_id = message_id
|
||||||
}
|
self.from_user = from_user
|
||||||
|
self.date = date
|
||||||
for (param, default) in param_defaults.iteritems():
|
self.chat = chat
|
||||||
setattr(self, param, kwargs.get(param, default))
|
self.forward_from = forward_from
|
||||||
|
self.forward_date = forward_date
|
||||||
|
self.reply_to_message = reply_to_message
|
||||||
|
self.text = text
|
||||||
|
self.audio = audio
|
||||||
|
self.document = document
|
||||||
|
self.photo = photo
|
||||||
|
self.sticker = sticker
|
||||||
|
self.video = video
|
||||||
|
self.contact = contact
|
||||||
|
self.location = location
|
||||||
|
self.new_chat_participant = new_chat_participant
|
||||||
|
self.left_chat_participant = left_chat_participant
|
||||||
|
self.new_chat_title = new_chat_title
|
||||||
|
self.new_chat_photo = new_chat_photo
|
||||||
|
self.delete_chat_photo = delete_chat_photo
|
||||||
|
self.group_chat_created = group_chat_created
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def chat_id(self):
|
def chat_id(self):
|
||||||
|
@ -36,11 +52,11 @@ class Message(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
if 'from' in data: # from on api
|
if 'from' in data: # from is a reserved word, use user_from instead.
|
||||||
from telegram import User
|
from telegram import User
|
||||||
user = User.de_json(data['from'])
|
from_user = User.de_json(data['from'])
|
||||||
else:
|
else:
|
||||||
user = None
|
from_user = None
|
||||||
|
|
||||||
if 'chat' in data:
|
if 'chat' in data:
|
||||||
if 'username' in data['chat']:
|
if 'username' in data['chat']:
|
||||||
|
@ -59,9 +75,7 @@ class Message(object):
|
||||||
forward_from = None
|
forward_from = None
|
||||||
|
|
||||||
if 'reply_to_message' in data:
|
if 'reply_to_message' in data:
|
||||||
reply_to_message = Message.de_json(
|
reply_to_message = Message.de_json(data['reply_to_message'])
|
||||||
data['reply_to_message']
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
reply_to_message = None
|
reply_to_message = None
|
||||||
|
|
||||||
|
@ -109,22 +123,18 @@ class Message(object):
|
||||||
|
|
||||||
if 'new_chat_participant' in data:
|
if 'new_chat_participant' in data:
|
||||||
from telegram import User
|
from telegram import User
|
||||||
new_chat_participant = User.de_json(
|
new_chat_participant = User.de_json(data['new_chat_participant'])
|
||||||
data['new_chat_participant']
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
new_chat_participant = None
|
new_chat_participant = None
|
||||||
|
|
||||||
if 'left_chat_participant' in data:
|
if 'left_chat_participant' in data:
|
||||||
from telegram import User
|
from telegram import User
|
||||||
left_chat_participant = User.de_json(
|
left_chat_participant = User.de_json(data['left_chat_participant'])
|
||||||
data['left_chat_participant']
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
left_chat_participant = None
|
left_chat_participant = None
|
||||||
|
|
||||||
return Message(message_id=data.get('message_id', None),
|
return Message(message_id=data.get('message_id', None),
|
||||||
user=user,
|
from_user=from_user,
|
||||||
date=data.get('date', None),
|
date=data.get('date', None),
|
||||||
chat=chat,
|
chat=chat,
|
||||||
forward_from=forward_from,
|
forward_from=forward_from,
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
|
|
||||||
class PhotoSize(object):
|
class PhotoSize(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
file_id,
|
||||||
'file_id': None,
|
width,
|
||||||
'width': None,
|
height,
|
||||||
'height': None,
|
file_size=None):
|
||||||
'file_size': None
|
self.file_id = file_id
|
||||||
}
|
self.width = width
|
||||||
|
self.height = height
|
||||||
for (param, default) in param_defaults.iteritems():
|
self.file_size = file_size
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
|
|
||||||
class Update(object):
|
class Update(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
update_id,
|
||||||
'update_id': None,
|
message=None):
|
||||||
'message': None
|
self.update_id = update_id
|
||||||
}
|
self.message = message
|
||||||
|
|
||||||
for (param, default) in param_defaults.iteritems():
|
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
id,
|
||||||
'id': None,
|
first_name,
|
||||||
'first_name': None,
|
last_name=None,
|
||||||
'last_name': None,
|
username=None):
|
||||||
'username': None
|
self.id = id
|
||||||
}
|
self.first_name = first_name
|
||||||
|
self.last_name = last_name
|
||||||
for (param, default) in param_defaults.iteritems():
|
self.username = username
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
|
|
||||||
class UserProfilePhotos(object):
|
class UserProfilePhotos(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self,
|
||||||
param_defaults = {
|
total_count,
|
||||||
'total_count': None,
|
photos):
|
||||||
'photos': None
|
self.total_count = total_count
|
||||||
}
|
self.photos = photos
|
||||||
|
|
||||||
for (param, default) in param_defaults.iteritems():
|
|
||||||
setattr(self, param, kwargs.get(param, default))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
|
|
Loading…
Add table
Reference in a new issue