mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-02-22 14:59:55 +08:00
呐呐呐
This commit is contained in:
parent
0275863cfe
commit
073c711c7c
52
Cargo.lock
generated
52
Cargo.lock
generated
|
@ -71,9 +71,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.84"
|
||||
version = "0.1.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0"
|
||||
checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -138,9 +138,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
|||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
|
@ -200,11 +200,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.2.0"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
||||
checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
|
@ -389,6 +388,12 @@ version = "1.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
|
@ -684,6 +689,7 @@ dependencies = [
|
|||
"colored",
|
||||
"ed25519",
|
||||
"ed25519-dalek",
|
||||
"foldhash",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"md-5",
|
||||
|
@ -899,9 +905,9 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
|||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
|
@ -1418,9 +1424,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.42"
|
||||
version = "0.38.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85"
|
||||
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
|
@ -1431,9 +1437,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.20"
|
||||
version = "0.23.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b"
|
||||
checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"rustls-pki-types",
|
||||
|
@ -1504,9 +1510,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.13.0"
|
||||
version = "2.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5"
|
||||
checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
|
@ -1540,9 +1546,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.134"
|
||||
version = "1.0.135"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
|
||||
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
|
@ -1681,9 +1687,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.95"
|
||||
version = "2.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||
checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1824,9 +1830,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.42.0"
|
||||
version = "1.43.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551"
|
||||
checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
|
@ -1842,9 +1848,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.4.0"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -37,10 +37,10 @@ serde_json = "1.0"
|
|||
chrono = "0.4"
|
||||
toml = "0.8"
|
||||
toml_edit = "0.22.20"
|
||||
colored = "2.1"
|
||||
colored = "3.0"
|
||||
|
||||
# runtime
|
||||
tokio = { version = "1.41", features = ["full"] }
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
futures-util = "0.3.30"
|
||||
pyo3 = { version = "0.23", features = ["experimental-async", "py-clone"] }
|
||||
anyhow = { version = "1.0", features = ["backtrace"] }
|
||||
|
@ -49,5 +49,6 @@ anyhow = { version = "1.0", features = ["backtrace"] }
|
|||
# pyo3-asyncio = { version = "0.20.0", features = ["attributes", "tokio-runtime"] }
|
||||
|
||||
# log
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["time"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["time"] }
|
||||
foldhash = "0.1.4"
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use colored::Colorize;
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use rust_socketio::{Event, Payload};
|
||||
use serde_json::json;
|
||||
use tracing::{event, info, span, warn, Level};
|
||||
|
||||
use crate::data_struct::ica::all_rooms::Room;
|
||||
use crate::data_struct::ica::messages::{Message, MessageTrait, NewMessage};
|
||||
use crate::data_struct::ica::online_data::OnlineData;
|
||||
use crate::data_struct::ica::RoomId;
|
||||
use crate::ica::client::send_message;
|
||||
use crate::{client_id, help_msg, py, version_str, MainStatus, VERSION};
|
||||
|
||||
|
@ -30,7 +32,7 @@ pub async fn add_message(payload: Payload, client: Client) {
|
|||
return;
|
||||
}
|
||||
|
||||
event!(Level::INFO, "new_msg {}", message.to_string().cyan());
|
||||
println!("new_msg {}", message.to_string().cyan());
|
||||
// 就在这里处理掉最基本的消息
|
||||
// 之后的处理交给插件
|
||||
if !message.is_from_self() && !message.is_reply() {
|
||||
|
@ -105,6 +107,10 @@ pub async fn add_message(payload: Payload, client: Client) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if message.content() == "/bot-fetch" {
|
||||
let reply = message.reply_with("正在更新当前群消息");
|
||||
send_message(&client, &reply).await;
|
||||
fetch_messages(&client, message.room_id).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +175,20 @@ pub async fn failed_message(payload: Payload, _client: Client) {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn fetch_history(client: Client, room: RoomId) {
|
||||
let mut request_body = json!(room);
|
||||
}
|
||||
|
||||
pub async fn fetch_messages(client: &Client, room: RoomId) {
|
||||
let mut request_body = json!(room);
|
||||
match client.emit("fetchMessages", request_body).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
event!(Level::WARN, "fetch_messages {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 所有
|
||||
pub async fn any_event(event: Event, payload: Payload, _client: Client) {
|
||||
let handled = vec![
|
||||
|
@ -189,6 +209,7 @@ pub async fn any_event(event: Event, payload: Payload, _client: Client) {
|
|||
"handleRequest", // 处理验证消息 (加入请求之类的)
|
||||
// 忽略的
|
||||
"notify",
|
||||
"setShutUp", // 禁言
|
||||
"syncRead", // 同步已读
|
||||
"closeLoading", // 发送消息/加载新聊天 有一个 loading
|
||||
"renewMessage", // 我也不确定到底是啥事件
|
||||
|
|
|
@ -165,11 +165,10 @@ impl PluginConfigFile {
|
|||
pub fn write_to_default(&self) -> Result<(), std::io::Error> {
|
||||
let config_path = MainStatus::global_config().py().config_path.clone();
|
||||
let config_path = Path::new(&config_path);
|
||||
let path = config_path.join(CONFIG_FILE_NAME);
|
||||
self.write_to_file(&path)
|
||||
self.write_to_file(&config_path)
|
||||
}
|
||||
|
||||
pub fn write_to_file(&self, path: &PathBuf) -> Result<(), std::io::Error> {
|
||||
pub fn write_to_file(&self, path: &Path) -> Result<(), std::io::Error> {
|
||||
let config_path = path.join(CONFIG_FILE_NAME);
|
||||
std::fs::write(config_path, self.data.to_string())?;
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue
Block a user