X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions telegram/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,30 @@ class Audio(TelegramObject):
Args:
file_id (str):
duration (int):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
performer (Optional[str]):
title (Optional[str]):
mime_type (Optional[str]):
file_size (Optional[int]):
**kwargs: Arbitrary keyword arguments.

"""

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):
Expand Down
1,065 changes: 501 additions & 564 deletions telegram/bot.py

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions telegram/callbackquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
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

Expand Down
29 changes: 19 additions & 10 deletions telegram/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,36 @@ class Chat(TelegramObject):
Args:
id (int):
type (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
type (Optional[str]):
title (Optional[str]):
username(Optional[str]):
first_name(Optional[str]):
last_name(Optional[str]):
bot (Optional[Bot]): The Bot to use for instance methods
"""
**kwargs (dict): Arbitrary keyword arguments.

"""
PRIVATE = 'private'
GROUP = 'group'
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

Expand Down
3 changes: 2 additions & 1 deletion telegram/chatmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class ChatMember(TelegramObject):
Args:
user (:class:`telegram.User`):
status (str):
"""
**kwargs (dict): Arbitrary keyword arguments.

"""
CREATOR = 'creator'
ADMINISTRATOR = 'administrator'
MEMBER = 'member'
Expand Down
5 changes: 5 additions & 0 deletions telegram/choseninlineresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ class ChosenInlineResult(TelegramObject):
result_id (str):
from_user (:class:`telegram.User`):
query (str):
location (:class:`telegram.Location`):
inline_message_id (str):

Args:
result_id (str):
from_user (:class:`telegram.User`):
query (str):
location (Optional[:class:`telegram.Location`]):
inline_message_id (Optional[str]):
**kwargs (dict): Arbitrary keyword arguments.

"""

Expand Down
11 changes: 5 additions & 6 deletions telegram/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,19 @@ class Contact(TelegramObject):
Args:
phone_number (str):
first_name (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
last_name (Optional[str]):
user_id (Optional[int]):
**kwargs: Arbitrary keyword arguments.

"""

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):
Expand Down
15 changes: 7 additions & 8 deletions telegram/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@ class Document(TelegramObject):

Args:
file_id (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
thumb (Optional[:class:`telegram.PhotoSize`]):
file_name (Optional[str]):
mime_type (Optional[str]):
file_size (Optional[int]):
**kwargs (dict): Arbitrary keyword arguments.

"""

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):
Expand Down
10 changes: 4 additions & 6 deletions telegram/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ class File(TelegramObject):
Args:
file_id (str):
bot (telegram.Bot):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
file_size (Optional[int]):
file_path (Optional[str]):
**kwargs (dict): Arbitrary keyword arguments.

"""

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

Expand Down
9 changes: 4 additions & 5 deletions telegram/forcereply.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ class ForceReply(ReplyMarkup):

Args:
force_reply (bool):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
selective (Optional[bool]):
**kwargs (dict): Arbitrary keyword arguments.

"""

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):
Expand Down
12 changes: 5 additions & 7 deletions telegram/inlinekeyboardbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,21 @@ class InlineKeyboardButton(TelegramObject):

Args:
text (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
url (Optional[str]):
callback_data (Optional[str]):
switch_inline_query (Optional[str]):
**kwargs (dict): Arbitrary keyword arguments.

"""

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):
Expand Down
2 changes: 2 additions & 0 deletions telegram/inlinekeyboardmarkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class InlineKeyboardMarkup(ReplyMarkup):

Args:
inline_keyboard (List[List[:class:`telegram.InlineKeyboardButton`]]):
**kwargs (dict): Arbitrary keyword arguments.

"""

Expand All @@ -46,6 +47,7 @@ def de_json(data, bot):

Returns:
telegram.InlineKeyboardMarkup:

"""
data = super(InlineKeyboardMarkup, InlineKeyboardMarkup).de_json(data, bot)

Expand Down
9 changes: 4 additions & 5 deletions telegram/inlinequery.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,21 @@ class InlineQuery(TelegramObject):
from_user (:class:`telegram.User`):
query (str):
offset (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
location (optional[:class:`telegram.Location`]):
bot (Optional[Bot]): The Bot to use for instance methods
**kwargs (dict): Arbitrary keyword arguments.

"""

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
self.query = query
self.offset = offset

# Optional
self.location = kwargs.get('location')
self.location = location

self.bot = bot

Expand Down
7 changes: 4 additions & 3 deletions telegram/inlinequeryresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ class InlineQueryResult(TelegramObject):
"""This object represents a Telegram InlineQueryResult.

Attributes:
type (str):
id (str):
type (str): Type of the result.
id (str): Unique identifier for this result, 1-64 Bytes

Args:
type (str):
type (str): Type of the result.
id (str): Unique identifier for this result, 1-64 Bytes
**kwargs (dict): Arbitrary keyword arguments.

"""

Expand Down
7 changes: 3 additions & 4 deletions telegram/inlinequeryresultarticle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,20 @@ class InlineQueryResultArticle(InlineQueryResult):

parse_mode (str): Use :class:`InputTextMessageContent` instead.

disable_web_page_preview (bool): Use :class:`InputTextMessageContent`
instead.
disable_web_page_preview (bool): Use :class:`InputTextMessageContent` instead.

Args:
id (str): Unique identifier for this result, 1-64 Bytes
title (str):
reply_markup (:class:`telegram.ReplyMarkup`):

Keyword Args:
url (Optional[str]):
hide_url (Optional[bool]):
description (Optional[str]):
thumb_url (Optional[str]):
thumb_width (Optional[int]):
thumb_height (Optional[int]):
**kwargs (dict): Arbitrary keyword arguments.

"""

def __init__(self,
Expand Down
14 changes: 5 additions & 9 deletions telegram/inlinequeryresultaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,24 @@ class InlineQueryResultAudio(InlineQueryResult):
performer (Optional[str]):
audio_duration (Optional[str]):
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
input_message_content (Optional[
:class:`telegram.input_message_content`]):
input_message_content (Optional[:class:`telegram.input_message_content`]):

Deprecated: 4.0
message_text (str): Use :class:`InputTextMessageContent` instead.

parse_mode (str): Use :class:`InputTextMessageContent` instead.

disable_web_page_preview (bool): Use :class:`InputTextMessageContent`
instead.
disable_web_page_preview (bool): Use :class:`InputTextMessageContent` instead.

Args:
audio_url (str):
title (str):
**kwargs: Arbitrary keyword arguments.

Keyword Args:
performer (Optional[str]):
audio_duration (Optional[str]):
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
input_message_content (Optional[
:class:`telegram.input_message_content`]):
input_message_content (Optional[:class:`telegram.input_message_content`]):
**kwargs (dict): Arbitrary keyword arguments.

"""

def __init__(self,
Expand Down
Loading
X Tutup