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;
|
2024-06-05 00:09:08 +08:00
|
|
|
use tracing::{debug, warn};
|
2024-06-04 23:48:01 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|