Move send_message to message::send module
This commit is contained in:
parent
12e5299abf
commit
f6c47dd394
3 changed files with 30 additions and 10 deletions
|
|
@ -5,3 +5,4 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
pub mod receive;
|
||||
pub mod send;
|
||||
|
|
|
|||
27
xmpp/src/message/send.rs
Normal file
27
xmpp/src/message/send.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2023 xmpp-rs contributors.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use tokio_xmpp::{
|
||||
parsers::message::{Body, Message, MessageType},
|
||||
Jid,
|
||||
};
|
||||
|
||||
use crate::Agent;
|
||||
|
||||
pub async fn send_message(
|
||||
agent: &mut Agent,
|
||||
recipient: Jid,
|
||||
type_: MessageType,
|
||||
lang: &str,
|
||||
text: &str,
|
||||
) {
|
||||
let mut message = Message::new(Some(recipient));
|
||||
message.type_ = type_;
|
||||
message
|
||||
.bodies
|
||||
.insert(String::from(lang), Body(String::from(text)));
|
||||
let _ = agent.client.send_stanza(message.into()).await;
|
||||
}
|
||||
Loading…
Reference in a new issue