Sender. You need to specify the target IM, group, or user. For group push, pass groupCode; for private push, pass userID.
Function overview
| Function | Purpose | Parameters | Returns |
|---|---|---|---|
push(imType, groupCode, userID, title, content, options?, timeout?) | Push text. | imType: required; groupCode: group ID, pass '' for private chat; userID: user ID, pass '' for group push; title: title or fallback text; content: text; options: optional; timeout: optional milliseconds. | Promise<number>, number of successfully sent targets, usually 0 or 1. |
pushImage(imType, groupCode, userID, title, imageUrl, options?, timeout?) | Push an image. | First four parameters are the same; imageUrl: required image source; options: optional media parameters; timeout: optional milliseconds. | Promise<number> |
pushVoice(imType, groupCode, userID, title, voiceUrl, options?, timeout?) | Push voice/audio. | voiceUrl: required voice source; options: optional media parameters; timeout: optional milliseconds. | Promise<number> |
pushVideo(imType, groupCode, userID, title, videoUrl, options?, timeout?) | Push a video. | videoUrl: required video source; options: optional media parameters; timeout: optional milliseconds. | Promise<number> |
pushFile(imType, groupCode, userID, title, fileUrl, options?, timeout?) | Push a file. | fileUrl: required file source; options can pass account, filename, and MIME type; timeout: optional milliseconds. | Promise<number> |
pushMixed(imType, groupCode, userID, title, items, options?, timeout?) | Push a mixed message. | items: required mixed items; options: optional account parameters; timeout: optional milliseconds. | Promise<number> |
push(imType, groupCode, userID, title, content, options?, timeout?)
Target IM type, such as
qq, weixin, or qx, depending on enabled adapters.Group ID / group number. Required for group push; pass an empty string for private chat.
User ID. Required for private push; group push can pass an empty string.
Push title or note. In text push, if
content is empty, title is used as the text.Text content. The runtime also supports
text / message fields, but the helper always sends content.Optional extension fields.
middleware.js shallow-merges this object into the top-level request body.Target account ID. You can also write
accountID or accountId. Explicit values have the highest priority.Request timeout in milliseconds.
Push account selection
These rules apply topush(...), pushImage(...), pushVoice(...), pushVideo(...), pushFile(...), and pushMixed(...).
Selection rules:
- If
optionscontainsaccount_id, use it. - If this is a message trigger and the target IM is the same as the current chat IM, use the current chat account by default.
- If this is cron / fake, use the target IM default account.
- For cross-IM push, use the target IM default account.
- If the target IM has no default account, the runtime selects the first online account that can send. If there is no available sending account, it returns
0or throws an adapter-offline error.
Media push
Return value
Proactive push functions return a number: the count of targets that the runtime considers successfully sent.1: usually means the message was submitted to one target.0: usually means no available adapter, invalid target, or not sent.- Adapter request failures may throw
Error.
Mixed items
pushMixed(...) items are the same as replyMixed(...): they support text, markdown, image, voice, video, and file.
Next steps
Runtime context
See differences between message, cron, route, and cross-IM contexts.
Media files
See media sources, downloads, and user-uploaded file handling.