blob: e9965d8f20ae8d6083f52e161fc37aad491c94c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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();
}
_ => ()
}
}
}
|