Skip to content

feat: ctx.send and SendData #676

@KnorpelSenf

Description

@KnorpelSenf

We want to introduce SendData: an object that specifies all necessary information in order to send a message. This can be a string, or { text: string } or { photo: photo }, etc. Optionally, more parameters can be contained.

This lets us add ctx.send. In grammY 2.0, you can then call ctx.send("message") and ctx.send({ photo }) instead of ctx.reply("message") and ctx.replyWithPhoto(photo).

Similar objects will be introduced for editing messages.

Similar objects will be introduced for calling arbitrary API methods.

This has many advantages:

  • ctx.reply has nothing to do with replies so the name is misleading
  • it is currently impossible to write a function that generates message data—if you want modularity, you must pass around the context object, which is bad
  • menus have no way to edit their own content when they are being navigated to, and send data will make this much better

Naming ideas:

  • send data
  • send template
  • send spec objects
  • send blueprints

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions