1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub enum MediaType {
    MediaTypeNone,
    MediaTypeVideo,
    MediaTypeAudio,
}

#[derive(Copy, Clone)]
#[allow(dead_code)]
pub struct Timer {
    tid: i32,
    milliseconds: i32,
}
impl Timer {
    pub fn get_tid(&self) -> i32 {
        self.tid
    }
    pub fn get_milliseconds(&self) -> i32 {
        self.milliseconds
    }
    pub fn new(_tid: i32, _milliseconds: i32) -> Self {
        Timer {
            tid: _tid,
            milliseconds: _milliseconds,
        }
    }
}

pub trait BasePlugin {
    // get plugin name
    fn get_name(&self) -> String;

    // get plugin author
    fn get_author(&self) -> String;

    // get plugin args
    fn get_args(&self) -> Vec<String>;

    // get plugin filter name
    fn get_filter_name(&self) -> String;

    // get plugin media type
    fn get_media_type(&self) -> MediaType;

    // validate args
    fn validate_user_args(&self, args: &Vec<String>) -> Result<bool, &'static str>;

    // print plugin log
    fn print_log(&self, level: super::util::os::PrintLogLevel, log: &str) {
        super::util::os::print_log(level, format!("[{}]", self.get_name()).to_string() + log)
    }

    // get timer
    fn register_task(&self) -> Vec<Timer> {
        let empty: Vec<Timer> = Vec::new();
        empty
    }

    // get subscribe key
    fn register_message_keys(&self) -> Vec<super::proto::keys::EventMessageAction> {
        let empty: Vec<super::proto::keys::EventMessageAction> = Vec::new();
        empty
    }

    // execute timer
    #[warn(unused_variables)]
    fn execute_task(&mut self, _tid: u32) {}

    // execute message
    #[allow(unused_variables)]
    fn execute_message(&mut self, action: i32, body: String) {}
}