Exemplo n.º 1
0
struct t_hashtable *
irc_info_info_hashtable_irc_message_split_cb (void *data,
                                              const char *info_name,
                                              struct t_hashtable *hashtable)
{
    const char *server, *message;
    struct t_irc_server *ptr_server;
    struct t_hashtable *value;

    /* make C compiler happy */
    (void) data;
    (void) info_name;

    if (!hashtable)
        return NULL;

    server = dogechat_hashtable_get (hashtable, "server");
    ptr_server = (server) ? irc_server_search (server) : NULL;
    message = dogechat_hashtable_get (hashtable, "message");
    if (message)
    {
        value = irc_message_split (ptr_server, message);
        return value;
    }

    return NULL;
}
Exemplo n.º 2
0
int
irc_notify_timer_ison_cb (const void *pointer, void *data, int remaining_calls)
{
    char *message, hash_key[32];
    const char *str_message;
    int num_nicks, number;
    struct t_irc_server *ptr_server;
    struct t_hashtable *hashtable;

    /* make C compiler happy */
    (void) pointer;
    (void) data;
    (void) remaining_calls;

    for (ptr_server = irc_servers; ptr_server;
         ptr_server = ptr_server->next_server)
    {
        if (ptr_server->is_connected
            && ptr_server->notify_list
            && (ptr_server->monitor == 0))
        {
            message = irc_notify_build_message_with_nicks (ptr_server,
                                                           "ISON :",
                                                           " ",
                                                           &num_nicks);
            if (message && (num_nicks > 0))
            {
                hashtable = irc_message_split (ptr_server, message);
                if (hashtable)
                {
                    number = 1;
                    while (1)
                    {
                        snprintf (hash_key, sizeof (hash_key), "msg%d", number);
                        str_message = weechat_hashtable_get (hashtable,
                                                             hash_key);
                        if (!str_message)
                            break;
                        irc_redirect_new (ptr_server, "ison", "notify", 1,
                                          NULL, 0, NULL);
                        irc_server_sendf (ptr_server,
                                          IRC_SERVER_SEND_OUTQ_PRIO_LOW,
                                          NULL, "%s", str_message);
                        number++;
                    }
                    weechat_hashtable_free (hashtable);
                }
            }
            if (message)
                free (message);
        }
    }

    return WEECHAT_RC_OK;
}
Exemplo n.º 3
0
struct t_hashtable *
irc_info_get_info_hashtable_cb (void *data, const char *info_name,
                                struct t_hashtable *hashtable)
{
    const char *server, *message;
    struct t_irc_server *ptr_server;
    struct t_hashtable *value;

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

    if (!hashtable)
        return NULL;

    if (weechat_strcasecmp (info_name, "irc_message_parse") == 0)
    {
        server = weechat_hashtable_get (hashtable, "server");
        ptr_server = (server) ? irc_server_search (server) : NULL;
        message = weechat_hashtable_get (hashtable, "message");
        if (message)
        {
            value = irc_message_parse_to_hashtable (ptr_server, message);
            return value;
        }
    }
    else if (weechat_strcasecmp (info_name, "irc_message_split") == 0)
    {
        server = weechat_hashtable_get (hashtable, "server");
        ptr_server = (server) ? irc_server_search (server) : NULL;
        message = weechat_hashtable_get (hashtable, "message");
        if (message)
        {
            value = irc_message_split (ptr_server, message);
            return value;
        }
    }

    return NULL;
}
Exemplo n.º 4
0
void
irc_notify_send_monitor (struct t_irc_server *server)
{
    struct t_hashtable *hashtable;
    char *message, hash_key[32];
    const char *str_message;
    int num_nicks, number;

    message = irc_notify_build_message_with_nicks (server,
                                                   "MONITOR + ",
                                                   ",",
                                                   &num_nicks);
    if (message && (num_nicks > 0))
    {
        hashtable = irc_message_split (server, message);
        if (hashtable)
        {
            number = 1;
            while (1)
            {
                snprintf (hash_key, sizeof (hash_key), "msg%d", number);
                str_message = weechat_hashtable_get (hashtable,
                                                     hash_key);
                if (!str_message)
                    break;
                irc_server_sendf (server,
                                  IRC_SERVER_SEND_OUTQ_PRIO_LOW,
                                  NULL, "%s", str_message);
                number++;
            }
            weechat_hashtable_free (hashtable);
        }
    }
    if (message)
        free (message);
}