mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-02-22 14:59:55 +08:00
加个 abi3-py38
This commit is contained in:
parent
6638a1f645
commit
62a0a8d3fa
|
@ -42,7 +42,7 @@ colored = "3.0"
|
|||
# runtime
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
futures-util = "0.3.30"
|
||||
pyo3 = { version = "0.23", features = ["experimental-async", "py-clone"] }
|
||||
pyo3 = { version = "0.23", features = ["experimental-async", "py-clone", "abi3-py38"] }
|
||||
anyhow = { version = "1.0", features = ["backtrace"] }
|
||||
# async 这玩意以后在搞
|
||||
# pyo3-async = "0.3.2"
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::data_struct::ica::messages::{At, LastMessage};
|
|||
use crate::data_struct::ica::RoomId;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
use serde_json::{Number, Value as JsonValue};
|
||||
|
||||
/// export default interface Room {
|
||||
/// roomId: number
|
||||
|
@ -39,14 +39,14 @@ pub struct Room {
|
|||
|
||||
impl Room {
|
||||
pub fn new_from_json(raw_json: &JsonValue) -> Self {
|
||||
let parse_json = raw_json.clone();
|
||||
let mut parse_json = raw_json.clone();
|
||||
// 手动 patch 一下 roomId
|
||||
// ica issue: https://github.com/Icalingua-plus-plus/Icalingua-plus-plus/issues/793
|
||||
// if parse_json.get("roomId").is_none_or(|id| id.is_null()) {
|
||||
// use tracing::warn;
|
||||
// warn!("Room::new_from_json roomId is None, patching it to -1, raw: {:#?}", raw_json);
|
||||
// parse_json["roomId"] = JsonValue::Number(Number::from(-1));
|
||||
// }
|
||||
if parse_json.get("roomId").is_none_or(|id| id.is_null()) {
|
||||
use tracing::warn;
|
||||
warn!("Room::new_from_json roomId is None, patching it to -1, raw: {:?}", raw_json);
|
||||
parse_json["roomId"] = JsonValue::Number(Number::from(-1));
|
||||
}
|
||||
// 现在 fix 了
|
||||
|
||||
let inner = match serde_json::from_value::<InnerRoom>(parse_json) {
|
||||
|
|
|
@ -146,6 +146,10 @@ impl SendMessagePy {
|
|||
pub fn get_content(&self) -> String { self.msg.content.clone() }
|
||||
#[setter]
|
||||
pub fn set_content(&mut self, content: String) { self.msg.content = content; }
|
||||
#[getter]
|
||||
pub fn get_room_id(&self) -> RoomId { self.msg.room_id }
|
||||
#[setter]
|
||||
pub fn set_room_id(&mut self, room_id: RoomId) { self.msg.room_id = room_id; }
|
||||
/// 设置消息图片
|
||||
pub fn set_img(&mut self, file: Vec<u8>, file_type: String, as_sticker: bool) {
|
||||
self.msg.set_img(&file, &file_type, as_sticker);
|
||||
|
|
Loading…
Reference in New Issue
Block a user