aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugin.rs
blob: 0a4034ddbbf562b92ee0562fa9aec4fe1a0a1298 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::fmt;
use irc::client::prelude::*;
use irc::error::Error as IrcError;

pub trait Plugin: PluginName + Send + Sync + fmt::Debug {
    fn is_allowed(&self, server: &IrcServer, message: &Message) -> bool;
    fn execute(&mut self, server: &IrcServer, message: &Message) -> Result<(), IrcError>;
    fn command(&mut self, server: &IrcServer, command: PluginCommand) -> Result<(), IrcError>;
}

pub trait PluginName: Send + Sync + fmt::Debug {
    fn name(&self) -> &str;
}

#[derive(Clone, Debug)]
pub struct PluginCommand {
    pub source: String,
    pub target: String,
    pub tokens: Vec<String>,
}