New plugins should prefer
Sender methods: replyImage, replyVoice, replyVideo, replyFile, and replyMixed. Legacy global functions such as sendImage, sendVoice, sendVideo, sendFile, and sendMixed still work for maintaining old reply scripts, but new examples use Sender.Choose a sending method
Reply to the current chat
Use
sender.replyImage(...) and related methods in a message-triggered plugin. The target comes from the current message.Push proactively
Use
pushImage(...), pushVoice(...), pushVideo(...), pushFile(...), or pushMixed(...) with imType, group, and user IDs.Send combined content
Use
replyMixed(...) to send text, images, voice, video, or files in one message sequence.Save files first
Use
fileDownload(...) to save a remote URL, base64 payload, or data URI, then pass the local path to a media method.Quick example
Media sources
Thesource parameter of media methods supports these forms:
Reply with media
CreateSender first, then call the reply method. The return value is usually SendReceipt.
Method purpose
options
The second parameter of media reply methods is an optional object. Current regular plugin helpers use these fields:
To specify a target, use
pushImage(...), pushVoice(...), pushVideo(...), pushFile(...), or pushMixed(...). Regular replies send to the current conversation by default.
Send mixed messages
replyMixed(items, options?) combines text and media into one message sequence. Media items can use source, file, url, or path for the source.
items:
Media items can also include
name, file_name, filename, mime_type, or mimeType.
Push media proactively
Proactive push does not depend on the current message. Specify the target:imType: IM type, such asqqorwx. Use the adapters enabled in your deployment.groupCode: Group number or group ID. Usually an empty string for private chats.userID: User ID. Usually an empty string for group pushes.title: Push title or note. Some adapters ignore it.
For proactive push account selection rules, see
JavaScript proactive push or Python proactive push.
Save and send files
fileDownload(url, path?) saves http(s), base64://..., or data:*;base64,... sources as local files. Pass the returned path / file_path to media sending methods.
fileDownload parameters
FileDownloadResult
fileDownload(...) file is limited to about 20 MB by default. Download failures, unreachable sources, or oversized files throw exceptions.
Handle user-uploaded files
If a user uploads a file in a message, read media items first, then calldownloadAdapterFile(...) to save it locally.
downloadAdapterFile(...) returns the same fields as fileDownload(...) and may include extra fields:
SendReceipt
Text, media, and recall methods usually return a send receipt. Adapters may add extra fields.ok === false / ok is False as failure. Do not rely on only one message ID field.
Practical tips
- Before sending a locally generated file, make sure it has been fully written.
- Set
filename/namefor files and mixed media items so users can recognize downloads. - Prefer reachable URLs for large files. Save to disk with
fileDownload(...)only when you need local processing. - Do not manually parse user-uploaded platform raw fields. Use
sender.getMediaItems()+downloadAdapterFile(...). - When media sending fails, read
errorfrom the receipt and give users a concrete next step.
Legacy reply script entry points
When maintaining legacyplugin/replies/*.js scripts, you can still use global functions:
plugin/scripts/*.js or plugin/scripts/*.py files, prefer the Sender style for readability and type hints.