Exemplo n.º 1
0
static void highlight_init() {
    /* Let everyone know we're here. */
    scr_log_print(LPRINT_NORMAL, "highlight: plugin enabled.");

    /* Register our message handler so we can start processing incoming messages. */
    globals.hook = hk_add_handler(highlight_process_message, HOOK_PRE_MESSAGE_IN, G_PRIORITY_DEFAULT, NULL);

    /* Add our commands for highlighting. */
    cmd_add("highlight", "", 0, 0, highlight_command, NULL);
}
Exemplo n.º 2
0
static void highlight_uninit() {
    /* Let everyone know we're checking out. */
    scr_log_print(LPRINT_NORMAL, "highlight: plugin disabled.");

    /* De-register our message handler as we're done with it now. */
    hk_del_handler(HOOK_PRE_MESSAGE_IN, globals.hook);

    /* Remove our commands. */
    cmd_del("highlight");

    /* Nullify all the pointers. */
    globals.match_list = NULL;
}
Exemplo n.º 3
0
static void highlight_command(char *argument) {
    GRegexCompileFlags flags = 0;
    GRegex *regex = NULL;
    GError *error = NULL;

    flags |= G_REGEX_RAW;
    flags |= G_REGEX_OPTIMIZE;
    flags |= G_REGEX_CASELESS;
    flags |= G_REGEX_NO_AUTO_CAPTURE;

    /* Compile the trimmed argument into a regular expression to match against. */
    regex = g_regex_new(argument, flags, G_REGEX_MATCH_NOTEMPTY, &error);

    if (error) {
        /* Error in regexp, log and abort. */
        scr_log_print(LPRINT_LOGNORM, "highlight: Error compiling regex: %s.", error->message);
        g_error_free(error);
    } else {
        /* Add it to the list of matchers. */
        scr_log_print(LPRINT_LOGNORM, "highlight: Added highlight for %s.", argument);
        globals.match_list = g_slist_append(globals.match_list, (gpointer) regex);
    }
}
Exemplo n.º 4
0
/* Initialization */
static void urlregex_init(void)
{
  if (settings_opt_get("url_regex")) {
#ifdef HAVE_GLIB_REGEX
    url_regex = g_regex_new(settings_opt_get("url_regex"),
                            G_REGEX_OPTIMIZE, 0, NULL);
    /* Add handler
     * We are only interested in incoming message events
     */
    urlregex_hid = hk_add_handler(urlregex_hh, HOOK_POST_MESSAGE_IN,
                                  G_PRIORITY_DEFAULT_IDLE, NULL);
#else
    scr_log_print(LPRINT_LOGNORM, "ERROR: Your glib version is too old, "
                  "cannot use url_regex.");
#endif // HAVE_GLIB_REGEX
  }
}
static void slack_completion_init(void) {
    scr_log_print(LPRINT_NORMAL, "slack_completion: init");

    register_builtin_cat(COMPL_RESOURCE, compl_dyn_resource_slack);
}