mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-04-19 14:39:54 +08:00
update to edition 2024
This commit is contained in:
parent
e10dff96d2
commit
12d6254c6b
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "ica-rs"
|
||||
version = "0.9.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::data_struct::ica::{MessageId, RoomId, UserId};
|
|||
|
||||
use chrono::DateTime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value as JsonValue};
|
||||
use serde_json::{Value as JsonValue, json};
|
||||
use tracing::warn;
|
||||
|
||||
pub mod msg_trait;
|
||||
|
@ -331,7 +331,7 @@ impl SendMessage {
|
|||
/// file_type: 图片类型(MIME) (image/png; image/jpeg)
|
||||
pub fn set_img(&mut self, file: &Vec<u8>, file_type: &str, as_sticker: bool) {
|
||||
self.sticker = as_sticker;
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
let base64_data = general_purpose::STANDARD.encode(file);
|
||||
self.file_data = Some(format!("data:{};base64,{}", file_type, base64_data));
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use chrono::DateTime;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
use crate::MainStatus;
|
||||
use crate::data_struct::ica::messages::{At, Message, NewMessage};
|
||||
use crate::data_struct::ica::{MessageId, UserId};
|
||||
use crate::MainStatus;
|
||||
|
||||
impl Serialize for At {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value as JsonValue};
|
||||
use serde_json::{Value as JsonValue, json};
|
||||
|
||||
use crate::data_struct::tailchat::{ConverseId, GroupId, MessageId, UserId};
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ pub mod events;
|
|||
|
||||
use colored::Colorize;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::{async_any_callback, async_callback};
|
||||
use rust_socketio::{Event, Payload, TransportType};
|
||||
use tracing::{event, span, Level};
|
||||
use rust_socketio::{async_any_callback, async_callback};
|
||||
use tracing::{Level, event, span};
|
||||
|
||||
use crate::config::IcaConfig;
|
||||
use crate::error::{ClientResult, IcaError};
|
||||
use crate::{version_str, StopGetter};
|
||||
use crate::{StopGetter, version_str};
|
||||
|
||||
/// icalingua 客户端的兼容版本号
|
||||
pub const ICA_PROTOCOL_VERSION: &str = "2.12.28";
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use crate::MainStatus;
|
||||
use crate::data_struct::ica::messages::{DeleteMessage, SendMessage};
|
||||
use crate::data_struct::ica::{RoomId, RoomIdTrait, UserId};
|
||||
use crate::error::{ClientResult, IcaError};
|
||||
use crate::MainStatus;
|
||||
|
||||
use colored::Colorize;
|
||||
use ed25519_dalek::{Signature, Signer, SigningKey};
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use rust_socketio::Payload;
|
||||
use serde_json::{json, Value};
|
||||
use tracing::{debug, event, span, warn, Level};
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use serde_json::{Value, json};
|
||||
use tracing::{Level, debug, event, span, warn};
|
||||
|
||||
/// "安全" 的 发送一条消息
|
||||
pub async fn send_message(client: &Client, message: &SendMessage) -> bool {
|
||||
|
|
|
@ -2,14 +2,14 @@ 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 tracing::{Level, event, info, span, warn};
|
||||
|
||||
use crate::data_struct::ica::RoomId;
|
||||
use crate::data_struct::ica::all_rooms::{JoinRequestRoom, 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};
|
||||
use crate::{MainStatus, VERSION, client_id, help_msg, py, version_str};
|
||||
|
||||
/// 获取在线数据
|
||||
pub async fn get_online_data(payload: Payload, _client: Client) {
|
||||
|
|
|
@ -19,7 +19,7 @@ mod tailchat;
|
|||
use colored::Colorize;
|
||||
use config::BotConfig;
|
||||
use error::PyPluginError;
|
||||
use tracing::{event, span, Level};
|
||||
use tracing::{Level, event, span};
|
||||
|
||||
pub static mut MAIN_STATUS: status::BotStatus = status::BotStatus {
|
||||
config: None,
|
||||
|
@ -233,8 +233,8 @@ async fn test_macro() {
|
|||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::Payload;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
|
||||
/// 一个简单的例子
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -4,13 +4,13 @@ use std::sync::LazyLock;
|
|||
use pyo3::prelude::*;
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{event, info, warn, Level};
|
||||
use tracing::{Level, event, info, warn};
|
||||
|
||||
use crate::MainStatus;
|
||||
use crate::data_struct::{ica, tailchat};
|
||||
use crate::error::PyPluginError;
|
||||
use crate::py::consts::events_func;
|
||||
use crate::py::{class, PyPlugin, PyStatus};
|
||||
use crate::MainStatus;
|
||||
use crate::py::{PyPlugin, PyStatus, class};
|
||||
|
||||
pub struct PyTasks {
|
||||
pub ica_new_message: Vec<tokio::task::JoinHandle<()>>,
|
||||
|
|
|
@ -4,12 +4,11 @@ pub mod schdule;
|
|||
pub mod tailchat;
|
||||
|
||||
use pyo3::{
|
||||
pyclass, pymethods, pymodule,
|
||||
Bound, IntoPyObject, PyAny, PyRef, PyResult, pyclass, pymethods, pymodule,
|
||||
types::{PyBool, PyModule, PyModuleMethods, PyString},
|
||||
Bound, IntoPyObject, PyAny, PyRef, PyResult,
|
||||
};
|
||||
use toml::Value as TomlValue;
|
||||
use tracing::{event, Level};
|
||||
use tracing::{Level, event};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[pyclass]
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use pyo3::{
|
||||
pyclass, pymethods,
|
||||
Bound, PyAny, PyResult, pyclass, pymethods,
|
||||
types::{
|
||||
PyAnyMethods, PyBool, PyBoolMethods, PyDict, PyDictMethods, PyFloat, PyInt, PyList,
|
||||
PyListMethods, PyString, PyStringMethods, PyTypeMethods,
|
||||
},
|
||||
Bound, PyAny, PyResult,
|
||||
};
|
||||
use tracing::{event, Level};
|
||||
use tracing::{Level, event};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ConfigItem {
|
||||
|
|
|
@ -3,15 +3,15 @@ use std::time::SystemTime;
|
|||
use pyo3::{pyclass, pymethods};
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use tokio::runtime::Runtime;
|
||||
use tracing::{event, Level};
|
||||
use tracing::{Level, event};
|
||||
|
||||
use crate::MainStatus;
|
||||
use crate::data_struct::ica::messages::{
|
||||
DeleteMessage, MessageTrait, NewMessage, ReplyMessage, SendMessage,
|
||||
};
|
||||
use crate::data_struct::ica::{MessageId, RoomId, RoomIdTrait, UserId};
|
||||
use crate::ica::client::{delete_message, send_message, send_poke, send_room_sign_in};
|
||||
use crate::py::PyStatus;
|
||||
use crate::MainStatus;
|
||||
|
||||
#[pyclass]
|
||||
#[pyo3(name = "IcaStatus")]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use pyo3::{pyclass, pymethods, types::PyFunction, Bound, Py, PyAny, PyTraverseError, PyVisit};
|
||||
use tracing::{event, Level};
|
||||
use pyo3::{Bound, Py, PyAny, PyTraverseError, PyVisit, pyclass, pymethods, types::PyFunction};
|
||||
use tracing::{Level, event};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[pyclass]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::{path::Path, str::FromStr};
|
||||
|
||||
use colored::Colorize;
|
||||
use toml_edit::{value, DocumentMut, Key, Table, TomlError, Value};
|
||||
use tracing::{event, Level};
|
||||
use toml_edit::{DocumentMut, Key, Table, TomlError, Value, value};
|
||||
use tracing::{Level, event};
|
||||
|
||||
use crate::py::PyStatus;
|
||||
use crate::MainStatus;
|
||||
use crate::py::PyStatus;
|
||||
|
||||
/// ```toml
|
||||
/// # 这个文件是由 shenbot 自动生成的, 请 **谨慎** 修改
|
||||
|
|
|
@ -12,15 +12,15 @@ use std::{collections::HashMap, path::PathBuf};
|
|||
|
||||
use colored::Colorize;
|
||||
use pyo3::{
|
||||
Bound, Py, PyErr, PyResult, Python,
|
||||
exceptions::PyTypeError,
|
||||
intern,
|
||||
types::{PyAnyMethods, PyModule, PyTracebackMethods, PyTuple},
|
||||
Bound, Py, PyErr, PyResult, Python,
|
||||
};
|
||||
use tracing::{event, span, warn, Level};
|
||||
use tracing::{Level, event, span, warn};
|
||||
|
||||
use crate::error::PyPluginError;
|
||||
use crate::MainStatus;
|
||||
use crate::error::PyPluginError;
|
||||
|
||||
use consts::config_func;
|
||||
|
||||
|
@ -36,6 +36,7 @@ pub type RawPyPlugin = (PathBuf, Option<SystemTime>, String);
|
|||
#[allow(non_upper_case_globals)]
|
||||
static mut PyPluginStatus: OnceLock<PyStatus> = OnceLock::new();
|
||||
|
||||
#[allow(static_mut_refs)]
|
||||
impl PyStatus {
|
||||
pub fn init() {
|
||||
let config =
|
||||
|
@ -394,9 +395,7 @@ impl TryFrom<RawPyPlugin> for PyPlugin {
|
|||
"加载 Python 插件 {:?} 的配置文件信息时失败:返回的不是 [str, str]",
|
||||
path
|
||||
);
|
||||
Err(PyTypeError::new_err(
|
||||
"返回的不是 [str, str]".to_string(),
|
||||
))
|
||||
Err(PyTypeError::new_err("返回的不是 [str, str]".to_string()))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::config::BotConfig;
|
||||
use crate::MAIN_STATUS;
|
||||
use crate::config::BotConfig;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BotStatus {
|
||||
|
|
|
@ -9,13 +9,13 @@ use reqwest::ClientBuilder as reqwest_ClientBuilder;
|
|||
use rust_socketio::async_callback;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::{Event, Payload, TransportType};
|
||||
use serde_json::{json, Value};
|
||||
use tracing::{event, span, Level};
|
||||
use serde_json::{Value, json};
|
||||
use tracing::{Level, event, span};
|
||||
|
||||
use crate::config::TailchatConfig;
|
||||
use crate::data_struct::tailchat::status::{BotStatus, LoginData};
|
||||
use crate::error::{ClientResult, TailchatError};
|
||||
use crate::{async_any_callback_with_state, async_callback_with_state, version_str, StopGetter};
|
||||
use crate::{StopGetter, async_any_callback_with_state, async_callback_with_state, version_str};
|
||||
|
||||
pub async fn start_tailchat(
|
||||
config: TailchatConfig,
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::data_struct::tailchat::messages::SendingMessage;
|
|||
use colored::Colorize;
|
||||
use reqwest::multipart;
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use serde_json::{json, Value};
|
||||
use tracing::{event, span, Level};
|
||||
use serde_json::{Value, json};
|
||||
use tracing::{Level, event, span};
|
||||
|
||||
pub async fn send_message(client: &Client, message: &SendingMessage) -> bool {
|
||||
let span = span!(Level::INFO, "tailchat send message");
|
||||
|
|
|
@ -3,14 +3,14 @@ use std::sync::Arc;
|
|||
use colored::Colorize;
|
||||
use rust_socketio::asynchronous::Client;
|
||||
use rust_socketio::{Event, Payload};
|
||||
use tracing::{event, info, Level};
|
||||
use tracing::{Level, event, info};
|
||||
|
||||
use crate::data_struct::tailchat::messages::ReceiveMessage;
|
||||
use crate::data_struct::tailchat::status::{BotStatus, UpdateDMConverse};
|
||||
use crate::py::call::tailchat_new_message_py;
|
||||
use crate::py::PyStatus;
|
||||
use crate::py::call::tailchat_new_message_py;
|
||||
use crate::tailchat::client::{emit_join_room, send_message};
|
||||
use crate::{client_id, help_msg, version_str, MainStatus, VERSION};
|
||||
use crate::{MainStatus, VERSION, client_id, help_msg, version_str};
|
||||
|
||||
/// 所有
|
||||
pub async fn any_event(event: Event, payload: Payload, _client: Client, _status: Arc<BotStatus>) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user