mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-02-23 00:29:59 +08:00
ica 1.6.7 & tailchat 1.2.6
This commit is contained in:
parent
ede6640aa9
commit
c23b3ee67a
|
@ -151,7 +151,7 @@ impl Display for NewMessage {
|
|||
self.room_id,
|
||||
self.msg.sender_id,
|
||||
self.msg.sender_name,
|
||||
self.msg.files[0].name
|
||||
self.msg.files[0]
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
|
|
|
@ -3,6 +3,7 @@ pub mod events;
|
|||
|
||||
// use std::sync::OnceLock;
|
||||
|
||||
use colored::Colorize;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::{async_any_callback, async_callback};
|
||||
use rust_socketio::{Event, Payload, TransportType};
|
||||
|
@ -66,7 +67,11 @@ pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientRe
|
|||
.await
|
||||
{
|
||||
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
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
@ -18,8 +18,6 @@ mod tailchat;
|
|||
use config::BotConfig;
|
||||
use tracing::{event, span, Level};
|
||||
|
||||
use crate::py::call;
|
||||
|
||||
pub static mut MAIN_STATUS: status::BotStatus = status::BotStatus {
|
||||
config: None,
|
||||
ica_status: None,
|
||||
|
@ -31,8 +29,8 @@ 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.5";
|
||||
pub const TAILCHAT_VERSION: &str = "1.2.5";
|
||||
pub const ICA_VERSION: &str = "1.6.7";
|
||||
pub const TAILCHAT_VERSION: &str = "1.2.6";
|
||||
|
||||
const HELP_MSG: &str = r#"/bot-rs
|
||||
展示 rust 侧信息
|
||||
|
|
|
@ -18,12 +18,6 @@ pub struct 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<()>) {
|
||||
self.ica_new_message.push(handle);
|
||||
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 {
|
||||
self.ica_new_message.len() + self.ica_delete_message.len() + self.tailchat_new_message.len()
|
||||
}
|
||||
|
|
|
@ -255,6 +255,14 @@ impl IcaClientPy {
|
|||
#[getter]
|
||||
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() }
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::time::SystemTime;
|
|||
use pyo3::prelude::*;
|
||||
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use tokio::runtime::Runtime;
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
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() }
|
||||
#[getter]
|
||||
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() }
|
||||
|
|
12
news.md
12
news.md
|
@ -14,6 +14,18 @@
|
|||
- 现在会记录所有的 python 运行中 task 了
|
||||
- 也会在退出的时候等待所有的 task 结束
|
||||
- 二次 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user