Exemple #1
0
/**
 * Handle nick collide messages to make sure we are still connected
 *
 * @param user is the nick of the person whom was part of the collide
 *
 * @return always returns MOD_CONT
 */
int m_nickcoll(char *user)
{
    if (nickIsServices(user)) {
        introduce_user(user);
    }
    return MOD_CONT;
}
Exemple #2
0
/**
 * Handle KILL messages
 *
 * @param source is the server or nick that send the message
 * @param nick is the user name that was killed
 * @param msg is the text of the kill message
 *
 * @return void - no returend value
 */
void m_kill(char *source, char *nick, char *msg)
{
    User *u;
    ServStats *s;
    int id;

    if ((u = user_find(source))) {
        if ((s = findserverstats(u->server->name))) {
            s->ircopskills++;
        }
        send_event(EVENT_GLOBAL_KILL, 3, source, nick, msg);
    } else if ((s = findserverstats(source))) {
        s->serverkills++;
        send_event(EVENT_SERVER_KILL, 3, source, nick, msg);
    }
    do_kill(nick, msg);
    if (denora->do_sql) {
        nick = rdb_escape(nick);
        db_removenick(nick, msg);
        if (UserCacheTime) {
            db_cleanuser();
        }
        free(nick);
    }
    if (s && denora->do_sql) {
        id = db_getserver(s->name);
        if (id) {
            rdb_query
                (QUERY_LOW,
                 "UPDATE %s SET ircopskills=%d, serverkills=%ld WHERE servid=%d",
                 ServerTable, s->ircopskills, s->serverkills, id);
        }
    }
    if (nickIsServices(nick)) {
        introduce_user(nick);
    }
}
void process()
{
    int retVal = 0;
    Message *current = NULL;
    char source[64];
    char cmd[64];
    char buf[512];              /* Longest legal IRC command line */
    char *s;
    int ac;                     /* Parameters for the command */
    char **av;
    Message *m;

    /* zero out the buffers before we do much else */
    *buf = '\0';
    *source = '\0';
    *cmd = '\0';

    /* If debugging, log the buffer */
    if (debug) {
        alog("debug: Received: %s", inbuf);
    }

    /* First make a copy of the buffer so we have the original in case we
     * crash - in that case, we want to know what we crashed on. */
    strscpy(buf, inbuf, sizeof(buf));

    doCleanBuffer((char *) buf);

    /* Split the buffer into pieces. */
    if (*buf == ':') {
        s = strpbrk(buf, " ");
        if (!s)
            return;
        *s = 0;
        while (isspace(*++s));
        strscpy(source, buf + 1, sizeof(source));
        memmove(buf, s, strlen(s) + 1);
    } else {
        *source = 0;
    }
    if (!*buf)
        return;
    s = strpbrk(buf, " ");
    if (s) {
        *s = 0;
        while (isspace(*++s));
    } else
        s = buf + strlen(buf);
    strscpy(cmd, buf, sizeof(cmd));
    ac = split_buf(s, &av, 1);
    if (protocoldebug) {
        protocol_debug(source, cmd, ac, av);
    }
    if (mod_current_buffer) {
        free(mod_current_buffer);
    }
    /* fix to moduleGetLastBuffer() bug 296 */
    /* old logic was that since its meant for PRIVMSG that we would get
       the NICK as AV[0] and the rest would be in av[1], however on Bahamut
       based systems when you do /cs it assumes we will translate the command
       to the NICK and thus AV[0] is the message. The new logic is to check
       av[0] to see if its a service nick if so assign mod_current_buffer the
       value from AV[1] else just assign av[0] - TSL */
    /* First check if the ircd proto module overrides this -GD */
    /* fix to moduleGetLastBuffer() bug 476:
       fixed in part by adding {} to nickIsServices()
       however if you have a pseudo they could not use moduleGetLastBuffer()
       cause they are not part of nickIsServices, even those the ac count is 2
       that was ignored and only the first param was passed on which is fine for
       Bahmut ircd aliases but not for pseudo clients on. So additional logic is
       that if the ac is greater then 1 copy av[1] else copy av[0] 
       I also changed from if statments, cause attempting to access a array member
       that is not set can lead to odd things - TSL (3/12/06) */
    if (!xanadu_set_mod_current_buffer(ac, av)) {
        if (ac >= 1) {
            if (nickIsServices(av[0], 1)) {
                mod_current_buffer =
                    (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0]));
            } else {
                mod_current_buffer =
                    (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0]));
            }
        } else {
            mod_current_buffer = NULL;
        }
    }
    /* Do something with the message. */
    m = find_message(cmd);
    if (m) {
        if (m->func) {
            mod_current_module_name = m->mod_name;
            retVal = m->func(source, ac, av);
            mod_current_module_name = NULL;
            if (retVal == MOD_CONT) {
                current = m->next;
                while (current && current->func && retVal == MOD_CONT) {
                    mod_current_module_name = current->mod_name;
                    retVal = current->func(source, ac, av);
                    mod_current_module_name = NULL;
                    current = current->next;
                }
            }
        }
    } else {
        if (debug)
            alog("debug: unknown message from server (%s)", inbuf);
    }

    /* Load/unload modules if needed */
    handleModuleOperationQueue();

    /* Free argument list we created */
    free(av);
}