API 参考¶
本页列出插件作者和应用代码可直接从 iamai 导入的公共接口。
Public package exports for iamai plugin authors and application code.
- exception iamai.AgentError[source]¶
Bases:
RuntimeErrorRaised when an agent helper cannot complete a model or tool operation.
- class iamai.AgentTrace(name, status='running', events=<factory>)[source]¶
Bases:
objectAppend-only trace used to inspect model calls, tool calls, and observations.
- Parameters:
name (str)
status (str)
events (list[TraceEvent])
- name: str¶
- status: str¶
- events: list[TraceEvent]¶
- add(kind, name, *, input=None, output=None, **metadata)[source]¶
Append a trace event and return it.
- Parameters:
kind (str)
name (str)
input (Any)
output (Any)
metadata (Any)
- Return type:
TraceEvent
- lines(*, limit=12)[source]¶
Return compact human-readable trace lines.
- Parameters:
limit (int)
- Return type:
list[str]
- class iamai.Adapter(runtime, config=None)[source]¶
Bases:
ABCTransport bridge between iamai and an external protocol or runtime.
- Parameters:
runtime (Runtime)
config (dict[str, Any] | None)
- async call_api(action, **params)[source]¶
Call an adapter-specific API action.
- Parameters:
action (str)
params (Any)
- Return type:
Any
- async emit(event)[source]¶
Emit an event and return whether the runtime admitted it.
- Parameters:
event (Event)
- Return type:
bool
- name = 'adapter'¶
- class iamai.AuditLogger(logger_name='iamai.audit')[source]¶
Bases:
objectStructured audit logger that emits one JSON object per runtime event.
- Parameters:
logger_name (str)
- class iamai.Guardrail(*blocked_tokens)[source]¶
Bases:
objectSimple token-based output guardrail.
- Parameters:
blocked_tokens (str)
- class iamai.JsonStateStore(path)[source]¶
Bases:
StateStoreJSON-file backed plugin state store.
- Parameters:
path (str | Path)
- class iamai.LLMClient(config=None)[source]¶
Bases:
objectSmall async client for text and JSON chat completions.
- Parameters:
config (LLMConfig | dict[str, Any] | None)
- async chat_json(messages, *, temperature=None, max_tokens=None, schema=None, trace=None)[source]¶
Call the chat model and parse a JSON object or array.
- Parameters:
messages (list[dict[str, str]])
temperature (float | None)
max_tokens (int | None)
schema (type[BaseModel] | None)
trace (AgentTrace | None)
- Return type:
dict[str, Any] | list[Any] | BaseModel
- async chat_text(messages, *, temperature=None, max_tokens=None, trace=None, response_format=None)[source]¶
Call the configured chat model and return stripped text.
- Parameters:
messages (list[dict[str, str]])
temperature (float | None)
max_tokens (int | None)
trace (AgentTrace | None)
response_format (dict[str, str] | None)
- Return type:
str
- class iamai.LLMConfig(api_key='', base_url=None, model='', temperature=0.7, max_tokens=800, timeout=60.0, extra_body=None)[source]¶
Bases:
objectConnection and generation settings for an OpenAI-compatible chat model.
- Parameters:
api_key (str)
base_url (str | None)
model (str)
temperature (float)
max_tokens (int)
timeout (float)
extra_body (dict[str, Any] | None)
- api_key: str¶
- base_url: str | None¶
- model: str¶
- temperature: float¶
- max_tokens: int¶
- timeout: float¶
- extra_body: dict[str, Any] | None¶
- class iamai.NullStateStore[source]¶
Bases:
StateStoreNo-op state store used for memory-only operation.
- class iamai.Permission(_executor, name='permission')[source]¶
Bases:
objectComposable async permission predicate.
- Parameters:
_executor (Callable[['Runtime', 'Context', dict[Any, Any]], Any])
name (str)
- name: str¶
- class iamai.Rule(_executor, name='rule')[source]¶
Bases:
objectComposable async rule predicate that may also return match payloads.
- Parameters:
_executor (Callable[['Runtime', 'Context', dict[Any, Any]], Any])
name (str)
- name: str¶
- async evaluate(runtime, ctx, cache)[source]¶
Return whether the rule matches and any extracted match payload.
- class iamai.RuntimeMetrics[source]¶
Bases:
objectSmall in-memory counter store for health checks and operator inspection.
- increment(name, value=1, **labels)[source]¶
Increment a labeled counter by
value.- Parameters:
name (str)
value (int)
labels (Any)
- Return type:
None
- class iamai.SessionManager(*, max_backlog_keys=1024, max_backlog_per_key=3, backlog_ttl_seconds=300.0)[source]¶
Bases:
objectCoordinate per-session waiter registration and message consumption.
- Parameters:
max_backlog_keys (int)
max_backlog_per_key (int)
backlog_ttl_seconds (float)
- cancel(key=None)[source]¶
Cancel waiters, optionally scoped to a single key.
- Parameters:
key (str | None)
- Return type:
int
- configure(*, max_backlog_keys, max_backlog_per_key, backlog_ttl_seconds)[source]¶
Apply bounded backlog settings without replacing active waiters.
- Parameters:
max_backlog_keys (int)
max_backlog_per_key (int)
backlog_ttl_seconds (float)
- Return type:
None
- async consume(ctx)[source]¶
Deliver a context to the first waiter that accepts it.
- Parameters:
ctx (Context)
- Return type:
bool
- list_waiters()[source]¶
Return diagnostic information about active waiters.
- Return type:
list[dict[str, Any]]
- class iamai.SqliteStateStore(path)[source]¶
Bases:
StateStoreSQLite-backed plugin state store.
- Parameters:
path (str | Path)
- class iamai.StateStore[source]¶
Bases:
objectAbstract state backend for plugin persistence.
- class iamai.ToolRegistry[source]¶
Bases:
objectRegistry for named tools that can be called by agent workflows.
- async call(name, tool_input=None, *, trace=None, approved=False, approval_callback=None, **kwargs)[source]¶
Call a registered tool by name.
- Parameters:
name (str)
tool_input (Any)
trace (AgentTrace | None)
approved (bool)
approval_callback (Callable[[Tool, Any], bool | Awaitable[bool]] | None)
kwargs (Any)
- Return type:
Any
- list_tools()[source]¶
Return tool metadata for prompts or diagnostics.
- Return type:
list[dict[str, Any]]
- register(name, description, callback, *, permission_name='', input_schema=None, audit_fields=(), requires_approval=False, runtime_capabilities=())[source]¶
Register or replace a named tool.
- Parameters:
name (str)
description (str)
callback (Callable[[...], Any])
permission_name (str)
input_schema (dict[str, Any] | None)
audit_fields (tuple[str, ...] | list[str])
requires_approval (bool)
runtime_capabilities (tuple[str, ...] | list[str])
- Return type:
None
- class iamai.Runtime(config, *, base_path=None)[source]¶
Bases:
objectTop-level runtime container that owns adapters, plugins, state, and dispatch.
- Parameters:
config (dict[str, Any])
base_path (Path | None)
- add_middleware(callback, *, priority=100, phase='around')[source]¶
Register runtime middleware outside of a plugin class.
- Parameters:
callback (Callable[[...], Any])
priority (int)
phase (str)
- Return type:
None
- audit(action, *, outcome='ok', level=20, **fields)[source]¶
Emit one structured runtime audit event.
- Parameters:
action (str)
outcome (str)
level (int)
fields (Any)
- Return type:
None
- async bootstrap()[source]¶
Load plugins and adapters, then run plugin startup hooks.
- Return type:
None
- count_metric(name, value=1, **labels)[source]¶
Increment a runtime counter.
- Parameters:
name (str)
value (int)
labels (Any)
- Return type:
None
- async dispatch(event, adapter)[source]¶
Dispatch one event, returning whether all matched handlers were admitted.
Handler admission is atomic per event. If the complete matched handler set cannot fit within the configured capacity, none of its handlers are scheduled.
- classmethod from_config_file(path)[source]¶
Create a runtime from a TOML configuration file.
- Parameters:
path (str | Path)
- Return type:
- get_adapter_config(adapter_name)[source]¶
Return raw configuration for one adapter.
- Parameters:
adapter_name (str)
- Return type:
dict[str, Any]
- get_plugin_config(plugin_name)[source]¶
Return raw configuration for one plugin.
- Parameters:
plugin_name (str)
- Return type:
dict[str, Any]
- get_plugin_schema(plugin_name)[source]¶
Return a plugin configuration JSON schema, if available.
- Parameters:
plugin_name (str)
- Return type:
dict[str, Any] | None
- iter_handlers()[source]¶
Return all bound handlers in runtime dispatch order.
This exposes the actual bound callbacks for plugins that need advanced introspection. Prefer
list_handlersfor diagnostics and management API payloads.- Return type:
tuple[BoundHandler, …]
- list_adapters()[source]¶
Return operator-facing metadata for loaded adapters.
- Return type:
list[dict[str, Any]]
- list_handlers()[source]¶
Return JSON-friendly metadata for all registered plugin handlers.
- Return type:
list[dict[str, Any]]
- list_metrics()[source]¶
Return runtime metric series as dictionaries.
- Return type:
list[dict[str, Any]]
- list_plugin_traces()[source]¶
Return trace payloads exposed by loaded plugins.
- Return type:
list[dict[str, Any]]
- list_plugins()[source]¶
Return operator-facing metadata for loaded plugins.
- Return type:
list[dict[str, Any]]
- list_sessions()[source]¶
Return active session waiters for diagnostics.
- Return type:
list[dict[str, Any]]
- register_dependency(name, value, *, annotation=None)[source]¶
Register a value for name-based and type-based dependency injection.
- Parameters:
name (str)
value (Any)
annotation (type[Any] | None)
- Return type:
None
- async reload_config()[source]¶
Reload configuration, plugins, state backend, and adapters atomically.
- Return type:
None
- async reload_plugins()[source]¶
Reload user plugins while keeping the current adapter set.
- Return type:
None
- request_config_reload()[source]¶
Schedule a configuration reload outside the current handler task.
- Return type:
None
- request_plugin_reload()[source]¶
Schedule a plugin reload outside the current handler task.
- Return type:
None
- property runtime_config: dict[str, Any]¶
Return the validated
[runtime]configuration.
- exception iamai.ConfigValidationError[source]¶
Bases:
ValueErrorRaised when a TOML config file fails structural validation.
- class iamai.Context(runtime, adapter, plugin, event, handler, matches=<factory>)[source]¶
Bases:
objectRuntime context passed to handlers and middleware.
- Parameters:
- handler: BoundHandler¶
- matches: dict[str, Any]¶
- property args: str¶
Return command arguments captured during command matching.
- async call_api(action, **params)[source]¶
Call an API action on the current adapter.
- Parameters:
action (str)
params (Any)
- Return type:
Any
- property command_name: str | None¶
Return the matched command name, if any.
- property config: dict[str, Any]¶
Return this plugin’s validated configuration mapping.
- async reload_plugins()[source]¶
Schedule a plugin reload after the current handler completes.
- Return type:
None
- async reply(message)[source]¶
Send a reply to the event’s default target.
- Parameters:
message (str | Message)
- Return type:
Any
- async send(message, *, target=None)[source]¶
Send a message to an explicit adapter target.
- Parameters:
message (str | Message)
target (Any | None)
- Return type:
Any
Return the runtime-wide shared state mapping.
- property state: dict[str, Any]¶
Return this plugin’s private state mapping.
- property text: str¶
Return the plain text carried by the current event.
- class iamai.Depends(provider, use_cache=True)[source]¶
Bases:
objectDeclare that a parameter should be resolved from a dependency provider.
- Parameters:
provider (Callable[[...], Any] | Any)
use_cache (bool)
- provider: Callable[[...], Any] | Any¶
- use_cache: bool¶
- class iamai.Event(id, adapter, platform, type, detail_type=None, sub_type=None, user_id=None, channel_id=None, guild_id=None, self_id=None, message=<factory>, raw=<factory>)[source]¶
Bases:
objectAdapter-agnostic event payload used by the dispatch pipeline.
- Parameters:
id (str)
adapter (str)
platform (str)
type (str)
detail_type (str | None)
sub_type (str | None)
user_id (str | None)
channel_id (str | None)
guild_id (str | None)
self_id (str | None)
message (Message)
raw (dict[str, Any])
- id: str¶
- adapter: str¶
- platform: str¶
- type: str¶
- detail_type: str | None¶
- sub_type: str | None¶
- user_id: str | None¶
- channel_id: str | None¶
- guild_id: str | None¶
- self_id: str | None¶
- raw: dict[str, Any]¶
- classmethod from_dict(payload)[source]¶
Build an event from a normalized dictionary payload.
- Parameters:
payload (dict[str, Any])
- Return type:
- property text: str¶
Return the plain text representation of the event message.
- class iamai.Message(value=None, *, core=None)[source]¶
Bases:
objectProtocol-neutral message builder and container.
- Parameters:
value (str | Iterable[Mapping[str, Any]] | 'Message' | None)
core (CoreMessage | None)
- append(kind, **data)[source]¶
Append a generic segment and return this message.
- Parameters:
kind (str)
data (Any)
- Return type:
- append_text(text)[source]¶
Append a text segment and return this message.
- Parameters:
text (str)
- Return type:
- property core: MagicMock¶
Return the underlying Rust-backed core message object.
- classmethod ensure(value)[source]¶
Return
valueas aMessageinstance.- Parameters:
value (str | 'Message' | Iterable[Mapping[str, Any]])
- Return type:
- extend(other)[source]¶
Append all segments from another message-like value.
- Parameters:
other (str | 'Message' | Iterable[Mapping[str, Any]])
- Return type:
- classmethod from_onebot11(payload)[source]¶
Create a message from a OneBot11 message payload.
- Parameters:
payload (Any)
- Return type:
- render_text()[source]¶
Render the message into a debug-friendly text representation.
- Return type:
str
- property segments: list[dict[str, Any]]¶
Return message segments as plain dictionaries.
- class iamai.FieldCondition(path, op=FieldOp.EXISTS, value=<object object>, source='event', capture_as=None, flags=0)[source]¶
Bases:
objectOne field comparison used by
fieldandmatch_fields.- Parameters:
path (str | Sequence[str])
op (FieldOp)
value (Any)
source (Literal['event', 'raw', 'state', 'shared_state', 'matches', 'context'])
capture_as (str | None)
flags (int)
- path: str | Sequence[str]¶
- value: Any¶
- source: Literal['event', 'raw', 'state', 'shared_state', 'matches', 'context']¶
- capture_as: str | None¶
- flags: int¶
- class iamai.FieldOp(*values)[source]¶
Bases:
str,EnumSupported operators for dotted-path field rules.
- EXISTS = 'exists'¶
- EQUALS = 'equals'¶
- NOT_EQUALS = 'not_equals'¶
- IN = 'in'¶
- CONTAINS = 'contains'¶
- STARTSWITH = 'startswith'¶
- ENDSWITH = 'endswith'¶
- REGEX = 'regex'¶
- GT = 'gt'¶
- GE = 'ge'¶
- LT = 'lt'¶
- LE = 'le'¶
- iamai.adapter_in(*adapter_names)[source]¶
Allow only events emitted by one of the selected adapters.
- Parameters:
adapter_names (str)
- Return type:
- iamai.adapter_is(*names)[source]¶
Match events emitted by one of the selected adapters.
- Parameters:
names (str)
- Return type:
- iamai.all_rules(*values)¶
Create a rule that matches only when every child rule matches.
- Parameters:
values (Any)
- Return type:
- iamai.any_rules(*values)¶
Create a rule that matches when at least one child rule matches.
- Parameters:
values (Any)
- Return type:
- iamai.channel_in(*channel_ids)[source]¶
Allow only events from one of the selected channel IDs.
- Parameters:
channel_ids (str | int)
- Return type:
- class iamai.Plugin(runtime)[source]¶
Bases:
objectBase class for user-defined iamai plugins.
- Parameters:
runtime (Runtime)
- property config: dict[str, Any]¶
Return a copy of this plugin’s raw configuration mapping.
- config_model: type[Any] | None = None¶
- property config_obj: Any | None¶
Return the validated plugin configuration object, if configured.
- description: str = ''¶
- iter_handlers()[source]¶
Return handlers declared on this plugin instance.
- Return type:
list[BoundHandler]
- iter_middlewares()[source]¶
Return middleware callbacks declared on this plugin instance.
- Return type:
list[BoundMiddleware]
- load_after: tuple[str, ...] = ()¶
- load_before: tuple[str, ...] = ()¶
- name: str | None = None¶
- optional_requires: tuple[str, ...] = ()¶
- property plugin_name: str¶
Return the effective plugin name used by config and state.
- priority = 100¶
- requires: tuple[str, ...] = ()¶
- state_scope: str = 'memory'¶
- iamai.command(*names, prefixes=None, adapters=None, event_types=None, detail_types=None, rule=None, permission=None, priority=100, block=False)[source]¶
Decorate a plugin method as a command handler.
- Parameters:
names (str)
prefixes (tuple[str, ...] | list[str] | None)
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]
- iamai.channel_id_is(*values)[source]¶
Match events whose
channel_idis invalues.- Parameters:
values (str | int)
- Return type:
- iamai.contains(*tokens, require_all=False)[source]¶
Match message text containing any token, or every token if requested.
- Parameters:
tokens (str)
require_all (bool)
- Return type:
- iamai.detail_type_is(*names)[source]¶
Match events whose normalized detail type is in
names.- Parameters:
names (str)
- Return type:
- iamai.depends(provider, *, use_cache=True)[source]¶
Return a dependency marker for a handler or middleware parameter.
- Parameters:
provider (Callable[[...], Any] | Any)
use_cache (bool)
- Return type:
Any
- iamai.endswith(*suffixes)[source]¶
Match message text that ends with one of
suffixes.- Parameters:
suffixes (str)
- Return type:
- iamai.event_handler(*, adapters=None, event_types=None, detail_types=None, rule=None, permission=None, priority=100, block=False)[source]¶
Decorate a plugin method as a generic event handler.
- Parameters:
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]
- iamai.event_type_is(*names)[source]¶
Match events whose normalized event type is in
names.- Parameters:
names (str)
- Return type:
- iamai.field(path, *, source='event', exists=None, equals=<object object>, not_equals=<object object>, in_=None, contains=<object object>, startswith=None, endswith=None, regex=None, gt=<object object>, ge=<object object>, lt=<object object>, le=<object object>, capture_as=None, flags=0)[source]¶
Match a dotted path on event/raw/state/shared_state/matches/context.
Multiple comparisons are combined with logical AND. When
capture_asis provided, the resolved value is exposed in the rule payload.- Parameters:
path (str | Sequence[str])
source (Literal['event', 'raw', 'state', 'shared_state', 'matches', 'context'])
exists (bool | None)
equals (Any)
not_equals (Any)
in_ (Iterable[Any] | None)
contains (Any)
startswith (str | tuple[str, ...] | None)
endswith (str | tuple[str, ...] | None)
regex (str | Pattern[str] | None)
gt (Any)
ge (Any)
lt (Any)
le (Any)
capture_as (str | None)
flags (int)
- Return type:
- iamai.fullmatch(pattern, *, flags=0)[source]¶
Match stripped message text with
re.fullmatchand expose groups.- Parameters:
pattern (str)
flags (int)
- Return type:
- iamai.group_in(*group_ids)[source]¶
Allow only group-like events from one of the selected group IDs.
- Parameters:
group_ids (str | int)
- Return type:
- iamai.guild_id_is(*values)[source]¶
Match events whose
guild_idis invalues.- Parameters:
values (str | int)
- Return type:
- iamai.match_fields(*conditions)[source]¶
Create a rule that requires every field condition to match.
- Parameters:
conditions (FieldCondition)
- Return type:
- iamai.middleware(*, priority=100, phase='around')[source]¶
Decorate a plugin method as middleware for the selected dispatch phase.
- Parameters:
priority (int)
phase (Literal['before', 'around', 'after', 'error'])
- Return type:
Callable[[MiddlewareFunc], MiddlewareFunc]
- iamai.message_handler(*, adapters=None, event_types=None, detail_types=None, startswith=None, contains=None, regex=None, rule=None, permission=None, priority=100, block=False)[source]¶
Decorate a plugin method as a message handler.
- Parameters:
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
startswith (tuple[str, ...] | list[str] | None)
contains (tuple[str, ...] | list[str] | None)
regex (str | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]
- iamai.none_of(*values)[source]¶
Create a rule that matches only when none of the child rules match.
- Parameters:
values (Any)
- Return type:
- iamai.permission(func)[source]¶
Wrap a callable as a dependency-injected permission predicate.
- Parameters:
func (Callable[[...], Any])
- Return type:
- iamai.permission_predicate(func)¶
Alias for
permissionthat reads naturally in decorator arguments.- Parameters:
func (Callable[[...], Any])
- Return type:
- iamai.platform_is(*names)[source]¶
Match events emitted by one of the selected platforms.
- Parameters:
names (str)
- Return type:
- iamai.raw_field(path, **kwargs)[source]¶
Match a dotted path inside
event.raw.- Parameters:
path (str | Sequence[str])
kwargs (Any)
- Return type:
- iamai.regex(pattern, *, flags=0)[source]¶
Match message text with
re.searchand expose named groups.- Parameters:
pattern (str)
flags (int)
- Return type:
- iamai.rule(func)[source]¶
Wrap a callable as a dependency-injected event matching rule.
- Parameters:
func (Callable[[...], bool | Mapping[str, Any] | tuple[bool, Mapping[str, Any] | None] | None | Awaitable[bool | Mapping[str, Any] | tuple[bool, Mapping[str, Any] | None] | None]])
- Return type:
- iamai.rule_predicate(func)¶
Alias for
rulethat reads naturally in decorator arguments.- Parameters:
func (Callable[[...], Any])
- Return type:
- class iamai.RuleCase(name, rule, priority=100)[source]¶
Bases:
objectOne named rule inside a
Ruleset.- Parameters:
name (str)
rule (Rule)
priority (int)
- name: str¶
- priority: int¶
- class iamai.RuleMatch(name, priority, payload=<factory>)[source]¶
Bases:
objectResult produced by
Rulesetevaluation.- Parameters:
name (str)
priority (int)
payload (dict[str, Any])
- name: str¶
- priority: int¶
- payload: dict[str, Any]¶
- class iamai.Ruleset(name, cases=())[source]¶
Bases:
objectA priority-ordered collection of named rules.
This mirrors rule-engine style rulesets without changing iamai handler dispatch. Use it inside a single handler rule when you need explainable, named branches.
- Parameters:
name (str)
cases (tuple[RuleCase, ...])
- name: str¶
- as_rule(*, first=True, capture_as='ruleset')[source]¶
Convert this ruleset into a single rule.
When
firstis true, evaluation stops at the first matching case. Otherwise all matching cases are evaluated and returned.- Parameters:
first (bool)
capture_as (str)
- Return type:
- iamai.ruleset(name='ruleset')[source]¶
Create an empty named ruleset.
- Parameters:
name (str)
- Return type:
- iamai.startswith(*prefixes)[source]¶
Match message text that starts with one of
prefixes.- Parameters:
prefixes (str)
- Return type:
- iamai.state_field(path, **kwargs)[source]¶
Match a dotted path inside the current plugin state.
- Parameters:
path (str | Sequence[str])
kwargs (Any)
- Return type:
- iamai.superusers(*user_ids)[source]¶
Allow configured runtime superusers or the explicit IDs passed here.
- Parameters:
user_ids (str | int)
- Return type:
- iamai.text_equals(*values, ignore_case=False, strip=True)[source]¶
Match message text exactly against one of
values.- Parameters:
values (str)
ignore_case (bool)
strip (bool)
- Return type:
- iamai.user_id_is(*values)[source]¶
Match events whose
user_idis invalues.- Parameters:
values (str | int)
- Return type:
- iamai.user_in(*user_ids)[source]¶
Allow only events whose
user_idappears inuser_ids.- Parameters:
user_ids (str | int)
- Return type:
- iamai.when_all(*values)[source]¶
Alias for
all_ofinspired by ruleset engines.- Parameters:
values (Any)
- Return type:
- iamai.when_any(*values)[source]¶
Alias for
any_ofinspired by ruleset engines.- Parameters:
values (Any)
- Return type:
- iamai.word_in(*words, ignore_case=True)[source]¶
Match whole words in message text.
- Parameters:
words (str)
ignore_case (bool)
- Return type:
- iamai.on_command(*names, prefixes=None, adapters=None, event_types=None, detail_types=None, rule=None, permission=None, priority=100, block=False)¶
Decorate a plugin method as a command handler.
- Parameters:
names (str)
prefixes (tuple[str, ...] | list[str] | None)
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]
- iamai.on_message(*, adapters=None, event_types=None, detail_types=None, startswith=None, contains=None, regex=None, rule=None, permission=None, priority=100, block=False)¶
Decorate a plugin method as a message handler.
- Parameters:
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
startswith (tuple[str, ...] | list[str] | None)
contains (tuple[str, ...] | list[str] | None)
regex (str | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]
- iamai.on_event(*, adapters=None, event_types=None, detail_types=None, rule=None, permission=None, priority=100, block=False)¶
Decorate a plugin method as a generic event handler.
- Parameters:
adapters (tuple[str, ...] | list[str] | None)
event_types (tuple[str, ...] | list[str] | None)
detail_types (tuple[str, ...] | list[str] | None)
rule (Rule | Callable[[...], Any] | None)
permission (Permission | Callable[[...], Any] | None)
priority (int)
block (bool)
- Return type:
Callable[[HandlerFunc], HandlerFunc]