aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTill Hoeppner2014-10-21 15:33:17 +0200
committerTill Hoeppner2014-10-21 16:15:10 +0200
commitfc27f8cee888acf70683badca9edadb45544822c (patch)
treef39314f857e92a1e5a19f9675205750adf8919f0 /src/main.rs
parentce640c2c25b0e16c567553c5774d633c13cbf0ee (diff)
downloadirsc-fc27f8cee888acf70683badca9edadb45544822c.tar.gz
irsc-fc27f8cee888acf70683badca9edadb45544822c.tar.xz
irsc-fc27f8cee888acf70683badca9edadb45544822c.zip
Initial commit.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs34
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();
+ }
+ _ => ()
+ }
+ }
+}