summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 03f9e02..4abd4b6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,9 @@
#![plugin(serde_macros)]
extern crate hyper;
extern crate irc;
+#[macro_use]
+extern crate lazy_static;
+extern crate rand;
extern crate serde;
extern crate serde_json;
@@ -15,6 +18,22 @@ use hyper::header::Connection;
use irc::client::prelude::*;
+use rand::{thread_rng, sample};
+
+lazy_static! {
+ static ref EMOTE_HAPPY: Vec<&'static str> = vec![":D", ":)", "^_^"];
+
+ static ref EMOTES: HashMap<&'static str, &'static [&'static str]> = {
+ let mut m = HashMap::new();
+ m.insert("happy", &(*EMOTE_HAPPY)[..]);
+ m.insert("smile", &(*EMOTE_HAPPY)[..]);
+ m.insert(":)", &(*EMOTE_HAPPY)[..]);
+ m.insert(":D", &(*EMOTE_HAPPY)[..]);
+
+ m
+ };
+}
+
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct WikiPage {
ns: u32,
@@ -66,6 +85,10 @@ fn emote_action(action: &str) -> Option<&str> {
if action == "shrugs" {
Some("¯\\_(ツ)_/¯")
}
+ else if let Some(x) = EMOTES.get(action) {
+ let mut rng = thread_rng();
+ Some(sample(&mut rng, *x, 1)[0])
+ }
else {
None
}