diff --git a/telegram/audio.py b/telegram/audio.py index 89ce7c5ba..0b49e9396 100644 --- a/telegram/audio.py +++ b/telegram/audio.py @@ -44,15 +44,22 @@ class Audio(TelegramObject): file_size (Optional[int]): """ - def __init__(self, file_id, duration, **kwargs): + def __init__(self, + file_id, + duration, + performer='', + title='', + mime_type='', + file_size=0, + **kwargs): # Required self.file_id = str(file_id) self.duration = int(duration) # Optionals - self.performer = kwargs.get('performer', '') - self.title = kwargs.get('title', '') - self.mime_type = str(kwargs.get('mime_type', '')) - self.file_size = int(kwargs.get('file_size', 0)) + self.performer = performer + self.title = title + self.mime_type = str(mime_type) + self.file_size = int(file_size) @staticmethod def de_json(data, bot): diff --git a/telegram/callbackquery.py b/telegram/callbackquery.py index 77332c50f..17850c501 100644 --- a/telegram/callbackquery.py +++ b/telegram/callbackquery.py @@ -25,14 +25,15 @@ from telegram import TelegramObject, Message, User class CallbackQuery(TelegramObject): """This object represents a Telegram CallbackQuery.""" - def __init__(self, id, from_user, data, bot=None, **kwargs): + def __init__(self, id, from_user, data, message=None, inline_message_id='', bot=None, + **kwargs): # Required self.id = id self.from_user = from_user self.data = data # Optionals - self.message = kwargs.get('message') - self.inline_message_id = kwargs.get('inline_message_id', '') + self.message = message + self.inline_message_id = inline_message_id self.bot = bot diff --git a/telegram/chat.py b/telegram/chat.py index 94ade4994..c28d7d3d4 100644 --- a/telegram/chat.py +++ b/telegram/chat.py @@ -48,15 +48,23 @@ class Chat(TelegramObject): SUPERGROUP = 'supergroup' CHANNEL = 'channel' - def __init__(self, id, type, bot=None, **kwargs): + def __init__(self, + id, + type, + title='', + username='', + first_name='', + last_name='', + bot=None, + **kwargs): # Required self.id = int(id) self.type = type # Optionals - self.title = kwargs.get('title', '') - self.username = kwargs.get('username', '') - self.first_name = kwargs.get('first_name', '') - self.last_name = kwargs.get('last_name', '') + self.title = title + self.username = username + self.first_name = first_name + self.last_name = last_name self.bot = bot diff --git a/telegram/contact.py b/telegram/contact.py index 48f7e3065..bd29cf984 100644 --- a/telegram/contact.py +++ b/telegram/contact.py @@ -40,13 +40,13 @@ class Contact(TelegramObject): user_id (Optional[int]): """ - def __init__(self, phone_number, first_name, **kwargs): + def __init__(self, phone_number, first_name, last_name='', user_id=0, **kwargs): # Required self.phone_number = str(phone_number) self.first_name = first_name # Optionals - self.last_name = kwargs.get('last_name', '') - self.user_id = int(kwargs.get('user_id', 0)) + self.last_name = last_name + self.user_id = int(user_id) @staticmethod def de_json(data, bot): diff --git a/telegram/document.py b/telegram/document.py index 4e16b02b5..2bc08ff8d 100644 --- a/telegram/document.py +++ b/telegram/document.py @@ -42,14 +42,14 @@ class Document(TelegramObject): file_size (Optional[int]): """ - def __init__(self, file_id, **kwargs): + def __init__(self, file_id, thumb=None, file_name='', mime_type='', file_size=0, **kwargs): # Required self.file_id = str(file_id) # Optionals - self.thumb = kwargs.get('thumb') - self.file_name = kwargs.get('file_name', '') - self.mime_type = str(kwargs.get('mime_type', '')) - self.file_size = int(kwargs.get('file_size', 0)) + self.thumb = thumb + self.file_name = file_name + self.mime_type = str(mime_type) + self.file_size = int(file_size) @staticmethod def de_json(data, bot): diff --git a/telegram/file.py b/telegram/file.py index b04e85cff..7b0fd0e08 100644 --- a/telegram/file.py +++ b/telegram/file.py @@ -42,13 +42,13 @@ class File(TelegramObject): """ - def __init__(self, file_id, bot, **kwargs): + def __init__(self, file_id, bot, file_size=0, file_path='', **kwargs): # Required self.file_id = str(file_id) # Optionals - self.file_size = int(kwargs.get('file_size', 0)) - self.file_path = str(kwargs.get('file_path', '')) + self.file_size = int(file_size) + self.file_path = str(file_path) self.bot = bot diff --git a/telegram/forcereply.py b/telegram/forcereply.py index 3993e2390..8ce2925c0 100644 --- a/telegram/forcereply.py +++ b/telegram/forcereply.py @@ -36,11 +36,11 @@ class ForceReply(ReplyMarkup): selective (Optional[bool]): """ - def __init__(self, force_reply=True, **kwargs): + def __init__(self, force_reply=True, selective=False, **kwargs): # Required self.force_reply = bool(force_reply) # Optionals - self.selective = bool(kwargs.get('selective', False)) + self.selective = bool(selective) @staticmethod def de_json(data, bot): diff --git a/telegram/inlinekeyboardbutton.py b/telegram/inlinekeyboardbutton.py index d2fbcc588..0abf0552b 100644 --- a/telegram/inlinekeyboardbutton.py +++ b/telegram/inlinekeyboardbutton.py @@ -42,14 +42,14 @@ class InlineKeyboardButton(TelegramObject): """ - def __init__(self, text, **kwargs): + def __init__(self, text, url=None, callback_data=None, switch_inline_query=None, **kwargs): # Required self.text = text # Optionals - self.url = kwargs.get('url') - self.callback_data = kwargs.get('callback_data') - self.switch_inline_query = kwargs.get('switch_inline_query') + self.url = url + self.callback_data = callback_data + self.switch_inline_query = switch_inline_query @staticmethod def de_json(data, bot): diff --git a/telegram/inlinequery.py b/telegram/inlinequery.py index 58e4f265b..17a9ad462 100644 --- a/telegram/inlinequery.py +++ b/telegram/inlinequery.py @@ -45,7 +45,7 @@ class InlineQuery(TelegramObject): bot (Optional[Bot]): The Bot to use for instance methods """ - def __init__(self, id, from_user, query, offset, bot=None, **kwargs): + def __init__(self, id, from_user, query, offset, location=None, bot=None, **kwargs): # Required self.id = id self.from_user = from_user @@ -53,7 +53,7 @@ class InlineQuery(TelegramObject): self.offset = offset # Optional - self.location = kwargs.get('location') + self.location = location self.bot = bot diff --git a/telegram/message.py b/telegram/message.py index 32f8fe45b..9c7865d4d 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -106,41 +106,77 @@ class Message(TelegramObject): bot (Optional[Bot]): The Bot to use for instance methods """ - def __init__(self, message_id, from_user, date, chat, bot=None, **kwargs): + def __init__(self, + message_id, + from_user, + date, + chat, + forward_from=None, + forward_from_chat=None, + forward_date=None, + reply_to_message=None, + edit_date=None, + text='', + entities=None, + audio=None, + document=None, + photo=None, + sticker=None, + video=None, + voice=None, + caption='', + contact=None, + location=None, + venue=None, + new_chat_member=None, + left_chat_member=None, + new_chat_title='', + new_chat_photo=None, + delete_chat_photo=False, + group_chat_created=False, + supergroup_chat_created=False, + migrate_to_chat_id=0, + migrate_from_chat_id=0, + channel_chat_created=False, + pinned_message=None, + bot=None, + **kwargs): # Required self.message_id = int(message_id) self.from_user = from_user self.date = date self.chat = chat # Optionals - self.forward_from = kwargs.get('forward_from') - self.forward_from_chat = kwargs.get('forward_from_chat') - self.forward_date = kwargs.get('forward_date') - self.reply_to_message = kwargs.get('reply_to_message') - self.edit_date = kwargs.get('edit_date') - self.text = kwargs.get('text', '') - self.entities = kwargs.get('entities', list()) - self.audio = kwargs.get('audio') - self.document = kwargs.get('document') - self.photo = kwargs.get('photo') - self.sticker = kwargs.get('sticker') - self.video = kwargs.get('video') - self.voice = kwargs.get('voice') - self.caption = kwargs.get('caption', '') - self.contact = kwargs.get('contact') - self.location = kwargs.get('location') - self.venue = kwargs.get('venue') - self.new_chat_member = kwargs.get('new_chat_member') - self.left_chat_member = kwargs.get('left_chat_member') - self.new_chat_title = kwargs.get('new_chat_title', '') - self.new_chat_photo = kwargs.get('new_chat_photo') - self.delete_chat_photo = bool(kwargs.get('delete_chat_photo', False)) - self.group_chat_created = bool(kwargs.get('group_chat_created', False)) - self.supergroup_chat_created = bool(kwargs.get('supergroup_chat_created', False)) - self.migrate_to_chat_id = int(kwargs.get('migrate_to_chat_id', 0)) - self.migrate_from_chat_id = int(kwargs.get('migrate_from_chat_id', 0)) - self.channel_chat_created = bool(kwargs.get('channel_chat_created', False)) - self.pinned_message = kwargs.get('pinned_message') + self.forward_from = forward_from + self.forward_from_chat = forward_from_chat + self.forward_date = forward_date + self.reply_to_message = reply_to_message + self.edit_date = edit_date + self.text = text + if entities is None: + entities = list() + self.entities = entities + self.audio = audio + self.document = document + self.photo = photo + self.sticker = sticker + self.video = video + self.voice = voice + self.caption = caption + self.contact = contact + self.location = location + self.venue = venue + self.new_chat_member = new_chat_member + self.left_chat_member = left_chat_member + self.new_chat_title = new_chat_title + self.new_chat_photo = new_chat_photo + self.delete_chat_photo = bool(delete_chat_photo) + self.group_chat_created = bool(group_chat_created) + self.supergroup_chat_created = bool(supergroup_chat_created) + self.migrate_to_chat_id = int(migrate_to_chat_id) + self.migrate_from_chat_id = int(migrate_from_chat_id) + self.channel_chat_created = bool(channel_chat_created) + self.pinned_message = pinned_message self.bot = bot diff --git a/telegram/messageentity.py b/telegram/messageentity.py index eb6a41248..cd87e09f3 100644 --- a/telegram/messageentity.py +++ b/telegram/messageentity.py @@ -34,14 +34,14 @@ class MessageEntity(TelegramObject): user (Optional[:class:`telegram.User`]): """ - def __init__(self, type, offset, length, **kwargs): + def __init__(self, type, offset, length, url=None, user=None, **kwargs): # Required self.type = type self.offset = offset self.length = length # Optionals - self.url = kwargs.get('url') - self.user = kwargs.get('user') + self.url = url + self.user = user @staticmethod def de_json(data, bot): diff --git a/telegram/photosize.py b/telegram/photosize.py index e708ab11d..dfc5b8d31 100644 --- a/telegram/photosize.py +++ b/telegram/photosize.py @@ -40,13 +40,13 @@ class PhotoSize(TelegramObject): file_size (Optional[int]): """ - def __init__(self, file_id, width, height, **kwargs): + def __init__(self, file_id, width, height, file_size=0, **kwargs): # Required self.file_id = str(file_id) self.width = int(width) self.height = int(height) # Optionals - self.file_size = int(kwargs.get('file_size', 0)) + self.file_size = int(file_size) def __eq__(self, other): if not isinstance(other, self.__class__): diff --git a/telegram/replykeyboardhide.py b/telegram/replykeyboardhide.py index ddc5ff414..b57052dd2 100644 --- a/telegram/replykeyboardhide.py +++ b/telegram/replykeyboardhide.py @@ -37,11 +37,11 @@ class ReplyKeyboardHide(ReplyMarkup): selective (Optional[bool]): """ - def __init__(self, hide_keyboard=True, **kwargs): + def __init__(self, hide_keyboard=True, selective=False, **kwargs): # Required self.hide_keyboard = bool(hide_keyboard) # Optionals - self.selective = bool(kwargs.get('selective', False)) + self.selective = bool(selective) @staticmethod def de_json(data, bot): diff --git a/telegram/replykeyboardmarkup.py b/telegram/replykeyboardmarkup.py index 17f00ff57..16275c751 100644 --- a/telegram/replykeyboardmarkup.py +++ b/telegram/replykeyboardmarkup.py @@ -41,13 +41,18 @@ class ReplyKeyboardMarkup(ReplyMarkup): selective (Optional[bool]): """ - def __init__(self, keyboard, **kwargs): + def __init__(self, + keyboard, + resize_keyboard=False, + one_time_keyboard=False, + selective=False, + **kwargs): # Required self.keyboard = keyboard # Optionals - self.resize_keyboard = bool(kwargs.get('resize_keyboard', False)) - self.one_time_keyboard = bool(kwargs.get('one_time_keyboard', False)) - self.selective = bool(kwargs.get('selective', False)) + self.resize_keyboard = bool(resize_keyboard) + self.one_time_keyboard = bool(one_time_keyboard) + self.selective = bool(selective) @staticmethod def de_json(data, bot): diff --git a/telegram/sticker.py b/telegram/sticker.py index b2255fb18..5eb54453e 100644 --- a/telegram/sticker.py +++ b/telegram/sticker.py @@ -44,15 +44,15 @@ class Sticker(TelegramObject): file_size (Optional[int]): """ - def __init__(self, file_id, width, height, **kwargs): + def __init__(self, file_id, width, height, thumb=None, emoji='', file_size=0, **kwargs): # Required self.file_id = str(file_id) self.width = int(width) self.height = int(height) # Optionals - self.thumb = kwargs.get('thumb') - self.emoji = kwargs.get('emoji', '') - self.file_size = int(kwargs.get('file_size', 0)) + self.thumb = thumb + self.emoji = emoji + self.file_size = int(file_size) @staticmethod def de_json(data, bot): diff --git a/telegram/update.py b/telegram/update.py index 08a164b99..f6c9a3257 100644 --- a/telegram/update.py +++ b/telegram/update.py @@ -44,15 +44,22 @@ class Update(TelegramObject): callback_query (Optional[:class:`telegram.CallbackQuery`]): """ - def __init__(self, update_id, **kwargs): + def __init__(self, + update_id, + message=None, + edited_message=None, + inline_query=None, + chosen_inline_result=None, + callback_query=None, + **kwargs): # Required self.update_id = int(update_id) # Optionals - self.message = kwargs.get('message') - self.edited_message = kwargs.get('edited_message') - self.inline_query = kwargs.get('inline_query') - self.chosen_inline_result = kwargs.get('chosen_inline_result') - self.callback_query = kwargs.get('callback_query') + self.message = message + self.edited_message = edited_message + self.inline_query = inline_query + self.chosen_inline_result = chosen_inline_result + self.callback_query = callback_query @staticmethod def de_json(data, bot): diff --git a/telegram/user.py b/telegram/user.py index 676d276ee..e49d55f29 100644 --- a/telegram/user.py +++ b/telegram/user.py @@ -44,14 +44,14 @@ class User(TelegramObject): bot (Optional[Bot]): The Bot to use for instance methods """ - def __init__(self, id, first_name, bot=None, **kwargs): + def __init__(self, id, first_name, type='', last_name='', username='', bot=None, **kwargs): # Required self.id = int(id) self.first_name = first_name # Optionals - self.type = kwargs.get('type', '') - self.last_name = kwargs.get('last_name', '') - self.username = kwargs.get('username', '') + self.type = type + self.last_name = last_name + self.username = username self.bot = bot diff --git a/telegram/video.py b/telegram/video.py index 9adceb553..a2c7ef209 100644 --- a/telegram/video.py +++ b/telegram/video.py @@ -46,16 +46,24 @@ class Video(TelegramObject): file_size (Optional[int]): """ - def __init__(self, file_id, width, height, duration, **kwargs): + def __init__(self, + file_id, + width, + height, + duration, + thumb=None, + mime_type='', + file_size=0, + **kwargs): # Required self.file_id = str(file_id) self.width = int(width) self.height = int(height) self.duration = int(duration) # Optionals - self.thumb = kwargs.get('thumb') - self.mime_type = str(kwargs.get('mime_type', '')) - self.file_size = int(kwargs.get('file_size', 0)) + self.thumb = thumb + self.mime_type = str(mime_type) + self.file_size = int(file_size) @staticmethod def de_json(data, bot): diff --git a/telegram/voice.py b/telegram/voice.py index 50e2f9300..ba9b62ece 100644 --- a/telegram/voice.py +++ b/telegram/voice.py @@ -32,21 +32,21 @@ class Voice(TelegramObject): Args: file_id (str): + duration (Optional[int]): **kwargs: Arbitrary keyword arguments. Keyword Args: - duration (Optional[int]): mime_type (Optional[str]): file_size (Optional[int]): """ - def __init__(self, file_id, **kwargs): + def __init__(self, file_id, duration, mime_type='', file_size=0, **kwargs): # Required self.file_id = str(file_id) + self.duration = int(duration) # Optionals - self.duration = int(kwargs.get('duration', 0)) - self.mime_type = str(kwargs.get('mime_type', '')) - self.file_size = int(kwargs.get('file_size', 0)) + self.mime_type = str(mime_type) + self.file_size = int(file_size) @staticmethod def de_json(data, bot):