From fc27f8cee888acf70683badca9edadb45544822c Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Tue, 21 Oct 2014 15:33:17 +0200 Subject: Initial commit. --- src/main.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e9965d8 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,34 @@ +#![feature(globs, slicing_syntax)] + +extern crate irsc; + +use irsc::server::Server; +use irsc::events::*; +use irsc::color::bold; + +static NAME: &'static str = "rusticbot"; +static DESC: &'static str = "A bot, written in Rust."; + +fn main() { + let mut s = Server::new("irc.freenode.org".into_string(), 6667); + let events = s.events(); + s.connect().unwrap(); + s.nick(NAME).unwrap(); + s.user(NAME, "*", "*", DESC).unwrap(); + s.join("#botzoo").unwrap(); + + s.msg("flan3002", "Hey!").unwrap(); + + for e in events.iter() { + match e { + RplWelcome(welcome) => { + println!("{}", welcome) + }, + PrivMsg(from, _to, msg) => { + let response = format!("You wrote: {}", bold(msg[])); + s.msg(from.nickname[], response[]).unwrap(); + } + _ => () + } + } +} -- cgit v1.2.3