aboutsummaryrefslogtreecommitdiff
path: root/src/macros.rs
blob: 05ce731c617a302031fd39e79d2ab31c0ce2d022 (plain) (blame)
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
#![macro_use]

#[macro_export]
macro_rules! check_error {
    ($e:expr) => {
        if let Err(err) = $e {
            warn!("ERROR [{}:{}] {:?}", line!(), column!(), err);
        }
    };
}

macro_rules! failed {
    ($e:expr) => { warn!("[{}:{}] {}", line!(), column!(), $e); };
    ($e:expr, $w:expr) => { warn!("[{}:{}] {} | {}", line!(), column!(), $e, $w); };
}

macro_rules! now {
    () => { Utc::now().format("%FT%T").to_string() };
}

macro_rules! exec_on_message {
    ([$ctx:expr, $message:expr], $($plugin:ident), *) => {{
        // use utils::config::get_pool;
        // let pool = get_pool(&$ctx);

        $($plugin::on_message($ctx, /* &pool, */ $message);)*
    }}
}