Beispiel #1
0
void
irc_notify_check_now (struct t_irc_notify *notify)
{
    /* don't send anything if we are not connected to the server */
    if (!notify->server->is_connected)
        return;

    if (notify->server->monitor > 0)
    {
        /* send MONITOR for nick */
        irc_server_sendf (notify->server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
                          "MONITOR + %s", notify->nick);
    }
    else
    {
        /* send ISON for nick (MONITOR not supported on server) */
        irc_redirect_new (notify->server, "ison", "notify", 1, NULL, 0, NULL);
        irc_server_sendf (notify->server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
                          "ISON :%s", notify->nick);
    }

    if (notify->check_away)
    {
        /* send WHOIS for nick */
        irc_redirect_new (notify->server, "whois", "notify", 1, notify->nick, 0,
                          "301,401");
        irc_server_sendf (notify->server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
                          "WHOIS :%s", notify->nick);
    }
}
Beispiel #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;
}
Beispiel #3
0
int
irc_notify_timer_whois_cb (const void *pointer, void *data,
                           int remaining_calls)
{
    struct t_irc_server *ptr_server;
    struct t_irc_notify *ptr_notify, *ptr_next_notify;

    /* 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_notify = ptr_server->notify_list;
            while (ptr_notify)
            {
                ptr_next_notify = ptr_notify->next_notify;

                if (ptr_notify->check_away)
                {
                    /*
                     * redirect whois, and get only 2 messages:
                     * 301: away message
                     * 401: no such nick/channel
                     */
                    irc_redirect_new (ptr_server, "whois", "notify", 1,
                                      ptr_notify->nick, 0, "301,401");
                    irc_server_sendf (ptr_server,
                                      IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
                                      "WHOIS :%s", ptr_notify->nick);
                }

                ptr_notify = ptr_next_notify;
            }
        }
    }

    return WEECHAT_RC_OK;
}
Beispiel #4
0
int
irc_redirect_command_hsignal_cb (const void *pointer, void *data,
                                 const char *signal,
                                 struct t_hashtable *hashtable)
{
    const char *server, *pattern, *redirect_signal, *str_count, *string;
    const char *str_timeout, *cmd_filter;
    char *error;
    struct t_irc_server *ptr_server;
    int number, count, timeout;

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

    if (!hashtable)
        return WEECHAT_RC_ERROR;

    server = weechat_hashtable_get (hashtable, "server");
    pattern = weechat_hashtable_get (hashtable, "pattern");
    redirect_signal = weechat_hashtable_get (hashtable, "signal");
    str_count = weechat_hashtable_get (hashtable, "count");
    string = weechat_hashtable_get (hashtable, "string");
    str_timeout = weechat_hashtable_get (hashtable, "timeout");
    cmd_filter = weechat_hashtable_get (hashtable, "cmd_filter");

    if (!server || !server[0])
    {
        weechat_printf (
            NULL,
            _("%s%s: missing argument \"%s\" for redirect"),
            weechat_prefix ("error"), IRC_PLUGIN_NAME, "server");
        return WEECHAT_RC_ERROR;
    }
    ptr_server = irc_server_search (server);
    if (!ptr_server)
    {
        weechat_printf (
            NULL,
            _("%s%s: server \"%s\" not found for redirect"),
            weechat_prefix ("error"), IRC_PLUGIN_NAME, server);
        return WEECHAT_RC_ERROR;
    }

    count = 1;
    if (str_count && str_count[0])
    {
        number = (int)strtol (str_count, &error, 10);
        if (error && !error[0])
            count = number;
    }

    timeout = 0;
    if (str_timeout && str_timeout[0])
    {
        number = (int)strtol (str_timeout, &error, 10);
        if (error && !error[0])
            timeout = number;
    }

    irc_redirect_new (ptr_server, pattern, redirect_signal,
                      count, string, timeout, cmd_filter);

    return WEECHAT_RC_OK;
}