0.4.8
This commit is contained in:
parent
152c8215c3
commit
1f7ffcb2d4
@ -10,6 +10,8 @@ notice_start = true # 是否在启动 bot 后通知
|
||||
|
||||
# 机器人的管理员
|
||||
admin_list = [0] # 机器人的管理员
|
||||
# 过滤的人
|
||||
filter_list = [0]
|
||||
|
||||
# python 插件路径
|
||||
py_plugin_path = "/path/to/your/plugin"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ica-rs"
|
||||
version = "0.4.7"
|
||||
version = "0.4.8"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -96,7 +96,7 @@ def parse_rank(data: dict) -> dict:
|
||||
"start": data["isEnabled"],
|
||||
# "full": "全量" if "fullSize" in data else "分片",
|
||||
# "version": data["version"] if "version" in data else "未知版本",
|
||||
"owner": data["sponsor"]["name"] if "sponsor" in data else "未知用户",
|
||||
"owner": data["sponsor"]["name"] if "sponsor" in data else "未知",
|
||||
"rank": rank_data
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ def bmcl_rank(msg: NewMessage, client: IcaClient, name: Optional[str]) -> None:
|
||||
# 搜索是否有这个名字的节点
|
||||
names = [r["name"].lower() for r in ranks]
|
||||
finds = [re.search(name.lower(), n) for n in names]
|
||||
if not finds:
|
||||
if not any(finds):
|
||||
reply = msg.reply_with(f"未找到名为{name}的节点")
|
||||
client.send_message(reply)
|
||||
return
|
||||
@ -150,7 +150,7 @@ def bmcl_rank(msg: NewMessage, client: IcaClient, name: Optional[str]) -> None:
|
||||
# 4~10 个节点 只显示名称和次序
|
||||
find_msg = [f"{'✅' if r['start'] else '❌'}{r['name']}-No.{i+1}" for i, r in enumerate(ranks) if finds[i]]
|
||||
find_msg = "\n".join(find_msg)
|
||||
report_msg = f"OpenBMCLAPI 面板v{_version_}-搜索|{name}|\n{find_msg}\n"
|
||||
report_msg = f"OpenBMCLAPI 面板v{_version_}-搜索|{name}|\n{find_msg}"
|
||||
reply = msg.reply_with(report_msg)
|
||||
client.send_message(reply)
|
||||
return
|
||||
@ -167,7 +167,7 @@ def bmcl_rank(msg: NewMessage, client: IcaClient, name: Optional[str]) -> None:
|
||||
)
|
||||
rank_msgs.append(rank_msg)
|
||||
rank_msgs = "\n".join(rank_msgs)
|
||||
report_msg = f"OpenBMCLAPI 面板v{_version_}-排名\n{rank_msgs}\n"
|
||||
report_msg = f"OpenBMCLAPI 面板v{_version_}-排名\n{rank_msgs}"
|
||||
reply = msg.reply_with(report_msg)
|
||||
client.info(report_msg)
|
||||
client.send_message(reply)
|
||||
@ -178,8 +178,7 @@ def bmcl_rank(msg: NewMessage, client: IcaClient, name: Optional[str]) -> None:
|
||||
|
||||
help = """/bmcl -> dashboard
|
||||
/bmcl rank -> all rank
|
||||
/bmcl rank <name> -> rank of <name>
|
||||
"""
|
||||
/bmcl rank <name> -> rank of <name>"""
|
||||
|
||||
|
||||
def on_message(msg: NewMessage, client: IcaClient) -> None:
|
||||
|
@ -19,6 +19,8 @@ pub struct IcaConfig {
|
||||
pub notice_start: bool,
|
||||
/// 管理员列表
|
||||
pub admin_list: Vec<i64>,
|
||||
/// 过滤列表
|
||||
pub filter_list: Vec<i64>,
|
||||
/// Python 插件路径
|
||||
pub py_plugin_path: Option<String>,
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ use crate::client::IcalinguaStatus;
|
||||
use crate::data_struct::files::MessageFile;
|
||||
use crate::data_struct::{MessageId, RoomId, UserId};
|
||||
|
||||
use tracing::warn;
|
||||
use chrono::NaiveDateTime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value as JsonValue};
|
||||
@ -138,7 +139,15 @@ impl NewMessage {
|
||||
}
|
||||
// 回复的消息
|
||||
let reply: Option<ReplyMessage> = match message.get("replyMessage") {
|
||||
Some(value) => serde_json::from_value::<ReplyMessage>(value.clone()).ok(),
|
||||
Some(value) => {
|
||||
match serde_json::from_value::<ReplyMessage>(value.clone()) {
|
||||
Ok(reply) => Some(reply),
|
||||
Err(e) => {
|
||||
warn!("Failed to parse reply message: {}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
// At
|
||||
@ -196,7 +205,8 @@ impl NewMessage {
|
||||
|
||||
pub fn output(&self) -> String {
|
||||
format!(
|
||||
"Room: {}, Sender: {}|{}, Content: {}",
|
||||
// >10 >10 >15
|
||||
"{:>10}|{:>12}|{:<20}|{}",
|
||||
self.room_id, self.sender_id, self.sender_name, self.content
|
||||
)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use rust_socketio::asynchronous::Client;
|
||||
use rust_socketio::{Event, Payload};
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::client::send_message;
|
||||
use crate::client::{send_message, IcalinguaStatus};
|
||||
use crate::data_struct::all_rooms::Room;
|
||||
use crate::data_struct::messages::NewMessage;
|
||||
use crate::data_struct::online_data::OnlineData;
|
||||
@ -16,7 +16,7 @@ pub async fn get_online_data(payload: Payload, _client: Client) {
|
||||
let online_data = OnlineData::new_from_json(value);
|
||||
info!(
|
||||
"update_online_data {}",
|
||||
format!("{:#?}", online_data).cyan()
|
||||
format!("{:?}", online_data).cyan()
|
||||
);
|
||||
unsafe {
|
||||
crate::ClientStatus.update_online_data(online_data);
|
||||
@ -30,7 +30,12 @@ pub async fn add_message(payload: Payload, client: Client) {
|
||||
if let Payload::Text(values) = payload {
|
||||
if let Some(value) = values.first() {
|
||||
let message = NewMessage::new_from_json(value);
|
||||
// 检测是否在过滤列表内
|
||||
if IcalinguaStatus::get_config().filter_list.contains(&message.sender_id) {
|
||||
return;
|
||||
}
|
||||
info!("add_message {}", message.output().cyan());
|
||||
// info!("add_message {}", format!("{:#?}", message).cyan());
|
||||
// 就在这里处理掉最基本的消息
|
||||
// 之后的处理交给插件
|
||||
if message.content.eq("/bot-rs") && !message.is_from_self() && !message.is_reply() {
|
||||
@ -49,7 +54,7 @@ pub async fn delete_message(payload: Payload, _client: Client) {
|
||||
// 消息 id
|
||||
if let Some(value) = values.first() {
|
||||
if let Some(msg_id) = value.as_str() {
|
||||
warn!("delete_message {}", format!("{}", msg_id).yellow());
|
||||
info!("delete_message {}", format!("{}", msg_id).yellow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user