mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
先更新一部分能跑的
This commit is contained in:
parent
28ec8d316d
commit
d6443f27bb
|
@ -2,10 +2,10 @@ 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};
|
||||
use tracing::warn;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum At {
|
||||
|
@ -139,13 +139,11 @@ impl NewMessage {
|
|||
}
|
||||
// 回复的消息
|
||||
let reply: Option<ReplyMessage> = match message.get("replyMessage") {
|
||||
Some(value) => {
|
||||
match serde_json::from_value::<ReplyMessage>(value.clone()) {
|
||||
Ok(reply) => Some(reply),
|
||||
Err(e) => {
|
||||
warn!("Failed to parse reply message: {}", e);
|
||||
None
|
||||
}
|
||||
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,
|
||||
|
|
|
@ -14,10 +14,7 @@ pub async fn get_online_data(payload: Payload, _client: Client) {
|
|||
if let Payload::Text(values) = payload {
|
||||
if let Some(value) = values.first() {
|
||||
let online_data = OnlineData::new_from_json(value);
|
||||
info!(
|
||||
"update_online_data {}",
|
||||
format!("{:?}", online_data).cyan()
|
||||
);
|
||||
info!("update_online_data {}", format!("{:?}", online_data).cyan());
|
||||
unsafe {
|
||||
crate::ClientStatus.update_online_data(online_data);
|
||||
}
|
||||
|
@ -31,7 +28,10 @@ pub async fn add_message(payload: Payload, client: Client) {
|
|||
if let Some(value) = values.first() {
|
||||
let message = NewMessage::new_from_json(value);
|
||||
// 检测是否在过滤列表内
|
||||
if IcalinguaStatus::get_config().filter_list.contains(&message.sender_id) {
|
||||
if IcalinguaStatus::get_config()
|
||||
.filter_list
|
||||
.contains(&message.sender_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
info!("add_message {}", message.output().cyan());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use pyo3::prelude::*;
|
||||
use tracing::{debug, info, warn};
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use tokio::runtime::Runtime;
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::client::send_message;
|
||||
use crate::data_struct::messages::{NewMessage, ReplyMessage, SendMessage};
|
||||
|
|
|
@ -57,7 +57,7 @@ impl PyStatus {
|
|||
}
|
||||
}
|
||||
true
|
||||
},
|
||||
}
|
||||
None => false,
|
||||
},
|
||||
None => false,
|
||||
|
@ -108,7 +108,11 @@ pub fn load_py_plugins(path: &PathBuf) {
|
|||
|
||||
pub fn verify_plugins() {
|
||||
let mut need_reload_files: Vec<PathBuf> = Vec::new();
|
||||
let plugin_path = IcalinguaStatus::get_config().py_plugin_path.as_ref().unwrap().to_owned();
|
||||
let plugin_path = IcalinguaStatus::get_config()
|
||||
.py_plugin_path
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
for entry in std::fs::read_dir(&plugin_path).unwrap() {
|
||||
if let Ok(entry) = entry {
|
||||
let path = entry.path();
|
||||
|
@ -165,13 +169,12 @@ pub fn load_py_module(path: &PathBuf) -> Option<(Option<SystemTime>, Py<PyAny>)>
|
|||
&path.to_string_lossy(),
|
||||
&path.to_string_lossy(),
|
||||
// !!!! 请注意, 一定要给他一个名字, cpython 会自动把后面的重名模块覆盖掉前面的
|
||||
).map(|module| module.into());
|
||||
)
|
||||
.map(|module| module.into());
|
||||
module
|
||||
});
|
||||
match py_module {
|
||||
Ok(py_module) => {
|
||||
Some((changed_time, py_module))
|
||||
}
|
||||
Ok(py_module) => Some((changed_time, py_module)),
|
||||
Err(e) => {
|
||||
warn!("failed to load file: {:?} | e: {:?}", path, e);
|
||||
None
|
||||
|
|
Loading…
Reference in New Issue
Block a user