Struct Bot

Source
pub struct Bot {
    pub information: BotInformation,
    /* private fields */
}
Expand description

bot结构体

Fields§

§information: BotInformation

Implementations§

Source§

impl Bot

Source

pub fn spawn<F>(&mut self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Source

pub fn run(self)

运行bot

注意此函数会阻塞, 直到Bot连接失效,或者有退出信号传入程序

Source§

impl Bot

Source

pub fn build<C>(conf: C) -> Bot
where C: AsRef<KoviConf>,

构建一个bot实例

§Examples
let conf = KoviConf::new(
    123456,
    None,
    Server {
        host: "127.0.0.1".parse(),
        port: 8081,
        access_token: "",
    },
    false,
    None,
);
let bot = Bot::build(conf);
bot.run()
Source

pub fn mount_main<T>( &mut self, name: T, version: T, main: Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>, )
where String: From<T>,

挂载插件的启动函数。

Source

pub fn load_local_conf() -> Result<KoviConf, BotBuildError>

读取本地Kovi.conf.toml文件

Source§

impl Bot

Source

pub fn set_plugin_startup_use_file(self) -> Self

使用KoviConf设置插件在Bot启动时的状态

如果配置文件中没有对应的插件,将会被忽略,保留插件默认状态

如果配置文件读取失败或者解析toml失败,将会保留插件默认状态

Source

pub fn set_plugin_startup_use_file_ref(&mut self)

使用KoviConf设置插件在Bot启动时的状态

如果配置文件中没有对应的插件,将会被忽略,保留插件默认状态

如果配置文件读取失败或者解析toml失败,将会保留插件默认状态

Source

pub fn set_all_plugin_startup(self, enabled: bool) -> Self

设置全部插件在Bot启动时的状态

Source

pub fn set_all_plugin_startup_ref(&mut self, enabled: bool)

设置全部插件在Bot启动时的状态

Source

pub fn set_plugin_startup<T: AsRef<str>>( self, name: T, enabled: bool, ) -> Result<Self, BotError>

设置单个插件在Bot启动时的状态

Source

pub fn set_plugin_startup_ref<T: AsRef<str>>( &mut self, name: T, enabled: bool, ) -> Result<(), BotError>

设置单个插件在Bot启动时的状态

Trait Implementations§

Source§

impl Clone for Bot

Source§

fn clone(&self) -> Bot

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Bot

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Bot

§

impl !RefUnwindSafe for Bot

§

impl Send for Bot

§

impl Sync for Bot

§

impl Unpin for Bot

§

impl !UnwindSafe for Bot

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V