Skip to content

Commit 47b79ac

Browse files
committed
Do nothing with karma changes if they occur in highlights to the bot
1 parent 42b7fd6 commit 47b79ac

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Ruben Nijveld <[email protected]>"]
55

66
[dependencies.dazeus]
7-
version = "0.3"
7+
version = "0.4"
88

99
[dependencies.docopt]
1010
version = "0.6"

src/main.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate rustc_serialize;
77
extern crate chrono;
88

99
use docopt::Docopt;
10-
use dazeus::{DaZeus, EventType, Connection};
10+
use dazeus::{DaZeus, DaZeusClient, EventType, Connection};
1111
use handler::*;
1212

1313
mod karma;
@@ -38,8 +38,21 @@ fn main() {
3838
let connection = Connection::from_str(socket).unwrap();
3939
let mut dazeus = DaZeus::new(connection);
4040

41+
dazeus.handshake("dazeus-karma", "1", None);
42+
4143
dazeus.subscribe(EventType::PrivMsg, |evt, dazeus| {
42-
handle_karma_events(&evt, dazeus);
44+
let highlight_char = dazeus.get_highlight_char().unwrap_or("}".to_string());
45+
let nick = dazeus.nick(&evt[0]).unwrap_or("DaZeus".to_string());
46+
47+
let hl_with_char = format!("{}karma", highlight_char);
48+
let hl_with_nick = format!("{}:", nick);
49+
let hl_with_nick_alt = format!("{},", nick);
50+
51+
let msg = &evt[3];
52+
53+
if !msg.starts_with(&hl_with_char[..]) && !msg.starts_with(&hl_with_nick[..]) && !msg.starts_with(&hl_with_nick_alt[..]) {
54+
handle_karma_events(&evt, dazeus);
55+
}
4356
});
4457

4558
dazeus.subscribe_command("karma", |evt, dazeus| {

0 commit comments

Comments
 (0)