sender.getMediaItems(), file downloads, and group member lists. When handling user-uploaded files, prefer normalized MediaItem objects and do not manually assemble platform download URLs.
Event methods
| Method | Purpose | Parameters | Returns |
|---|---|---|---|
getPluginName() | Get the current plugin title; returns the plugin name when no title exists. | None | Promise<string> |
getPluginVersion() | Get the current plugin version. | None | Promise<string> |
getEventType() | Get the current event type. | None | Promise<string> |
setEventType(eventType) | Set the event type in the current runtime context. | eventType: required. | Promise<boolean> |
getEventData() | Get current event data. Returns {} when absent. | None | Promise<any> |
setEventData(eventData) | Set current event data. | eventData: required, any JSON-like data. | Promise<boolean> |
getMediaItems() | Get media items from the current event or latest waited input. | None | Promise<MediaItem[]> |
getMediaItems()
getMediaItems() lookup order:
last_input_media_items: media captured by the latestlisten(...)/input(...).media_items/mediaItems: media array in the current runtime context.event_data.media_items/event_data.mediaItems: media array in current event data.- Returns
[]when none exist.
Media type, such as
image, voice, video, or file. Only media items that have both type and source are kept.Media source. It may be a URL, local path, platform file ID, temporary resource ID, or adapter file identifier.
Filename. The runtime chooses from
name, filename, and file_name.MIME type. The runtime chooses from
mime_type or mimeType.Adapter raw file information. Keeping it improves adapter resolution success when downloading user-uploaded files.
fileDownload(url, path?)
Save a remote URL, file://, base64://..., or data:*;base64,... to a local file.
File source. Supports
http://, https://, file://, base64://..., and data URI.Save directory. If omitted, saves to the runtime download root. Relative paths are placed under the download root. Absolute paths are used as-is. Relative paths cannot escape the download root.
downloadAdapterFile(file, options?, timeout?)
Download a file uploaded by a user to an IM platform. Prefer passing the whole MediaItem returned by sender.getMediaItems().
User-uploaded file item. An object can contain
source, url, file_id, id, file, path, or platform_payload. A string is treated as the file source. If you only have a normal URL, you can also call fileDownload(url) directly.Save directory. Same rules as
fileDownload(..., path).Saved filename. You can also write
file_name, filename, or name.MIME type. You can also write
mime_type.Optional IM type. You can also write
imtype or im_type. If omitted, the current runtime context is used.Optional account ID. You can also write
accountID or accountId. If omitted, the current runtime context account is used.Request timeout in milliseconds. You can also pass a number directly as the second parameter, such as
downloadAdapterFile(file, 60000).Download flow
- If
sourceis alreadyhttp://,https://,data:,base64://, orfile://, the runtime downloads it directly. - If
sourceis a platform file ID or another identifier that cannot be downloaded directly, the runtime calls adapterresolveFileURL. - After successful download, it saves the file to the runtime file directory and returns the local path.
true when downloadAdapterFile(...) succeeds.Usually
resolveFileURL if an adapter was called to resolve the download URL first. It may be empty for direct downloads.Actual download URL or resolved temporary URL.
Saved local path.
Same as
path.Saved filename.
MIME type.
File size in bytes.
getGroupMemberList(groupIDOrOptions?, options?, timeout?)
Get a group member list. The adapter must support getGroupMemberList.
A string means group ID. An object can contain
group_id, groupID, groupCode, group, chat_id, imType, account_id, and other fields. If no group ID is passed, the runtime tries to use the current group chat context.Target IM type. You can also write
im_type. If omitted, the current context IM is used. Cron / fake contexts must pass it.Target account ID. You can also write
accountID or accountId. If omitted, the current context account or target IM default account is used.Whether to bypass adapter cache. You can also write
no_cache.Whether to include raw member data in each member object. You can also write
includeRaw or include_raw.Whether to include the adapter raw result in returned
raw / data. You can also write raw_result or includeRawResult.Request timeout in milliseconds.
true when the list is fetched successfully.Actual requested IM type.
Actual requested account ID. It may be empty if not specified.
Actual requested group ID.
Normalized member array.
Contains the adapter raw result only when
rawResult / raw_result / includeRawResult is passed.Next steps
Send media
See media sending and adapter differences.
Proactive push
See file and mixed proactive push.