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