From 1c62e4aa0e14d83239692ef23f5a17d90831c99f Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 18 Aug 2024 02:14:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E4=B8=8B=E5=B0=8F=E4=BF=AE=E5=B0=8F?= =?UTF-8?q?=E8=A1=A5=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/src/ica/events.rs | 6 ++++-- ica-rs/src/main.rs | 18 ++++++++++++++++-- ica-rs/src/tailchat/events.rs | 5 ++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ica-rs/src/ica/events.rs b/ica-rs/src/ica/events.rs index 6d8f5f4..46e8b0d 100644 --- a/ica-rs/src/ica/events.rs +++ b/ica-rs/src/ica/events.rs @@ -9,7 +9,7 @@ use crate::data_struct::ica::all_rooms::Room; use crate::data_struct::ica::messages::{Message, MessageTrait, NewMessage}; use crate::data_struct::ica::online_data::OnlineData; use crate::ica::client::send_message; -use crate::{py, version_str, MainStatus, VERSION}; +use crate::{help_msg, py, version_str, MainStatus, VERSION}; /// 获取在线数据 pub async fn get_online_data(payload: Payload, _client: Client) { @@ -22,7 +22,6 @@ pub async fn get_online_data(payload: Payload, _client: Client) { } } -// #[allow(clippy::collapsible_if)] /// 接收消息 pub async fn add_message(payload: Payload, client: Client) { if let Payload::Text(values) = payload { @@ -51,6 +50,9 @@ pub async fn add_message(payload: Payload, client: Client) { } )); send_message(&client, &reply).await; + } else if message.content() == "/bot-help" { + let reply = message.reply_with(&help_msg()); + send_message(&client, &reply).await; } if MainStatus::global_config().ica().admin_list.contains(&message.sender_id()) { // admin 区 diff --git a/ica-rs/src/main.rs b/ica-rs/src/main.rs index 7112425..6519ae5 100644 --- a/ica-rs/src/main.rs +++ b/ica-rs/src/main.rs @@ -26,9 +26,23 @@ pub type MainStatus = status::BotStatus; pub type StopGetter = tokio::sync::oneshot::Receiver<()>; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); -pub const ICA_VERSION: &str = "1.6.1"; -pub const TAILCHAT_VERSION: &str = "1.2.1"; +pub const ICA_VERSION: &str = "1.6.2"; +pub const TAILCHAT_VERSION: &str = "1.2.2"; +const HELP_MSG: &str = r#"/bot-rs + 展示 rust 侧信息 +/bot-py + 展示 python 侧信息(如果python插件启用了的话) +/bot-ls + 显示所有插件信息 +/bot-enable + 启用某个插件 +/bot-disable + 禁用某个插件 + +by shenjackyuanjie"#; + +pub fn help_msg() -> String { format!("{}\n{}", version_str(), HELP_MSG) } pub fn version_str() -> String { format!( "shenbot-rs v{}-{} ica v{}({}) tailchat v{}", diff --git a/ica-rs/src/tailchat/events.rs b/ica-rs/src/tailchat/events.rs index 3f2cb66..fe78814 100644 --- a/ica-rs/src/tailchat/events.rs +++ b/ica-rs/src/tailchat/events.rs @@ -9,7 +9,7 @@ use tracing::{event, info, Level}; use crate::data_struct::tailchat::messages::ReceiveMessage; use crate::data_struct::tailchat::status::{BotStatus, UpdateDMConverse}; use crate::tailchat::client::{emit_join_room, send_message}; -use crate::{py, MainStatus, TAILCHAT_VERSION, VERSION}; +use crate::{help_msg, py, MainStatus, TAILCHAT_VERSION, VERSION}; /// 所有 pub async fn any_event(event: Event, payload: Payload, _client: Client, _status: Arc) { @@ -94,6 +94,9 @@ pub async fn on_message(payload: Payload, client: Client, _status: Arc