mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 04:31:05 +08:00
更新日志:准备接入Matrix,去掉pyo3-async的依赖,启用ica,更新版本号为0.5.0
This commit is contained in:
parent
51cc24e347
commit
48d4c8fd5d
45
.github/workflows/publish.yml
vendored
Normal file
45
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
name: publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
publish: # 全都要!
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
# python-version: ["3.8", "3.9", "3.10", "3.11",]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: 获取版本号
|
||||
id: get_version
|
||||
uses: sravinet/toml-select@v1.0.1
|
||||
with:
|
||||
file: ./ica-rs/Cargo.toml
|
||||
field: "package.version"
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5.0.0
|
||||
with:
|
||||
# Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset.
|
||||
python-version: 3.8
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: 上传
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ica-rs-b${{ github.run_number }}-${{ steps.get_version.outputs.value }}-py38-win-x64
|
||||
path: ./target/release/ica-rs.exe
|
93
Cargo.lock
generated
93
Cargo.lock
generated
|
@ -57,7 +57,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -68,7 +68,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -256,7 +256,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -385,21 +385,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.30"
|
||||
|
@ -407,7 +392,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -416,17 +400,6 @@ version = "0.3.30"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.30"
|
||||
|
@ -441,7 +414,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -462,7 +435,6 @@ version = "0.3.30"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
|
@ -640,7 +612,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ica-rs"
|
||||
version = "0.4.12"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"colored",
|
||||
|
@ -649,7 +621,6 @@ dependencies = [
|
|||
"futures-util",
|
||||
"hex",
|
||||
"pyo3",
|
||||
"pyo3-asyncio",
|
||||
"rust_socketio",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -881,7 +852,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1016,31 +987,6 @@ dependencies = [
|
|||
"unindent",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-asyncio"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea6b68e93db3622f3bb3bf363246cf948ed5375afe7abff98ccbdd50b184995"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"pyo3",
|
||||
"pyo3-asyncio-macros",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-asyncio-macros"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56c467178e1da6252c95c29ecf898b133f742e9181dca5def15dc24e19d45a39"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-build-config"
|
||||
version = "0.20.3"
|
||||
|
@ -1070,7 +1016,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"pyo3-macros-backend",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1083,7 +1029,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"pyo3-build-config",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1325,7 +1271,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1450,17 +1396,6 @@ version = "2.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.50"
|
||||
|
@ -1534,7 +1469,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1620,7 +1555,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1720,7 +1655,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1889,7 +1824,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
@ -1923,7 +1858,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.50",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
py_plugin_path = "/path/to/your/plugin"
|
||||
py_config_path = "/path/to/your/config"
|
||||
|
||||
enable_ica = true # 是否启用 ica
|
||||
|
||||
[ica]
|
||||
enable = true
|
||||
|
||||
private_key = "" # 与 icalingua 客户端使用的 private_key 一致
|
||||
host = "" # docker 版 icalingua 服务的地址
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ica-rs"
|
||||
version = "0.4.12"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -21,7 +21,7 @@ tokio = { version = "1.0", features = ["full"] }
|
|||
futures-util = "0.3.30"
|
||||
pyo3 = "0.20.3"
|
||||
# pyo3-async = "0.3.2"
|
||||
pyo3-asyncio = { version = "0.20.0", features = ["attributes", "tokio-runtime"] }
|
||||
# pyo3-asyncio = { version = "0.20.0", features = ["attributes", "tokio-runtime"] }
|
||||
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["time"] }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::config::{BotConfig, IcaConfig};
|
||||
use crate::data_struct::all_rooms::Room;
|
||||
use crate::data_struct::messages::{DeleteMessage, SendMessage};
|
||||
use crate::data_struct::online_data::OnlineData;
|
||||
use crate::ica::data_struct::all_rooms::Room;
|
||||
use crate::ica::data_struct::messages::{DeleteMessage, SendMessage};
|
||||
use crate::ica::data_struct::online_data::OnlineData;
|
||||
use crate::ClientStatus_Global;
|
||||
|
||||
use colored::Colorize;
|
||||
|
|
|
@ -7,8 +7,6 @@ use toml::from_str;
|
|||
/// Icalingua bot 的配置
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct IcaConfig {
|
||||
/// 是否启用 icalingua
|
||||
pub enable: bool,
|
||||
/// icalingua 私钥
|
||||
pub private_key: String,
|
||||
/// icalingua 服务器地址
|
||||
|
@ -28,6 +26,8 @@ pub struct IcaConfig {
|
|||
/// 主配置
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct BotConfig {
|
||||
/// 是否启用 icalingua
|
||||
pub enable_ica: bool,
|
||||
/// Ica 配置
|
||||
pub ica: Option<IcaConfig>,
|
||||
/// Matrix 配置
|
||||
|
|
52
ica-rs/src/ica.rs
Normal file
52
ica-rs/src/ica.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
pub mod data_struct;
|
||||
pub mod events;
|
||||
|
||||
use futures_util::FutureExt;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::{Event, Payload, TransportType};
|
||||
use tracing::info;
|
||||
|
||||
use crate::config::IcaConfig;
|
||||
use crate::{wrap_any_callback, wrap_callback};
|
||||
|
||||
pub async fn start_ica(config: &IcaConfig, stop_reciver: tokio::sync::oneshot::Receiver<()>) {
|
||||
let socket = ClientBuilder::new(config.host.clone())
|
||||
.transport_type(TransportType::Websocket)
|
||||
.on_any(wrap_any_callback!(events::any_event))
|
||||
.on("requireAuth", wrap_callback!(crate::client::sign_callback))
|
||||
.on("message", wrap_callback!(events::connect_callback))
|
||||
.on("authSucceed", wrap_callback!(events::connect_callback))
|
||||
.on("authFailed", wrap_callback!(events::connect_callback))
|
||||
.on("messageSuccess", wrap_callback!(events::succes_message))
|
||||
.on("messageFailed", wrap_callback!(events::failed_message))
|
||||
.on("onlineData", wrap_callback!(events::get_online_data))
|
||||
.on("setAllRooms", wrap_callback!(events::update_all_room))
|
||||
.on("setMessages", wrap_callback!(events::set_messages))
|
||||
.on("addMessage", wrap_callback!(events::add_message))
|
||||
.on("deleteMessage", wrap_callback!(events::delete_message))
|
||||
.connect()
|
||||
.await
|
||||
.expect("Connection failed");
|
||||
|
||||
info!("Connected");
|
||||
|
||||
if config.notice_start {
|
||||
for room in config.notice_room.iter() {
|
||||
let startup_msg = data_struct::messages::SendMessage::new(
|
||||
format!("ica-async-rs bot v{}", crate::VERSION),
|
||||
room.clone(),
|
||||
None,
|
||||
);
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
info!("发送启动消息到房间: {}", room);
|
||||
if let Err(e) =
|
||||
socket.emit("sendMessage", serde_json::to_value(startup_msg).unwrap()).await
|
||||
{
|
||||
info!("启动信息发送失败 房间:{}|e:{}", room, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 等待停止信号
|
||||
stop_reciver.await.ok();
|
||||
socket.disconnect().await.expect("Disconnect failed");
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
use crate::data_struct::messages::{At, LastMessage};
|
||||
use crate::data_struct::RoomId;
|
||||
use crate::ica::data_struct::messages::{At, LastMessage};
|
||||
use crate::ica::data_struct::RoomId;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
|
@ -1,5 +1,5 @@
|
|||
use crate::data_struct::files::MessageFile;
|
||||
use crate::data_struct::{MessageId, RoomId, UserId};
|
||||
use crate::ica::data_struct::files::MessageFile;
|
||||
use crate::ica::data_struct::{MessageId, RoomId, UserId};
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use serde::{Deserialize, Serialize};
|
|
@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
|
|||
use serde_json::Value as JsonValue;
|
||||
|
||||
use crate::client::BotStatus;
|
||||
use crate::data_struct::messages::{At, Message, NewMessage};
|
||||
use crate::data_struct::{MessageId, UserId};
|
||||
use crate::ica::data_struct::messages::{At, Message, NewMessage};
|
||||
use crate::ica::data_struct::{MessageId, UserId};
|
||||
|
||||
impl Serialize for At {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
@ -4,9 +4,9 @@ use rust_socketio::{Event, Payload};
|
|||
use tracing::{info, warn};
|
||||
|
||||
use crate::client::{send_message, BotStatus};
|
||||
use crate::data_struct::all_rooms::Room;
|
||||
use crate::data_struct::messages::{Message, MessageTrait, NewMessage};
|
||||
use crate::data_struct::online_data::OnlineData;
|
||||
use crate::ica::data_struct::all_rooms::Room;
|
||||
use crate::ica::data_struct::messages::{Message, MessageTrait, NewMessage};
|
||||
use crate::ica::data_struct::online_data::OnlineData;
|
||||
use crate::{py, VERSION};
|
||||
|
||||
/// 获取在线数据
|
|
@ -1,15 +1,11 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use config::{BotConfig, IcaConfig};
|
||||
use futures_util::FutureExt;
|
||||
use rust_socketio::asynchronous::{Client, ClientBuilder};
|
||||
use rust_socketio::{Event, Payload, TransportType};
|
||||
use tracing::info;
|
||||
|
||||
mod client;
|
||||
mod config;
|
||||
mod data_struct;
|
||||
mod events;
|
||||
mod ica;
|
||||
mod matrix;
|
||||
mod py;
|
||||
|
||||
|
@ -24,60 +20,19 @@ pub static mut ClientStatus_Global: client::BotStatus = client::BotStatus {
|
|||
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! wrap_callback {
|
||||
($f:expr) => {
|
||||
|payload: Payload, client: Client| $f(payload, client).boxed()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! wrap_any_callback {
|
||||
($f:expr) => {
|
||||
|event: Event, payload: Payload, client: Client| $f(event, payload, client).boxed()
|
||||
};
|
||||
}
|
||||
|
||||
async fn start_ica(config: &IcaConfig, stop_reciver: tokio::sync::oneshot::Receiver<()>) {
|
||||
let socket = ClientBuilder::new(config.host.clone())
|
||||
.transport_type(TransportType::Websocket)
|
||||
.on_any(wrap_any_callback!(events::any_event))
|
||||
.on("requireAuth", wrap_callback!(client::sign_callback))
|
||||
.on("message", wrap_callback!(events::connect_callback))
|
||||
.on("authSucceed", wrap_callback!(events::connect_callback))
|
||||
.on("authFailed", wrap_callback!(events::connect_callback))
|
||||
.on("messageSuccess", wrap_callback!(events::succes_message))
|
||||
.on("messageFailed", wrap_callback!(events::failed_message))
|
||||
.on("onlineData", wrap_callback!(events::get_online_data))
|
||||
.on("setAllRooms", wrap_callback!(events::update_all_room))
|
||||
.on("setMessages", wrap_callback!(events::set_messages))
|
||||
.on("addMessage", wrap_callback!(events::add_message))
|
||||
.on("deleteMessage", wrap_callback!(events::delete_message))
|
||||
.connect()
|
||||
.await
|
||||
.expect("Connection failed");
|
||||
|
||||
info!("Connected");
|
||||
|
||||
if config.notice_start {
|
||||
for room in config.notice_room.iter() {
|
||||
let startup_msg = crate::data_struct::messages::SendMessage::new(
|
||||
format!("ica-async-rs bot v{}", VERSION),
|
||||
room.clone(),
|
||||
None,
|
||||
);
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
info!("发送启动消息到房间: {}", room);
|
||||
if let Err(e) =
|
||||
socket.emit("sendMessage", serde_json::to_value(startup_msg).unwrap()).await
|
||||
{
|
||||
info!("启动信息发送失败 房间:{}|e:{}", room, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 等待停止信号
|
||||
stop_reciver.await.ok();
|
||||
socket.disconnect().await.expect("Disconnect failed");
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init();
|
||||
|
@ -91,11 +46,11 @@ async fn main() {
|
|||
|
||||
// 准备一个用于停止 socket 的变量
|
||||
let (send, recv) = tokio::sync::oneshot::channel::<()>();
|
||||
if bot_config.ica.is_some() && bot_config.ica().enable {
|
||||
if bot_config.enable_ica && bot_config.ica.is_some() {
|
||||
info!("启动 ica");
|
||||
let config = bot_config.ica();
|
||||
tokio::spawn(async move {
|
||||
start_ica(&config, recv).await;
|
||||
ica::start_ica(&config, recv).await;
|
||||
});
|
||||
} else {
|
||||
info!("未启用 ica");
|
||||
|
|
|
@ -5,8 +5,8 @@ use rust_socketio::asynchronous::Client;
|
|||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::client::BotStatus;
|
||||
use crate::data_struct::messages::NewMessage;
|
||||
use crate::data_struct::MessageId;
|
||||
use crate::ica::data_struct::messages::NewMessage;
|
||||
use crate::ica::data_struct::MessageId;
|
||||
use crate::py::{class, PyPlugin, PyStatus};
|
||||
|
||||
pub fn get_func<'py>(py_module: &'py PyAny, path: &PathBuf, name: &'py str) -> Option<&'py PyAny> {
|
||||
|
|
|
@ -5,10 +5,10 @@ use toml::Value as TomlValue;
|
|||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::client::{delete_message, send_message, BotStatus};
|
||||
use crate::data_struct::messages::{
|
||||
use crate::ica::data_struct::messages::{
|
||||
DeleteMessage, MessageTrait, NewMessage, ReplyMessage, SendMessage,
|
||||
};
|
||||
use crate::data_struct::MessageId;
|
||||
use crate::ica::data_struct::MessageId;
|
||||
use crate::ClientStatus_Global;
|
||||
|
||||
#[pyclass]
|
||||
|
@ -178,16 +178,16 @@ impl IcaClientPy {
|
|||
/// 仅作占位
|
||||
/// (因为目前来说, rust调用 Python端没法启动一个异步运行时
|
||||
/// 所以只能 tokio::task::block_in_place 转换成同步调用)
|
||||
#[staticmethod]
|
||||
pub fn send_message_a(
|
||||
py: Python,
|
||||
client: IcaClientPy,
|
||||
message: SendMessagePy,
|
||||
) -> PyResult<&PyAny> {
|
||||
pyo3_asyncio::tokio::future_into_py(py, async move {
|
||||
Ok(send_message(&client.client, &message.msg).await)
|
||||
})
|
||||
}
|
||||
// #[staticmethod]
|
||||
// pub fn send_message_a(
|
||||
// py: Python,
|
||||
// client: IcaClientPy,
|
||||
// message: SendMessagePy,
|
||||
// ) -> PyResult<&PyAny> {
|
||||
// pyo3_asyncio::tokio::future_into_py(py, async move {
|
||||
// Ok(send_message(&client.client, &message.msg).await)
|
||||
// })
|
||||
// }
|
||||
|
||||
#[getter]
|
||||
pub fn get_status(&self) -> IcaStatusPy { IcaStatusPy::new() }
|
||||
|
|
Loading…
Reference in New Issue
Block a user