2017-02-18 23:01:51 +00:00
|
|
|
extern crate xmpp;
|
|
|
|
|
|
|
|
use xmpp::jid::Jid;
|
|
|
|
use xmpp::client::ClientBuilder;
|
2017-05-27 15:25:31 +00:00
|
|
|
use xmpp::plugins::stanza::StanzaPlugin;
|
2017-05-27 19:43:34 +00:00
|
|
|
use xmpp::plugins::unhandled_iq::UnhandledIqPlugin;
|
2017-02-20 15:28:51 +00:00
|
|
|
use xmpp::plugins::messaging::{MessagingPlugin, MessageEvent};
|
2017-05-27 15:37:21 +00:00
|
|
|
use xmpp::plugins::presence::{PresencePlugin, Type};
|
2017-05-27 17:06:48 +00:00
|
|
|
use xmpp::plugins::disco::DiscoPlugin;
|
2017-05-27 19:03:59 +00:00
|
|
|
use xmpp::plugins::ibb::IbbPlugin;
|
2017-05-27 21:12:32 +00:00
|
|
|
use xmpp::plugins::ping::PingPlugin;
|
2017-05-27 16:01:01 +00:00
|
|
|
use xmpp::event::{Priority, Propagation};
|
2017-02-18 23:01:51 +00:00
|
|
|
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let jid: Jid = env::var("JID").unwrap().parse().unwrap();
|
2017-02-25 05:49:13 +00:00
|
|
|
let pass = env::var("PASS").unwrap();
|
|
|
|
let mut client = ClientBuilder::new(jid.clone())
|
|
|
|
.password(pass)
|
|
|
|
.connect()
|
|
|
|
.unwrap();
|
2017-05-27 15:25:31 +00:00
|
|
|
client.register_plugin(StanzaPlugin::new());
|
2017-05-27 19:43:34 +00:00
|
|
|
client.register_plugin(UnhandledIqPlugin::new());
|
2017-02-20 15:28:51 +00:00
|
|
|
client.register_plugin(MessagingPlugin::new());
|
|
|
|
client.register_plugin(PresencePlugin::new());
|
2017-05-27 17:06:48 +00:00
|
|
|
client.register_plugin(DiscoPlugin::new("client", "bot", "en", "xmpp-rs"));
|
2017-05-27 19:03:59 +00:00
|
|
|
client.register_plugin(IbbPlugin::new());
|
2017-03-31 15:25:52 +00:00
|
|
|
client.register_plugin(PingPlugin::new());
|
2017-05-27 19:53:13 +00:00
|
|
|
client.plugin::<PingPlugin>().init();
|
2017-05-27 21:38:35 +00:00
|
|
|
client.plugin::<IbbPlugin>().init();
|
2017-05-27 16:01:01 +00:00
|
|
|
client.register_handler(Priority::Max, |e: &MessageEvent| {
|
|
|
|
println!("{:?}", e);
|
|
|
|
Propagation::Continue
|
|
|
|
});
|
2017-05-27 15:37:21 +00:00
|
|
|
client.plugin::<PresencePlugin>().set_presence(Type::Available, None, None).unwrap();
|
2017-05-09 22:13:54 +00:00
|
|
|
client.main().unwrap();
|
2017-02-18 23:01:51 +00:00
|
|
|
}
|