Skip to content

Commit

Permalink
Raises error when chat_id is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrotoledo committed Sep 4, 2015
1 parent 95ecd44 commit 910959b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def decorator(self, *args, **kwargs):
"""
url, data = func(self, *args, **kwargs)

if not kwargs.get('chat_id'):
raise TelegramError('Invalid chat_id.')

if kwargs.get('reply_to_message_id'):
reply_to_message_id = kwargs.get('reply_to_message_id')
data['reply_to_message_id'] = reply_to_message_id
Expand Down

2 comments on commit 910959b

@njittam
Copy link
Contributor

@njittam njittam commented on 910959b Sep 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehm i think this broke my code. Because I do this in a lot of places.

chat_id = update.message.chat.id
bot.sendMessage(chat_id, 'foobar')

however it is now necessary for me to change this to

chat_id = update.message.chat.id
bot.sendMessage(chat_id=chat_id, message='foobar')

@leandrotoledo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Well noted, I'll revert it back until we find a better solution.

Please sign in to comment.