Exemplo n.º 1
0
int
irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
{
    const char *ptr_data;
    char *data_with_colors, *msg;

    IRC_BUFFER_GET_SERVER_CHANNEL(buffer);

    if (buffer == irc_raw_buffer)
    {
        if (dogechat_strcasecmp (input_data, "q") == 0)
            dogechat_buffer_close (buffer);
    }
    else
    {
        /*
         * if send unknown commands is enabled and that input data is a
         * command, then send this command to IRC server
         */
        if (dogechat_config_boolean (irc_config_network_send_unknown_commands)
            && !dogechat_string_input_for_buffer (input_data))
        {
            if (ptr_server)
            {
                irc_server_sendf (ptr_server, flags, NULL,
                                  "%s", dogechat_utf8_next_char (input_data));
            }
            return DOGECHAT_RC_OK;
        }

        if (ptr_channel)
        {
            ptr_data = dogechat_string_input_for_buffer (input_data);
            if (!ptr_data)
                ptr_data = input_data;
            data_with_colors = irc_color_encode (
                ptr_data,
                dogechat_config_boolean (irc_config_network_colors_send));

            msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
            if (msg)
            {
                irc_input_send_user_message (buffer, flags, NULL, msg);
                free (msg);
            }

            if (data_with_colors)
                free (data_with_colors);
        }
        else
        {
            dogechat_printf (buffer,
                            _("%s%s: this buffer is not a channel!"),
                            dogechat_prefix ("error"), IRC_PLUGIN_NAME);
        }
    }

    return DOGECHAT_RC_OK;
}
Exemplo n.º 2
0
void
script_action_load (const char *name, int quiet)
{
    char *pos, str_command[1024];
    int language;

    language = -1;
    pos = strrchr (name, '.');
    if (pos)
        language = script_language_search_by_extension (pos + 1);
    if (language < 0)
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: unknown language for script \"%s\""),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* check that plugin for this language is loaded */
    if (!script_plugin_loaded[language])
    {
        dogechat_printf (NULL,
                        _("%s: plugin \"%s\" is not loaded"),
                        SCRIPT_PLUGIN_NAME, script_language[language]);
        return;
    }

    /* execute command (for example: "/perl load iset.pl") */
    snprintf (str_command, sizeof (str_command),
              "/%s load %s%s",
              script_language[language],
              (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
              name);
    dogechat_command (NULL, str_command);
}
Exemplo n.º 3
0
int
script_action_show_diff_process_cb (void *data, const char *command,
                                    int return_code, const char *out,
                                    const char *err)
{
    char **lines, *filename;
    const char *color;
    int num_lines, i, diff_color;

    /* make C compiler happy */
    (void) command;

    if (script_buffer && script_buffer_detail_script
        && ((return_code == DOGECHAT_HOOK_PROCESS_RUNNING) || (return_code >= 0)))
    {
        if (out)
        {
            lines = dogechat_string_split (out, "\n", 0, 0, &num_lines);
            if (lines)
            {
                diff_color = dogechat_config_boolean (script_config_look_diff_color);
                for (i = 0; i < num_lines; i++)
                {
                    color = NULL;
                    if (diff_color)
                    {
                        switch (lines[i][0])
                        {
                            case '-':
                            case '<':
                                color = dogechat_color ("red");
                                break;
                            case '+':
                            case '>':
                                color = dogechat_color ("green");
                                break;
                            case '@':
                                color = dogechat_color ("cyan");
                                break;
                        }
                    }
                    dogechat_printf_y (script_buffer,
                                      script_buffer_detail_script_last_line++,
                                      "%s%s",
                                      (color) ? color : "",
                                      lines[i]);
                }
                dogechat_string_free_split (lines);
            }
        }
        else if (err)
        {
            lines = dogechat_string_split (err, "\n", 0, 0, &num_lines);
            if (lines)
            {
                for (i = 0; i < num_lines; i++)
                {
                    dogechat_printf_y (script_buffer,
                                      script_buffer_detail_script_last_line++,
                                      "%s",
                                      lines[i]);
                }
                dogechat_string_free_split (lines);
            }
        }
        if (return_code >= 0)
        {
            dogechat_printf_y (script_buffer,
                              script_buffer_detail_script_last_line++,
                              "%s----------------------------------------"
                              "----------------------------------------",
                              dogechat_color ("magenta"));
        }
    }

    if ((return_code == DOGECHAT_HOOK_PROCESS_ERROR) || (return_code >= 0))
    {
        /* last call to this callback: delete temporary file */
        filename = (char *)data;
        unlink (filename);
        free (filename);
    }

    return DOGECHAT_RC_OK;
}
Exemplo n.º 4
0
void
script_action_remove (const char *name, int quiet)
{
    struct t_script_repo *ptr_script;
    char str_signal[256], *filename;
    int length;

    ptr_script = script_repo_search_by_name_ext (name);
    if (!ptr_script)
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: script \"%s\" not found"),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* check that script is installed */
    if (!(ptr_script->status & SCRIPT_STATUS_INSTALLED))
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: script \"%s\" is not installed"),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* check that script is not held */
    if (ptr_script->status & SCRIPT_STATUS_HELD)
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: script \"%s\" is held"),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* check that plugin for this language is loaded */
    if (!script_plugin_loaded[ptr_script->language])
    {
        dogechat_printf (NULL,
                        _("%s: script \"%s\" can not be removed "
                          "because plugin \"%s\" is not loaded"),
                        SCRIPT_PLUGIN_NAME,
                        ptr_script->name_with_extension,
                        script_language[ptr_script->language]);
        return;
    }

    /* ask plugin to remove script */
    length = 3 + strlen (ptr_script->name_with_extension) + 1;
    filename = malloc (length);
    if (filename)
    {
        snprintf (filename, length,
                  "%s%s",
                  (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
                  ptr_script->name_with_extension);
        snprintf (str_signal, sizeof (str_signal),
                  "%s_script_remove",
                  script_language[ptr_script->language]);
        (void) dogechat_hook_signal_send (str_signal,
                                         DOGECHAT_HOOK_SIGNAL_STRING,
                                         filename);
        free (filename);
    }
}
Exemplo n.º 5
0
void
script_action_install (int quiet)
{
    struct t_script_repo *ptr_script_to_install;
    char *filename, *url;
    struct t_hashtable *options;

    while (1)
    {
        ptr_script_to_install = script_action_get_next_script_to_install ();

        /* no more script to install? just exit function */
        if (!ptr_script_to_install)
            return;

        /*
         * script to install and plugin is loaded: exit loop and go on with
         * install
         */
        if (script_plugin_loaded[ptr_script_to_install->language])
            break;

        /* plugin not loaded for language of script: display error */
        dogechat_printf (NULL,
                        _("%s: script \"%s\" can not be installed because "
                          "plugin \"%s\" is not loaded"),
                        SCRIPT_PLUGIN_NAME,
                        ptr_script_to_install->name_with_extension,
                        script_language[ptr_script_to_install->language]);
    }

    filename = script_config_get_script_download_filename (ptr_script_to_install,
                                                           NULL);
    if (filename)
    {
        options = dogechat_hashtable_new (32,
                                         DOGECHAT_HASHTABLE_STRING,
                                         DOGECHAT_HASHTABLE_STRING,
                                         NULL,
                                         NULL);
        if (options)
        {
            url = script_build_download_url (ptr_script_to_install->url);
            if (url)
            {
                if (!dogechat_config_boolean (script_config_look_quiet_actions))
                {
                    dogechat_printf (NULL,
                                    _("%s: downloading script \"%s\"..."),
                                    SCRIPT_PLUGIN_NAME,
                                    ptr_script_to_install->name_with_extension);
                }
                dogechat_hashtable_set (options, "file_out", filename);
                dogechat_hook_process_hashtable (
                    url,
                    options,
                    dogechat_config_integer (script_config_scripts_download_timeout) * 1000,
                    &script_action_install_process_cb,
                    (quiet) ? (void *)1 : (void *)0);
                free (url);
            }
            dogechat_hashtable_free (options);
        }
        free (filename);
    }
}
Exemplo n.º 6
0
int
script_action_install_process_cb (void *data, const char *command,
                                  int return_code, const char *out,
                                  const char *err)
{
    char *pos, *filename, *filename2, str_signal[256];
    int quiet, length;
    struct t_script_repo *ptr_script;

    /* make C compiler happy */
    (void) out;

    quiet = (data) ? 1 : 0;

    if (return_code >= 0)
    {
        pos = strrchr (command, '/');

        if (err && err[0])
        {
            dogechat_printf (NULL,
                            _("%s%s: error downloading script \"%s\": %s"),
                            dogechat_prefix ("error"),
                            SCRIPT_PLUGIN_NAME,
                            (pos) ? pos + 1 : "?",
                            err);
            return DOGECHAT_RC_OK;
        }

        if (pos)
        {
            ptr_script = script_repo_search_by_name_ext (pos + 1);
            if (ptr_script)
            {
                filename = script_config_get_script_download_filename (ptr_script,
                                                                       NULL);
                if (filename)
                {
                    length = 16 + strlen (filename) + 1;
                    filename2 = malloc (length);
                    if (filename2)
                    {
                        snprintf (filename2, length,
                                  "%s%s%s",
                                  (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
                                  (dogechat_config_boolean (script_config_scripts_autoload)) ? "-a " : "",
                                  filename);
                        snprintf (str_signal, sizeof (str_signal),
                                  "%s_script_install",
                                  script_language[ptr_script->language]);
                        (void) dogechat_hook_signal_send (str_signal,
                                                         DOGECHAT_HOOK_SIGNAL_STRING,
                                                         filename2);
                        free (filename2);
                    }
                    free (filename);
                }

                /* schedule install of next script */
                dogechat_hook_timer (10, 0, 1,
                                    &script_action_installnext_timer_cb,
                                    (quiet) ? (void *)1 : (void *)0);
            }
        }
    }

    return DOGECHAT_RC_OK;
}
Exemplo n.º 7
0
void
script_action_autoload (const char *name, int quiet, int autoload)
{
    struct t_script_repo *ptr_script;
    char str_signal[256], *filename;
    int length;

    ptr_script = script_repo_search_by_name_ext (name);
    if (!ptr_script)
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: script \"%s\" not found"),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* check that script is installed */
    if (!(ptr_script->status & SCRIPT_STATUS_INSTALLED))
    {
        if (!quiet)
        {
            dogechat_printf (NULL,
                            _("%s: script \"%s\" is not installed"),
                            SCRIPT_PLUGIN_NAME, name);
        }
        return;
    }

    /* toggle autoload if value is -1 */
    if (autoload < 0)
        autoload = (ptr_script->status & SCRIPT_STATUS_AUTOLOADED) ? 0 : 1;

    /* ask plugin to autoload (or not) script */
    length = 16 + strlen (ptr_script->name_with_extension) + 1;
    filename = malloc (length);
    if (filename)
    {
        snprintf (filename, length,
                  "%s%s%s",
                  (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
                  (autoload) ? "-a " : "",
                  ptr_script->name_with_extension);
        snprintf (str_signal, sizeof (str_signal),
                  "%s_script_autoload",
                  script_language[ptr_script->language]);
        (void) dogechat_hook_signal_send (str_signal,
                                         DOGECHAT_HOOK_SIGNAL_STRING,
                                         filename);
        free (filename);
    }
    if (!quiet)
    {
        dogechat_printf (NULL,
                        (autoload) ?
                        _("%s: autoload enabled for script \"%s\"") :
                        _("%s: autoload disabled for script \"%s\""),
                        SCRIPT_PLUGIN_NAME, name);
    }
    script_repo_update_status (ptr_script);
}
Exemplo n.º 8
0
void
script_action_reload (const char *name, int quiet)
{
    char *pos, hdata_name[128], *filename, *ptr_base_name, str_command[1024];
    const char *ptr_filename, *ptr_registered_name;
    int language, found, i;
    struct t_hdata *hdata;
    void *ptr_script;

    pos = strrchr (name, '.');
    if (pos)
    {
        /* reload script by using name + extension (example: "iset.pl") */
        language = script_language_search_by_extension (pos + 1);
        if (language < 0)
        {
            if (!quiet)
            {
                dogechat_printf (NULL,
                                _("%s: unknown language for script \"%s\""),
                                SCRIPT_PLUGIN_NAME, name);
            }
            return;
        }
        /*
         * search registered name of script using name with extension,
         * for example with "iset.pl" we should find "iset"
         */
        snprintf (hdata_name, sizeof (hdata_name),
                  "%s_script", script_language[language]);
        hdata = dogechat_hdata_get (hdata_name);
        ptr_script = dogechat_hdata_get_list (hdata, "scripts");
        while (ptr_script)
        {
            found = 0;
            ptr_filename = dogechat_hdata_string (hdata, ptr_script, "filename");
            if (ptr_filename)
            {
                filename = strdup (ptr_filename);
                if (filename)
                {
                    ptr_base_name = basename (filename);
                    if (strcmp (ptr_base_name, name) == 0)
                        found = 1;
                    free (filename);
                }
            }
            if (found)
            {
                ptr_registered_name = dogechat_hdata_string (hdata, ptr_script,
                                                            "name");
                if (ptr_registered_name)
                {
                    snprintf (str_command, sizeof (str_command),
                              "/%s reload %s%s",
                              script_language[language],
                              (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
                              ptr_registered_name);
                    dogechat_command (NULL, str_command);
                }
                return;
            }
            ptr_script = dogechat_hdata_move (hdata, ptr_script, 1);
        }
    }
    else
    {
        /* reload script by using name (example: "iset") */
        for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
        {
            snprintf (hdata_name, sizeof (hdata_name),
                      "%s_script", script_language[i]);
            hdata = dogechat_hdata_get (hdata_name);
            ptr_script = dogechat_hdata_get_list (hdata, "scripts");
            while (ptr_script)
            {
                ptr_registered_name = dogechat_hdata_string (hdata, ptr_script,
                                                            "name");
                if (strcmp (ptr_registered_name, name) == 0)
                {
                    snprintf (str_command, sizeof (str_command),
                              "/%s reload %s%s",
                              script_language[i],
                              (quiet && dogechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
                              name);
                    dogechat_command (NULL, str_command);
                    return;
                }
                ptr_script = dogechat_hdata_move (hdata, ptr_script, 1);
            }
        }
    }

    if (!quiet)
    {
        dogechat_printf (NULL,
                        _("%s: script \"%s\" is not loaded"),
                        SCRIPT_PLUGIN_NAME, name);
    }
}
Exemplo n.º 9
0
void
script_action_show (const char *name, int quiet)
{
    struct t_script_repo *ptr_script;
    char *filename, *url;
    struct t_hashtable *options;

    if (name)
    {
        ptr_script = script_repo_search_by_name_ext (name);
        if (ptr_script)
        {
            script_buffer_show_detail_script (ptr_script);
            if (dogechat_config_boolean (script_config_look_display_source))
            {
                dogechat_printf_y (script_buffer,
                                  script_buffer_detail_script_last_line++,
                                  _("Source code:"));
                dogechat_printf_y (script_buffer,
                                  script_buffer_detail_script_last_line++,
                                  "%s----------------------------------------"
                                  "----------------------------------------",
                                  dogechat_color ("lightcyan"));
                dogechat_printf_y (script_buffer,
                                  script_buffer_detail_script_last_line,
                                  _("Downloading script..."));
                dogechat_printf_y (script_buffer,
                                  script_buffer_detail_script_last_line + 1,
                                  "%s----------------------------------------"
                                  "----------------------------------------",
                                  dogechat_color ("lightcyan"));
                filename = script_config_get_script_download_filename (ptr_script,
                                                                       ".repository");
                if (filename)
                {
                    options = dogechat_hashtable_new (32,
                                                     DOGECHAT_HASHTABLE_STRING,
                                                     DOGECHAT_HASHTABLE_STRING,
                                                     NULL,
                                                     NULL);
                    if (options)
                    {
                        url = script_build_download_url (ptr_script->url);
                        if (url)
                        {
                            dogechat_hashtable_set (options, "file_out", filename);
                            dogechat_hook_process_hashtable (
                                url,
                                options,
                                dogechat_config_integer (script_config_scripts_download_timeout) * 1000,
                                &script_action_show_source_process_cb,
                                NULL);
                            free (url);
                        }
                        dogechat_hashtable_free (options);
                    }
                    free (filename);
                }
            }
        }
        else
        {
            if (!quiet)
            {
                dogechat_printf (NULL,
                                _("%s: script \"%s\" not found"),
                                SCRIPT_PLUGIN_NAME, name);
            }
        }
    }
    else
        script_buffer_show_detail_script (NULL);
}
Exemplo n.º 10
0
void
relay_server_get_protocol_args (const char *protocol_and_args,
                                int *ipv4, int *ipv6, int *ssl,
                                char **protocol, char **protocol_args)
{
    int opt_ipv4, opt_ipv6, opt_ssl;
    char *pos;

    opt_ipv4 = -1;
    opt_ipv6 = -1;
    opt_ssl = 0;
    while (1)
    {
        if (strncmp (protocol_and_args, "ipv4.", 5) == 0)
        {
            opt_ipv4 = 1;
            protocol_and_args += 5;
        }
        else if (strncmp (protocol_and_args, "ipv6.", 5) == 0)
        {
            opt_ipv6 = 1;
            protocol_and_args += 5;
        }
        else if (strncmp (protocol_and_args, "ssl.", 4) == 0)
        {
            opt_ssl = 1;
            protocol_and_args += 4;
        }
        else
            break;
    }
    if ((opt_ipv4 == -1) && (opt_ipv6 == -1))
    {
        /*
         * no IPv4/IPv6 specified, then use defaults:
         * - IPv4 enabled
         * - IPv6 enabled if option relay.network.ipv6 is on
         */
        opt_ipv4 = 1;
        opt_ipv6 = dogechat_config_boolean (relay_config_network_ipv6);
    }
    else
    {
        if (opt_ipv4 == -1)
            opt_ipv4 = 0;
        if (opt_ipv6 == -1)
            opt_ipv6 = 0;
    }
    if (!opt_ipv4 && !opt_ipv6)
    {
        /* both IPv4/IPv6 disabled (should never occur!) */
        opt_ipv4 = 1;
    }
    if (ipv4)
        *ipv4 = opt_ipv4;
    if (ipv6)
        *ipv6 = opt_ipv6;
    if (ssl)
        *ssl = opt_ssl;

    pos = strchr (protocol_and_args, '.');
    if (pos)
    {
        if (protocol)
        {
            *protocol = dogechat_strndup (protocol_and_args,
                                         pos - protocol_and_args);
        }
        if (protocol_args)
            *protocol_args = strdup (pos + 1);
    }
    else
    {
        if (protocol)
            *protocol = strdup (protocol_and_args);
        if (protocol_args)
            *protocol_args = NULL;
    }
}
Exemplo n.º 11
0
void
irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
                                const char *text)
{
    struct t_irc_nick *ptr_nick;
    char *pos, *text2, *text_decoded, str_tags[256], *str_color;
    const char *ptr_text;

    /* if message is an action, force "action" to 1 and extract message */
    if (strncmp (text, "\01ACTION ", 8) == 0)
    {
        action = 1;
        pos = strrchr (text + 8, '\01');
        if (pos)
            text2 = dogechat_strndup (text + 8, pos - text - 8);
        else
            text2 = strdup (text + 8);
    }
    else
        text2 = strdup (text);

    text_decoded = irc_color_decode (
        (text2) ? text2 : text,
        dogechat_config_boolean (irc_config_network_colors_send));

    IRC_BUFFER_GET_SERVER_CHANNEL(buffer);

    if (ptr_channel)
    {
        ptr_nick = NULL;
        if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
        {
            ptr_nick = irc_nick_search (ptr_server, ptr_channel,
                                        ptr_server->nick);
        }

        if (action)
        {
            snprintf (str_tags, sizeof (str_tags),
                      "irc_action,notify_none,no_highlight");
        }
        else
        {
            str_color = irc_color_for_tags (
                dogechat_config_color (
                    dogechat_config_get ("dogechat.color.chat_nick_self")));
            snprintf (str_tags, sizeof (str_tags),
                      "notify_none,no_highlight,prefix_nick_%s",
                      (str_color) ? str_color : "default");
            if (str_color)
                free (str_color);
        }
        ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text);
        if (action)
        {
            dogechat_printf_tags (
                buffer,
                irc_protocol_tags (
                    "privmsg", str_tags,
                    (ptr_nick) ? ptr_nick->name : ptr_server->nick,
                    NULL),
                "%s%s%s%s%s %s",
                dogechat_prefix ("action"),
                irc_nick_mode_for_display (ptr_server, ptr_nick, 0),
                IRC_COLOR_CHAT_NICK_SELF,
                ptr_server->nick,
                IRC_COLOR_RESET,
                ptr_text);
        }
        else
        {
            dogechat_printf_tags (
                buffer,
                irc_protocol_tags (
                    "privmsg", str_tags,
                    (ptr_nick) ? ptr_nick->name : ptr_server->nick,
                    NULL),
                "%s%s",
                irc_nick_as_prefix (
                    ptr_server,
                    (ptr_nick) ? ptr_nick : NULL,
                    (ptr_nick) ? NULL : ptr_server->nick,
                    IRC_COLOR_CHAT_NICK_SELF),
                ptr_text);
        }
    }

    if (text2)
        free (text2);
    if (text_decoded)
        free (text_decoded);
}
Exemplo n.º 12
0
int
irc_input_send_cb (void *data, const char *signal,
                   const char *type_data, void *signal_data)
{
    const char *ptr_string, *ptr_message;
    char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4, *error;
    char *server, *channel, *flags, *tags;
    long flags_value;
    char *data_with_colors;
    struct t_irc_server *ptr_server;
    struct t_irc_channel *ptr_channel;
    struct t_gui_buffer *ptr_buffer;

    /* make C compiler happy */
    (void) data;
    (void) signal;
    (void) type_data;

    ptr_string = (const char *)signal_data;

    server = NULL;
    channel = NULL;
    flags = NULL;
    tags = NULL;
    ptr_message = NULL;
    ptr_server = NULL;
    ptr_channel = NULL;

    pos_semicol1 = strchr (ptr_string, ';');
    if (pos_semicol1)
    {
        if (pos_semicol1 > ptr_string + 1)
        {
            server = dogechat_strndup (ptr_string, pos_semicol1 - ptr_string);
        }
        pos_semicol2 = strchr (pos_semicol1 + 1, ';');
        if (pos_semicol2)
        {
            if (pos_semicol2 > pos_semicol1 + 1)
            {
                channel = dogechat_strndup (pos_semicol1 + 1,
                                           pos_semicol2 - pos_semicol1 - 1);
            }
            pos_semicol3 = strchr (pos_semicol2 + 1, ';');
            if (pos_semicol3)
            {
                if (pos_semicol3 > pos_semicol2 + 1)
                {
                    flags = dogechat_strndup (pos_semicol2 + 1,
                                             pos_semicol3 - pos_semicol2 - 1);
                }
                pos_semicol4 = strchr (pos_semicol3 + 1, ';');
                if (pos_semicol4)
                {
                    if (pos_semicol4 > pos_semicol3 + 1)
                    {
                        tags = dogechat_strndup (pos_semicol3 + 1,
                                                pos_semicol4 - pos_semicol3 - 1);
                    }
                    ptr_message = pos_semicol4 + 1;
                }
            }
        }
    }

    flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
    if (flags)
    {
        error = NULL;
        flags_value = strtol (flags, &error, 10);
        if (flags_value < 0)
            flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
    }

    if (server && ptr_message)
    {
        ptr_server = irc_server_search (server);
        if (ptr_server)
        {
            ptr_buffer = ptr_server->buffer;
            if (channel)
            {
                ptr_channel = irc_channel_search (ptr_server, channel);
                if (ptr_channel)
                    ptr_buffer = ptr_channel->buffer;
            }

            /* set tags to use by default */
            irc_server_set_send_default_tags (tags);

            /* send text to buffer, or execute command */
            if (dogechat_string_input_for_buffer (ptr_message))
            {
                /* text as input */
                irc_input_data (ptr_buffer, ptr_message, flags_value);
            }
            else
            {
                /* command */
                data_with_colors = irc_color_encode (
                    ptr_message,
                    dogechat_config_boolean (irc_config_network_colors_send));
                dogechat_command (
                    ptr_buffer,
                    (data_with_colors) ? data_with_colors : ptr_message);
                if (data_with_colors)
                    free (data_with_colors);
            }

            /* reset tags to use by default */
            irc_server_set_send_default_tags (NULL);
        }
    }

    if (server)
        free (server);
    if (channel)
        free (channel);
    if (flags)
        free (flags);
    if (tags)
        free (tags);

    return DOGECHAT_RC_OK;
}