plugin/scripts/middleware.py is the SDK for regular Python plugins. Use it to create Sender, read the current context, reply to messages, store data, wait for input, handle payments, download user-uploaded files, handle HTTP routes, push proactively, and manage runtime scheduled tasks.
New plugins should prefer
from middleware import Sender, getSenderID. Do not hard-code credentials, ports, or autClaw internal service addresses.Quick start
Exception; catch exceptions in flows that send network requests, media, or files, and reply with an actionable message.
Browse by task
Context and base types
Import style,
senderID, response wrappers, SendReceipt, MediaItem, and download return bodies.Sender message capabilities
Read users and chats, match parameters, reply with text/media, recall, and use
replyMixed(...).Wait for input and payment
listen(...), input(...), waitPay(exitcode, timeout, amount=None), and amount-matching details.Events, media, and files
getMediaItems(), fileDownload(...), downloadAdapterFile(...), and getGroupMemberList(...).Storage and routes
Default storage, named buckets, and HTTP router request and response aliases.
Proactive push
Targets, account selection, and return values for
push(...) / pushImage(...) / pushMixed(...).Tools, Cron, and group management
import_module(...), system utilities, Cron, group invite/mute/announcement.Python signatures
Navigation-indexed
.pyi-style signatures for IDEs and AI retrieval through MCP.Common imports
- Use
Senderto handle the current message, route request, or event. - Use top-level functions for global operations, such as
bucketGet(...),pushImage(...), andfileDownload(...). - Business timeout parameters for
listen(...),input(...), andwaitPay(...)use milliseconds. - Serialize objects with
json.dumps(...)before saving them withset(...)/bucketSet(...).
Recommended template
Actual differences from JavaScript middleware
This table is checked against the currentplugin/scripts/middleware.py and plugin/scripts/middleware.js: