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=None, timeout=None) | 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. | int, number of successfully sent targets, usually 0 or 1. |
pushImage(imType, groupCode, userID, title, imageUrl, options=None, timeout=None) | Push an image. | First four parameters are the same; imageUrl: image source; options: optional media parameters. | int |
pushVoice(imType, groupCode, userID, title, voiceUrl, options=None, timeout=None) | Push voice/audio. | voiceUrl: voice source; options: optional media parameters. | int |
pushVideo(imType, groupCode, userID, title, videoUrl, options=None, timeout=None) | Push a video. | videoUrl: video source; options: optional media parameters. | int |
pushFile(imType, groupCode, userID, title, fileUrl, options=None, timeout=None) | Push a file. | fileUrl: file source; options can pass account, filename, and MIME type. | int |
pushMixed(imType, groupCode, userID, title, items, options=None, timeout=None) | Push a mixed message. | items: mixed items; options: optional account parameters. | int |
push(...)
Target IM type, such as
qq, weixin, or qx, depending on enabled adapters.Group ID. Required for group push; pass an empty string for private push.
User ID. Required for private push; can be empty for group push.
Target account ID. Also accepted as
accountID or accountId. Explicit values have highest priority.Request timeout. Pass 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 chooses the first online account that can send. If no account can send, it returns
0or raises an adapter offline error.
Media push
Return value
Proactive push returns the number of successfully sent targets, usually0 or 1. If the adapter returns an error, the SDK raises Exception.
Next steps
- Media source formats:
Media sending - Push from scheduled tasks:
Tools, Cron, and group management