mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-02-23 07:19:59 +08:00
呐呐呐
This commit is contained in:
parent
3ed1c3e738
commit
0275863cfe
|
@ -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::{Number, Value as JsonValue};
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
/// export default interface Room {
|
/// export default interface Room {
|
||||||
/// roomId: number
|
/// roomId: number
|
||||||
|
@ -39,14 +39,16 @@ 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 mut parse_json = raw_json.clone();
|
let 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 了
|
||||||
|
|
||||||
let inner = match serde_json::from_value::<InnerRoom>(parse_json) {
|
let inner = match serde_json::from_value::<InnerRoom>(parse_json) {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub async fn send_room_sign_in(client: &Client, room_id: RoomId) -> bool {
|
||||||
|
|
||||||
/// 向某个群/私聊的某个人发送戳一戳
|
/// 向某个群/私聊的某个人发送戳一戳
|
||||||
pub async fn send_poke(client: &Client, room_id: RoomId, target: UserId) -> bool {
|
pub async fn send_poke(client: &Client, room_id: RoomId, target: UserId) -> bool {
|
||||||
let data = json!([room_id, target]);
|
let data = vec![json!(room_id), json!(target)];
|
||||||
match client.emit("sendGroupPoke", data).await {
|
match client.emit("sendGroupPoke", data).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
event!(Level::INFO, "已向 {} 的 {} 发送戳一戳", room_id, target);
|
event!(Level::INFO, "已向 {} 的 {} 发送戳一戳", room_id, target);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user