socket-bot/ica-rs/src/tailchat/client.rs

23 lines
709 B
Rust
Raw Normal View History

2024-06-04 23:48:01 +08:00
use crate::data_struct::tailchat::messages::SendingMessage;
// use crate::data_struct::tailchat::{ConverseId, GroupId, MessageId, UserId};
2024-03-30 18:30:43 +08:00
2024-06-04 23:48:01 +08:00
use rust_socketio::asynchronous::Client;
use colored::Colorize;
use serde_json::Value;
use tracing::{debug, info, span, warn, Level};
pub async fn send_message(client: &Client, message: &SendingMessage) -> bool {
let value: Value = message.as_value();
match client.emit("chat.message.sendMessage", value).await {
Ok(_) => {
debug!("send_message {}", format!("{:#?}", message).cyan());
true
}
Err(e) => {
warn!("send_message faild:{}", format!("{:#?}", e).red());
false
}
}
}