Expand description
§Russenger Library
The Russenger library provides a set of modules and macros to help you build bots using the Russenger bot framework.
§Modules
cli
: This module provides command-line interface utilities.core
: This module contains the core functionalities of the Russenger bot framework.prelude
: This module re-exports important traits and structs for convenience.query
: This module provides utilities for handling queries.response_models
: This module contains models for different types of responses.
§Macros
action
: This proc macro is used to define an action.russenger_app
: This macro is used to create the main application.
§Deprecated
create_action
: This macro is deprecated. Please use the#[action]
proc macro instead. It was used to create a new action that sends a greeting message when the user input is “Hello”.
§Examples
Creating a new action that sends a greeting message when the user input is “Hello”: using the new #[action]
proc macro:
use russenger::prelude::*;
#[action]
async fn Main(res: Res, req: Req) {
let message: String = req.data.get_value();
if message == "Hello" {
res.send(TextModel::new(&req.user, "Hello, welcome to our bot!")).await;
}
}
russenger_app!(Main);
Re-exports§
pub use cli::launch;
pub use core::action::Action;
pub use core::action::ACTION_REGISTRY;
pub use core::action::ACTION_REGISTRY;
Modules§
- The
cli
module contains the command line interface for the application. - The
core
module contains the core functionality of the application. - This allows users to include everything they need with a single
use
statement. - The
query
module provides utilities for handling queries. TheQuery
struct represents a database query. It includes aDB
enum that represents the database connection. - The
response_models
module contains various response models that can be sent to a user.
Macros§
- create_actionDeprecatedDeprecated
- The
russenger_app!
macro is used to create the main application.
Functions§
- This is usually what you want. It loads the .env file located in the environment’s current directory or its parents in sequence.
Attribute Macros§
- The
#[action]
proc macro is used to create a new action. - Marks async main function as the Actix Web system entry-point.