Robot developed based on RICQ framework
一个基于 RICQ 开发的机器人
交流群: 787049553
提供原始的MessageEvent供用户自行使用
#[async_trait]
impl RawPlugin for Repeater {
async fn on_event(&self, event: &MessageEvent) -> anyhow::Result<bool> {
event.send_message_to_source("Hello World!".parse_message_chain()).await.unwrap();
Ok(true)
}
}
用户提供注解编写预设的命令,插件系统往方法中注入参数,供用户使用
pub struct Hello {
actions: Vec<Box<dyn Action>>,
}
impl Hello {
pub fn new() -> Self {
Remind {
actions: vec![
make_action!(hello)
]
}
}
}
#[async_trait]
impl CommandPlugin for Hello {
fn get_actions(&self) -> &Vec<Box<dyn Action>> {
&self.actions
}
}
#[action("hello {name}")]
async fn hello(event: &MessageEvent, name: Option<String>) -> anyhow::Result<bool> {
if name.is_none() {
return Ok(false);
}
event.send_message_to_source(format!("hello {}", name.unwrap()).parse_message_chain()).await.unwrap();
Ok(true)
}
详见 项目页面
1.1. Clone 或者下载这个项目.
git clone https://github.com/LovesAsuna/SimpleBot.git
1.2. 编译
cargo run
IntelliJ IDEA 是一个在各个方面都最大程度地提高开发人员的生产力的 IDE,适用于 JVM 平台语言。
特别感谢 JetBrains 为开源项目提供免费的 IntelliJ IDEA 等 IDE 的授权