update messaging plugin to support sending messages, still not sure how i'm going to modify the plugin architecture, so stays very unstable for now
This commit is contained in:
parent
142c6f0887
commit
83839f0ba6
1 changed files with 14 additions and 3 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
use plugin::{Plugin, PluginReturn, PluginProxy};
|
use plugin::{Plugin, PluginReturn, PluginProxy};
|
||||||
use event::Event;
|
use event::Event;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
use error::Error;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use ns;
|
use ns;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MessageEvent {
|
pub struct MessageEvent {
|
||||||
from: Jid,
|
pub from: Jid,
|
||||||
to: Jid,
|
pub to: Jid,
|
||||||
body: String,
|
pub body: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event for MessageEvent {}
|
impl Event for MessageEvent {}
|
||||||
|
|
@ -23,6 +24,16 @@ impl MessagingPlugin {
|
||||||
proxy: PluginProxy::new(),
|
proxy: PluginProxy::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn send_message(&self, to: &Jid, body: &str) -> Result<(), Error> {
|
||||||
|
let mut elem = Element::builder("message")
|
||||||
|
.attr("type", "chat")
|
||||||
|
.attr("to", to.to_string())
|
||||||
|
.build();
|
||||||
|
elem.append_child(Element::builder("body").text(body).build());
|
||||||
|
self.proxy.send(elem);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Plugin for MessagingPlugin {
|
impl Plugin for MessagingPlugin {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue