这下小修小补了

This commit is contained in:
shenjack 2024-08-18 02:14:55 +08:00
parent 113a1518d1
commit 1c62e4aa0e
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 24 additions and 5 deletions

View File

@ -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::messages::{Message, MessageTrait, NewMessage};
use crate::data_struct::ica::online_data::OnlineData; use crate::data_struct::ica::online_data::OnlineData;
use crate::ica::client::send_message; 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) { 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) { pub async fn add_message(payload: Payload, client: Client) {
if let Payload::Text(values) = payload { if let Payload::Text(values) = payload {
@ -51,6 +50,9 @@ pub async fn add_message(payload: Payload, client: Client) {
} }
)); ));
send_message(&client, &reply).await; 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()) { if MainStatus::global_config().ica().admin_list.contains(&message.sender_id()) {
// admin 区 // admin 区

View File

@ -26,9 +26,23 @@ pub type MainStatus = status::BotStatus;
pub type StopGetter = tokio::sync::oneshot::Receiver<()>; pub type StopGetter = tokio::sync::oneshot::Receiver<()>;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const ICA_VERSION: &str = "1.6.1"; pub const ICA_VERSION: &str = "1.6.2";
pub const TAILCHAT_VERSION: &str = "1.2.1"; pub const TAILCHAT_VERSION: &str = "1.2.2";
const HELP_MSG: &str = r#"/bot-rs
rust
/bot-py
python (python插件启用了的话)
/bot-ls
/bot-enable <plugin>
/bot-disable <plugin>
by shenjackyuanjie"#;
pub fn help_msg() -> String { format!("{}\n{}", version_str(), HELP_MSG) }
pub fn version_str() -> String { pub fn version_str() -> String {
format!( format!(
"shenbot-rs v{}-{} ica v{}({}) tailchat v{}", "shenbot-rs v{}-{} ica v{}({}) tailchat v{}",

View File

@ -9,7 +9,7 @@ use tracing::{event, info, Level};
use crate::data_struct::tailchat::messages::ReceiveMessage; use crate::data_struct::tailchat::messages::ReceiveMessage;
use crate::data_struct::tailchat::status::{BotStatus, UpdateDMConverse}; use crate::data_struct::tailchat::status::{BotStatus, UpdateDMConverse};
use crate::tailchat::client::{emit_join_room, send_message}; 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<BotStatus>) { pub async fn any_event(event: Event, payload: Payload, _client: Client, _status: Arc<BotStatus>) {
@ -94,6 +94,9 @@ pub async fn on_message(payload: Payload, client: Client, _status: Arc<BotStatus
} }
)); ));
send_message(&client, &reply).await; 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().tailchat().admin_list.contains(&message.sender_id) { if MainStatus::global_config().tailchat().admin_list.contains(&message.sender_id) {
// admin 区 // admin 区