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::connect::ServerConnector;
8use tokio_xmpp::{
9 jid::Jid,
10 parsers::message::{Body, Message, MessageType},
11};
12
13use crate::Agent;
14
15pub async fn send_message<C: ServerConnector>(
16 agent: &mut Agent<C>,
17 recipient: Jid,
18 type_: MessageType,
19 lang: &str,
20 text: &str,
21) {
22 let mut message = Message::new(Some(recipient));
23 message.type_ = type_;
24 message
25 .bodies
26 .insert(String::from(lang), Body(String::from(text)));
27 let _ = agent.client.send_stanza(message.into()).await;
28}