1// Copyright (c) 2023 xmpp-rs contributors.
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7use tokio_xmpp::{
8 jid::Jid,
9 parsers::message::{Body, Message, MessageType},
10};
11
12use crate::Agent;
13
14pub async fn send_message(
15 agent: &mut Agent,
16 recipient: Jid,
17 type_: MessageType,
18 lang: &str,
19 text: &str,
20) {
21 let mut message = Message::new(Some(recipient));
22 message.type_ = type_;
23 message
24 .bodies
25 .insert(String::from(lang), Body(String::from(text)));
26 let _ = agent.client.send_stanza(message.into()).await;
27}