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
extern crate proc_macro;
use TokenStream;
use quote;
use ;
/// The `#[action]` proc macro is used to create a new action.
///
/// An action is a struct that implements the `Action` trait, which has two methods: `execute` and `path`.
///
/// The `execute` method is where you define how to handle the user input. It receives two parameters: `res` and `req`. `res` is a `Res` struct that you can use to send responses to the user, and `req` is a `Req` struct that contains the user input.
///
/// The `path` method returns the name of the action as a string.
///
/// # Examples
///
/// Creating a new action that sends a greeting message when the user input is "Hello":
///
/// ```rust
/// use russenger::prelude::*;
///
/// #[action]
/// async fn Main(res: russenger::prelude::Res, req: russenger::prelude::Req) {
/// let message: String = req.data.get_value();
/// if message == "Hello" {
/// res.send(TextModel::new(&req.user, "Hello, welcome to our bot!")).await;
/// }
/// }
/// ```
///
/// This macro simplifies the process of creating a new action by automatically generating the struct and implementing the `Action` trait for it.