Crate mys_villa

Expand description

Initializing bot instance

you can simply initialize a Bot instance by calling the new method

use mys_villa::bot::bot_event_handler::BotEventHandler;
use mys_villa::bot::bot_info::BotAuthInfo;
use mys_villa::bot::bot_permission::BotPermission;
use mys_villa::bot::Bot;
// the default implementation of request executor
use mys_villa::request::request_executor::request_executor_impl::RequestExecutorImpl;

let bot = Bot::new(
  BotAuthInfo::from_env()?,
  BotPermission::all(),
  RequestExecutorImpl::new()?,
  State,
  EventHandler,
);

Make a api request

for example if we want to get the villa info of villa by id 123456789

use mys_villa::api_type::villa::villa_info::VillaInfo;

// first create a instance of target villa,
// store it in variable for future reuse
let villa = bot.villa(12345789);
// then we can call the get_info method on the instance
let villa_info: VillaInfo = villa.get_info().await?;
println!("{}",villa_info.name); // name of this villa

Other

for more information, you can view the related module/struct documentation and examples

Modules