diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 34 |
1 files changed, 34 insertions, 0 deletions
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(); + } + _ => () + } + } +} |