Skip to content

Add sendAs option to client.sendMessage#828

Open
zeynalnia wants to merge 1 commit into
gram-js:masterfrom
zeynalnia:feat/send-message-send-as
Open

Add sendAs option to client.sendMessage#828
zeynalnia wants to merge 1 commit into
gram-js:masterfrom
zeynalnia:feat/send-message-send-as

Conversation

@zeynalnia
Copy link
Copy Markdown

Closes #827.

Summary

Exposes the send_as parameter (already present on messages.sendMessage since
layer 167) through the high-level client.sendMessage wrapper, so callers no
longer need to drop down to client.invoke(new Api.messages.SendMessage(...))
just to post on behalf of a linked channel or anonymous-admin identity.

Changes

  • gramjs/client/messages.ts
    • Add sendAs?: EntityLike to SendMessageParams with JSDoc.
    • Resolve it via client.getInputEntity(sendAs) alongside the target entity.
    • Forward the resolved InputPeer to both Api.messages.SendMessage
      constructions (the Api.Message-resend branch and the fresh-text branch).
  • __tests__/client/sendMessage.spec.ts (new)
    • Two specs against a stub TelegramClient: (1) asserts sendAs is resolved
      and forwarded onto the constructed request, (2) asserts the field is left
      undefined when the option is omitted.

Scope

Limited to the no-file path. The file branch delegates to client.sendFile,
which would need a separate change to thread sendAs through messages.SendMedia.

Test plan

  • npx jest __tests__/client/sendMessage.spec.ts — both specs pass locally.
  • Manual smoke test against a Telegram account with permission to post as a
    linked channel.

@zeynalnia zeynalnia force-pushed the feat/send-message-send-as branch from 69948d3 to cc4d938 Compare April 19, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: expose sendAs in client.sendMessage

1 participant