From 5bbb55418607a017bd5795b9dc4c0f75f915ab02 Mon Sep 17 00:00:00 2001 From: Darren VanBuren Date: Mon, 25 Jul 2016 17:56:11 -0700 Subject: [PATCH] Very basic test for IRC library, include hyper for HTTP --- .gitignore | 2 ++ Cargo.toml | 1 + src/main.rs | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index ea28ef0..c93d818 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ # Generated by Cargo /target/ +# Config file +config.json diff --git a/Cargo.toml b/Cargo.toml index 0bbf187..1305dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,4 @@ authors = ["Darren VanBuren "] [dependencies] irc = "0.11.0" +hyper = "0.9" diff --git a/src/main.rs b/src/main.rs index e7a11a9..89df6d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,20 @@ +extern crate irc; + +use irc::client::prelude::*; + fn main() { println!("Hello, world!"); + + let server = IrcServer::new("config.json").unwrap(); + server.identify().unwrap(); + for message in server.iter() { + let message = message.unwrap(); + println!("Received message: {}", message); + match message.command { + Command::PRIVMSG(ref target, ref msg) => if msg.contains("rust-bot") { + server.send_privmsg(target, "Hello!").unwrap(); + }, + _ => (), + } + } }