Skip to content
Merged
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
41 changes: 19 additions & 22 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,25 @@ def message(func):
@functools.wraps(func)
def decorator(self, *args, **kwargs):
url, data = func(self, *args, **kwargs)
return self._message_wrapper(url, data, *args, **kwargs)
if kwargs.get('reply_to_message_id'):
data['reply_to_message_id'] = kwargs.get('reply_to_message_id')

if kwargs.get('disable_notification'):
data['disable_notification'] = kwargs.get('disable_notification')

if kwargs.get('reply_markup'):
reply_markup = kwargs.get('reply_markup')
if isinstance(reply_markup, ReplyMarkup):
data['reply_markup'] = reply_markup.to_json()
else:
data['reply_markup'] = reply_markup

result = self._request.post(url, data, timeout=kwargs.get('timeout'))

if result is True:
return result

return Message.de_json(result, self)

return decorator

Expand Down Expand Up @@ -148,27 +166,6 @@ def name(self):

return '@{0}'.format(self.username)

def _message_wrapper(self, url, data, *args, **kwargs):
if kwargs.get('reply_to_message_id'):
data['reply_to_message_id'] = kwargs.get('reply_to_message_id')

if kwargs.get('disable_notification'):
data['disable_notification'] = kwargs.get('disable_notification')

if kwargs.get('reply_markup'):
reply_markup = kwargs.get('reply_markup')
if isinstance(reply_markup, ReplyMarkup):
data['reply_markup'] = reply_markup.to_json()
else:
data['reply_markup'] = reply_markup

result = self._request.post(url, data, timeout=kwargs.get('timeout'))

if result is True:
return result

return Message.de_json(result, self)

@log
def get_me(self, timeout=None, **kwargs):
"""A simple method for testing your bot's auth token. Requires no parameters.
Expand Down