New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More instance methods #963

Merged
merged 9 commits into from Feb 18, 2018

Conversation

Projects
None yet
2 participants
@jsmnbom
Member

jsmnbom commented Jan 3, 2018

Fixes #955
Adds more instance methods, namely:

  • Chat.send_*() and User.send_*()
    This allows stuff such as:
def callback(bot, update):
  # send the user a PM
  update.effective_user.send_message("Hi you send stuff")
  update.message.reply_text("Hey {}, check your PM".format(update.effective_user.mention_html()), parse_mode="HTML")
  • Document.get_file()
    As well as PhotoSize.get_file(), Video.get_file() etc.
    Allows stuff like:
def callback(bot, update):
    update.message.document.get_file().download()

Additionally also does such that
bot.get_file(update.message.document)
works instead of
bot.get_file(update.message.document.file_id)

@tsnoam

tsnoam requested changes Jan 4, 2018 edited

In general looks good. But please see my comments (and check the travis log for failures).

Show outdated Hide outdated telegram/bot.py
Show outdated Hide outdated telegram/bot.py
:class:`telegram.Message`: On success, instance representing the message posted.
"""
return self.bot.send_message(chat_id=self.id, *args, **kwargs)

This comment has been minimized.

@tsnoam

tsnoam Jan 4, 2018

Member

bot may be None on some extreme cases. I believe that on these cases we should raise an explicit RuntimeError.

Though you may claim that we don't do that with Message.reply_*() methods. So maybe we should fix there too?

@tsnoam

tsnoam Jan 4, 2018

Member

bot may be None on some extreme cases. I believe that on these cases we should raise an explicit RuntimeError.

Though you may claim that we don't do that with Message.reply_*() methods. So maybe we should fix there too?

This comment has been minimized.

@jsmnbom

jsmnbom Jan 4, 2018

Member

That was the exact point I was gonna make xD
Does it matter what error it throws?
It seems like a lot of code for some superficial error that's unlikely to ever happen (as far as I understand it, it will never happen if users don't do stupid stuff, right?)

@jsmnbom

jsmnbom Jan 4, 2018

Member

That was the exact point I was gonna make xD
Does it matter what error it throws?
It seems like a lot of code for some superficial error that's unlikely to ever happen (as far as I understand it, it will never happen if users don't do stupid stuff, right?)

This comment has been minimized.

@tsnoam

tsnoam Jan 7, 2018

Member

Explicit errors are much easier to debug, especially in async systems, rather than deciphering a stack trace.
If you feel that the code is good as it is I won't object. I simply suggest to reconsider.

@tsnoam

tsnoam Jan 7, 2018

Member

Explicit errors are much easier to debug, especially in async systems, rather than deciphering a stack trace.
If you feel that the code is good as it is I won't object. I simply suggest to reconsider.

This comment has been minimized.

@tsnoam

tsnoam Feb 18, 2018

Member

i will leave this as is.

@tsnoam

tsnoam Feb 18, 2018

Member

i will leave this as is.

Show outdated Hide outdated telegram/files/audio.py
@tsnoam

This comment has been minimized.

Show comment
Hide comment
@tsnoam

tsnoam Feb 18, 2018

Member

Fails because of unrelated changes on telegram servers.
Will merge this after #1006

Member

tsnoam commented Feb 18, 2018

Fails because of unrelated changes on telegram servers.
Will merge this after #1006

@tsnoam

tsnoam approved these changes Feb 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment