ica 1.6.7 & tailchat 1.2.6

This commit is contained in:
shenjack 2025-02-12 00:02:05 +08:00
parent ede6640aa9
commit c23b3ee67a
Signed by: shenjack
GPG Key ID: 7B1134A979775551
7 changed files with 46 additions and 12 deletions

View File

@ -151,7 +151,7 @@ impl Display for NewMessage {
self.room_id, self.room_id,
self.msg.sender_id, self.msg.sender_id,
self.msg.sender_name, self.msg.sender_name,
self.msg.files[0].name self.msg.files[0]
) )
} else { } else {
write!( write!(

View File

@ -3,6 +3,7 @@ pub mod events;
// use std::sync::OnceLock; // use std::sync::OnceLock;
use colored::Colorize;
use rust_socketio::asynchronous::{Client, ClientBuilder}; use rust_socketio::asynchronous::{Client, ClientBuilder};
use rust_socketio::{async_any_callback, async_callback}; use rust_socketio::{async_any_callback, async_callback};
use rust_socketio::{Event, Payload, TransportType}; use rust_socketio::{Event, Payload, TransportType};
@ -66,7 +67,11 @@ pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientRe
.await .await
{ {
Ok(client) => { Ok(client) => {
event!(Level::INFO, "socketio connected time: {:?}", start_connect_time.elapsed()); event!(
Level::INFO,
"{}",
format!("socketio connected time: {:?}", start_connect_time.elapsed()).on_cyan()
);
client client
} }
Err(e) => { Err(e) => {

View File

@ -18,8 +18,6 @@ mod tailchat;
use config::BotConfig; use config::BotConfig;
use tracing::{event, span, Level}; use tracing::{event, span, Level};
use crate::py::call;
pub static mut MAIN_STATUS: status::BotStatus = status::BotStatus { pub static mut MAIN_STATUS: status::BotStatus = status::BotStatus {
config: None, config: None,
ica_status: None, ica_status: None,
@ -31,8 +29,8 @@ 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.5"; pub const ICA_VERSION: &str = "1.6.7";
pub const TAILCHAT_VERSION: &str = "1.2.5"; pub const TAILCHAT_VERSION: &str = "1.2.6";
const HELP_MSG: &str = r#"/bot-rs const HELP_MSG: &str = r#"/bot-rs
rust rust

View File

@ -18,12 +18,6 @@ pub struct PyTasks {
} }
impl PyTasks { impl PyTasks {
pub fn clear(&mut self) {
self.ica_new_message.clear();
self.ica_delete_message.clear();
self.tailchat_new_message.clear();
}
pub fn push_ica_new_message(&mut self, handle: tokio::task::JoinHandle<()>) { pub fn push_ica_new_message(&mut self, handle: tokio::task::JoinHandle<()>) {
self.ica_new_message.push(handle); self.ica_new_message.push(handle);
self.ica_new_message.retain(|handle| !handle.is_finished()); self.ica_new_message.retain(|handle| !handle.is_finished());
@ -51,6 +45,13 @@ impl PyTasks {
} }
} }
pub fn len_check(&mut self) -> usize {
self.ica_delete_message.retain(|handle| !handle.is_finished());
self.ica_new_message.retain(|handle| !handle.is_finished());
self.tailchat_new_message.retain(|handle| !handle.is_finished());
self.ica_new_message.len() + self.ica_delete_message.len() + self.tailchat_new_message.len()
}
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.ica_new_message.len() + self.ica_delete_message.len() + self.tailchat_new_message.len() self.ica_new_message.len() + self.ica_delete_message.len() + self.tailchat_new_message.len()
} }

View File

@ -255,6 +255,14 @@ impl IcaClientPy {
#[getter] #[getter]
pub fn get_startup_time(&self) -> SystemTime { crate::start_up_time() } pub fn get_startup_time(&self) -> SystemTime { crate::start_up_time() }
#[getter]
pub fn get_py_tasks_count(&self) -> usize {
tokio::task::block_in_place(|| {
let rt = Runtime::new().unwrap();
rt.block_on(async { crate::py::call::PY_TASKS.lock().await.len_check() })
})
}
/// 重新加载插件状态 /// 重新加载插件状态
/// 返回是否成功 /// 返回是否成功
pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() } pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() }

View File

@ -3,6 +3,7 @@ use std::time::SystemTime;
use pyo3::prelude::*; use pyo3::prelude::*;
use rust_socketio::asynchronous::Client; use rust_socketio::asynchronous::Client;
use tokio::runtime::Runtime;
use tracing::{debug, info, warn}; use tracing::{debug, info, warn};
use crate::data_struct::tailchat::messages::{ReceiveMessage, SendingFile, SendingMessage}; use crate::data_struct::tailchat::messages::{ReceiveMessage, SendingFile, SendingMessage};
@ -73,6 +74,15 @@ impl TailchatClientPy {
pub fn get_tailchat_version(&self) -> String { crate::TAILCHAT_VERSION.to_string() } pub fn get_tailchat_version(&self) -> String { crate::TAILCHAT_VERSION.to_string() }
#[getter] #[getter]
pub fn get_startup_time(&self) -> SystemTime { crate::start_up_time() } pub fn get_startup_time(&self) -> SystemTime { crate::start_up_time() }
#[getter]
pub fn get_py_tasks_count(&self) -> usize {
tokio::task::block_in_place(|| {
let rt = Runtime::new().unwrap();
rt.block_on(async { crate::py::call::PY_TASKS.lock().await.len_check() })
})
}
/// 重新加载插件状态 /// 重新加载插件状态
/// 返回是否成功 /// 返回是否成功
pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() } pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() }

12
news.md
View File

@ -14,6 +14,18 @@
- 现在会记录所有的 python 运行中 task 了 - 现在会记录所有的 python 运行中 task 了
- 也会在退出的时候等待所有的 task 结束 - 也会在退出的时候等待所有的 task 结束
- 二次 ctrl-c 会立即退出 - 二次 ctrl-c 会立即退出
- 改进了一下 ica 的新消息显示
- 添加了 ica 链接用时的显示
### ica 1.6.7
- 为 `IcaClinet` 添加了 `py_tasks_count -> int` 属性
- 用于获取当前运行中的 python task 数量
### tailchat 1.2.6
- 为 `TailchatClient` 添加了 `py_tasks_count -> int` 属性
- 用于获取当前运行中的 python task 数量
## 0.8.1 ## 0.8.1