Examples on this page target source snapshot
93e5c7f, not a crates.io release. Use the current API guide to select the matching dependency.Send text or protobuf content
Set options once
Wrap the message inSendRequest::new(chat, message).with_options(options) and call client.send(request).await. Build SendOptions from Default; typed IDs and with_* setters replace old literals and option overloads. The send task reference includes a complete example.
For disappearing content, use the chat’s chosen expiration. A per-message option does not change the chat timer. For an explicit fresh device query after NoRecipientDevice, set device freshness on the next request.
Preserve the original target
Usemessage_ref() on the received message, context or send result. Pass that reference to reactions, revokes, pins and keeps. Build EditRequest for edits. A target includes its original author and origin metadata, so rebuilding it from an ID alone can lose routing context.
Keep the original content ID separate from an operation’s returned ID. A reaction or edit is a new stanza, and its ACK is not an ACK for the target content or proof of recipient delivery.
Forward without copying a secret
Useforward_message for default sends. Use prepare_for_forward followed by a SendRequest to customize the result. Preparation drops the source’s secret and quote chain and sets forwarding metadata; do not attach the original secret back to forwarded content.
Address specialized content
- Polls and events return named creation results carrying their parent crypto association.
- Status posts need an explicit audience and different ID options for content and operations.
- Newsletter actions use
NewsletterMessageRefbecause channel client IDs and server content IDs are separate domains. - Community announcement posts need the original author and secret for encrypted edits and comments.
Album messages
Send anAlbumMessage parent declaring the image/video counts, then link each prepared media message using wrap_as_album_child. Children are separate sends; cancelling midway does not roll back the parent or earlier children.
Sticker packs
Prepare 512×512 WebP stickers and a cover withwacore::sticker_pack::create_sticker_pack_zip. Upload the ZIP as MediaType::StickerPack, then the JPEG thumbnail as StickerPackThumbnail with the ZIP upload’s same media key. Build the content with build_sticker_pack_message and send it through the ordinary pipeline. Uploading and sending are separate operations.
See media handling and the pinned core helper for exact metadata and upload projections.
Quoted replies
UseMessageContext::reply_quoting to include quote context from the incoming message. For manual protobuf assembly, its build_quote_context() exposes the quoted association. Sending, editing or forwarding content does not implicitly quote an arbitrary previous message.