1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use TokenStream;
use ;
use expand_plugin;
/// Generate a `RuntimePlugin` implementation from an `impl` block.
///
/// `#[plugin]` is the default authoring entrypoint. Put it on an `impl` block;
/// async methods in the impl become command handlers named after the method.
///
/// # Example
///
/// ```ignore
/// use ayiou::{plugin, Context};
///
/// #[derive(Default)]
/// struct EchoPlugin;
///
/// #[plugin(name = "echo", prefix = "/")]
/// impl EchoPlugin {
/// async fn echo(&self, ctx: &Context, text: String) -> anyhow::Result<()> {
/// ctx.reply_text(format!("Echo: {}", text)).await
/// }
/// }
/// ```
///
/// # Attributes
///
/// - `name`: Plugin name (defaults to struct name in lowercase)
/// - `description`: Plugin description
/// - `version`: Plugin version (defaults to "0.1.0")
/// - `prefix`: Command prefix accepted by this plugin (repeatable)
/// - `context`: Custom context type (defaults to `Context`)
/// - `register`: Whether to auto-register this plugin (defaults to `true`)
/// Mark a method in `#[plugin] impl` as a command handler.
///
/// This attribute is only consumed by `#[plugin]` and is otherwise a no-op.