Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slack to 0.16 and serde to 0.8 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ homepage = "https://github.com/mthjones/slackbot"
documentation = "https://mthjones.github.io/slackbot/slackbot"

[dependencies]
slack = "^0.8.2"
serde_json = "^0.6.0"
slack = "^0.16"
serde_json = "^0.8.0"
4 changes: 2 additions & 2 deletions src/event_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use slack::{EventHandler,RtmClient};
use slack::{Error, Event, EventHandler, RtmClient};
use serde_json::{self, Value};

use super::CommandHandler;
Expand Down Expand Up @@ -61,7 +61,7 @@ impl<'a> SlackBotEventHandler<'a> {
}

impl<'a> EventHandler for SlackBotEventHandler<'a> {
fn on_receive(&mut self, cli: &mut RtmClient, json_str: &str) {
fn on_event(&mut self, cli: &mut RtmClient, _: Result<Event, Error>, json_str: &str) {
if let Some(cmd) = Self::parse_json_to_command(&self.bot_name[..], json_str) {
let user = cli.get_users().iter().find(|u| u.id == cmd.user_id).unwrap().clone();
if let Some(handler) = self.handlers.get_mut(&cmd.command[..]) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern crate slack;
extern crate serde_json;

use std::collections::HashMap;
use slack::RtmClient;
use slack::{Error, RtmClient};

mod event_handler;
mod sender;
Expand Down Expand Up @@ -113,7 +113,7 @@ impl SlackBot {
/// Err(err) => println!("Bot crashed. Error message: {}", err)
/// };
/// ```
pub fn run(&mut self) -> Result<(), String> {
pub fn run(&mut self) -> Result<(), Error> {
let mut client = RtmClient::new(&self.token[..]);
let mut handler = SlackBotEventHandler::new(&self.name[..], &mut self.handlers);

Expand Down
6 changes: 3 additions & 3 deletions src/sender.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use slack::{RtmClient, User};
use slack::{Error, RtmClient, User};

/// The sender of a command to the bot.
pub struct Sender<'a> {
Expand Down Expand Up @@ -30,7 +30,7 @@ impl<'a> Sender<'a> {
/// sender.respond_in_channel("Hello, world!");
/// # }));
/// ```
pub fn respond_in_channel<S: Into<String>>(&mut self, message: S) -> Result<(), String> {
pub fn respond_in_channel<S: Into<String>>(&mut self, message: S) -> Result<isize, Error> {
self.channel_writer.write(message)
}
}
Expand All @@ -48,7 +48,7 @@ impl<'a> ChannelWriter<'a> {
}
}

fn write<S: Into<String>>(&mut self, message: S) -> Result<(), String> {
fn write<S: Into<String>>(&mut self, message: S) -> Result<isize, Error> {
self.client.send_message(&self.channel_id[..], &message.into()[..])
}
}