Skip to content

Conversation

@jh0ker
Copy link
Member

@jh0ker jh0ker commented Jul 30, 2016

PR to keep track of development.

The idea of this PR is to add shortcut-methods to the classes defined by the API.

Example:
To reply to a message with another text message, you would have to do

bot.sendMessage(update.message.chat_id, text="Reply")

Now, you can also do

update.message.reply_text("Reply")

which is nothing more than a shortcut for bot.sendMessage(update.message.chat_id, *args, **kwargs).

List of methods planned:

  • Message
    • reply_text
    • forward
    • reply_photo
    • reply_audio
    • reply_document
    • reply_sticker
    • reply_video
    • reply_voice
    • reply_location
    • reply_venue
    • reply_contact
  • Chat
    • send_action
    • kick_member
    • leave
    • unban_member
    • get (static?)
    • get_administrators
    • get_members_count
    • get_member
  • User
    • get_profile_photos
  • File
    • get (static?)
  • InlineQuery
    • answer
  • CallbackQuery
    • answer

@jh0ker jh0ker added this to the 5.1 milestone Jul 30, 2016
@jsmnbom
Copy link
Member

jsmnbom commented Aug 12, 2016

Any chance we could add send_chat_action to Message and Chat too?

@jh0ker
Copy link
Member Author

jh0ker commented Aug 12, 2016

It's already on Chat, I think that is enough, since they are both look linked

@jsmnbom
Copy link
Member

jsmnbom commented Aug 12, 2016

Alright yeah, that seems good. Just wasn't sure if you added it since it's not in the original list :)
Edit: Nevermind, I'm totally blind. It's right there.

@jh0ker
Copy link
Member Author

jh0ker commented Aug 12, 2016

screenshot_20160812-214938

@jh0ker
Copy link
Member Author

jh0ker commented Aug 12, 2016

Sorry, just got back to my laptop and saw the huge screenshot. But I'll leave it that way 😎

@jh0ker
Copy link
Member Author

jh0ker commented Aug 15, 2016

I think we should leave the static get methods, they seem a bit confusing and not really worth it

@evieluvsrainbows
Copy link

@jh0ker Just do them. They aren't confusing.

@jh0ker
Copy link
Member Author

jh0ker commented Aug 16, 2016

@KamranMackey The problem is that you need an instance of the class before you could use them, because only the instance can have a reference to the telegram.Bot instance which is needed to make the API call.

So it couldn't be a static method after all.

@evieluvsrainbows
Copy link

@jh0ker Oh, okay. Just leave them then.

telegram/bot.py Outdated

def create_references(self, d):
"""
Recursively reates a reference to this Bot instance in the dict and all contained dicts and
Copy link
Member

@tsnoam tsnoam Sep 7, 2016

Choose a reason for hiding this comment

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

(edited) Recursively iterates? creates?

@tsnoam
Copy link
Member

tsnoam commented Sep 7, 2016

I left some comments on the diff.
most of them were just nitpicks (pep8 and stuff) but there was one which was regarding performance and requires discussion.

@jh0ker jh0ker added the 📋 pending-review work status: pending-review label Sep 11, 2016
@jh0ker jh0ker merged commit 5116a77 into master Sep 20, 2016
@jh0ker jh0ker removed the 📋 pending-review work status: pending-review label Sep 20, 2016
@jh0ker jh0ker deleted the class-methods branch September 20, 2016 04:37
@whipermr5
Copy link
Contributor

If I'm not going to use any of those methods, is it safe to pass in None to Update.de_json? I feel bot should actually be optional for that method.

@jh0ker
Copy link
Member Author

jh0ker commented May 2, 2017

@whipermr5 Yes, that is safe.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2020
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 enhancement pr description: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants