Esempio n. 1
0
File: hash.c Progetto: NX-Andro/x3
void
NickChange(struct userNode* user, const char *new_nick, int no_announce)
{
    char *old_nick;
    unsigned int nn;

    /* don't do anything if there's no change */
    old_nick = user->nick;
    if (!strncmp(new_nick, old_nick, NICKLEN))
        return;

    /* remove old entry from clients dictionary */
    dict_remove(clients, old_nick);
#if !defined(WITH_PROTOCOL_P10)
    /* Remove from uplink's clients dict */
    dict_remove(user->uplink->users, old_nick);
#endif
    /* and reinsert */
    user->nick = strdup(new_nick);
    dict_insert(clients, user->nick, user);
#if !defined(WITH_PROTOCOL_P10)
    dict_insert(user->uplink->users, user->nick, user);
#endif

    /* Make callbacks for nick changes.  Do this with new nick in
     * place because that is slightly more useful.
     */
    for (nn=0; (nn<ncf2_used) && !user->dead; nn++)
        ncf2_list[nn](user, old_nick, ncf2_list_extra[nn]);
    user->timestamp = now;
    if (IsLocal(user) && !no_announce)
        irc_nick(user, old_nick);
    free(old_nick);
}
Esempio n. 2
0
void test_irc_nick() {
    char msg[READ_BUF];

    irc_nick("circus");
    read_mock(msg);

    mu_assert(s_eq(msg, "NICK circus\r\n"), "test_irc_nick: msg should be 'NICK circus\\r\\n'");
}
Esempio n. 3
0
File: irc.c Progetto: mattwb65/sigyn
void sigyn_introduce_client(char *nick)
{
	/* Generate the system hostname; RFC1459 wants us to send this. */
	char hostname[256];
    sigyn_hostname(hostname, 255);
    
    /* Introduce ourselves to the server. */
    irc_nick(nick);
    irc_user(nick, hostname, me.uplink.hostname, me.client->gecos);
}
Esempio n. 4
0
static
char *test_irc_nick() {
    bstring expected;

    expected = bfromcstr("NICK lolbot\r\n");
    irc_nick(SOCK, "lolbot");
    mu_assert("Empty message", blength(sent) != 0);
    mu_assert("Message differs from expected", bstrcmp(expected, sent) == 0);
    bdestroy(expected);
    bdestroy(sent);

    return NULL;
}
Esempio n. 5
0
File: prbot.c Progetto: rfw/prbot
int
main(int argc, char *argv[])
{
    // Compile some regexes.
    if (regcomp(&new_pr_regex, NEW_PR_PATTERN, REG_EXTENDED)) {
        fprintf(stderr, "Failed to compile regex.\n");
        return 1;
    }

    // Initialize SQLite gunk.
    int retval;

    retval = sqlite3_open(DATABASE_NAME, &db);
    if (retval) {
        fprintf(stderr, "Failed to open database: %s\n", sqlite3_errmsg(db));
        return 1;
    }

    retval = sqlite3_exec(db, INITIALIZE_DB, 0, 0, 0);
    if (retval) {
        fprintf(stderr, "Failed to initialize database: %s\n", sqlite3_errmsg(db));
        return 1;
    }
 
    // Kick off the IRC connection.
	char buf[BUF_LEN];
	struct ircbuf ircbuf;
	ircbuf_init(&ircbuf, buf, BUF_LEN);

	int fd = irc_connect(IRC_HOST, IRC_PORT);
	if (fd < 0) {
		fprintf(stderr, "Failed to open connection.\n");
		return 1;
	}

	irc_nick(fd, IRC_NICK, NULL);
	irc_join(fd, IRC_CHANNEL);

	char *line;
	while ((line = irc_getline(fd, &ircbuf))) {
		printf("%s\n", line);

		struct ircmsg msg;
		irc_parseline(line, &msg);
		if (!dispatch_handler(fd, &msg))
			return 2;
	}

	return 0;
}
Esempio n. 6
0
void network_connect(struct network *net)
{
    struct channel *tmp;
    irc_connect(net);
    if (net->close_network)
        return ;

    irc_nick(net);
    network_write_nick(net);
    irc_user(net);
    network_write_realname(net);
    if (net->password)
        irc_pass(net);

    network_foreach_channel(net, tmp)
        irc_join(net, tmp->name);

    network_write_joined(net);
}
Esempio n. 7
0
static int bad_nick(int argc, char *argv[])
{
	char *nick = copy_string(argv[3]);
	user_t *u = find_user(nick, irc_pick_server());
	int len = strlen(nick);
	int i;

	for (i = len - 1; i >= 0; i--) {
		if (nick[i] != '_') {
			nick[i] = '_';
			break;
		}
	}

	if (i < 0) {
		cio_out("could not set nick\n");
		return -1;
	}

	irc_nick(nick);
	u->recv_nick(u, nick);
	return 0;
}
Esempio n. 8
0
unsigned int rehashconfig(void) {
    char **xlines;
    char *conftok = (char*)callocm(CONF_MAX_ITEMLEN, sizeof(char));
    unsigned int i = 0, xcount = 0,
    acount = 0; /* Don't get this confused with the word "account" */
    extern q_maxbytes;
    
    /*X:Line*/
    xcount = get_confitem(&xlines, 'X');
    if(!xcount) {
        make_error("No X:lines in configuration file.");
        freem(conftok);
        return 0;
    }
    /*nickname*/    xstrcpy(bot.nick, get_itemtok(conftok, xlines[0], 2), 32);
    if(!istrcmp(bot.current_nick, bot.nick))
        irc_nick(bot.nick);
    /*altnick*/     xstrcpy(bot.altnick, get_itemtok(conftok, xlines[0], 3), 32);
    
    /*S:Lines*/
    /*maxretry*/    irc_subconftok(conftok, 'S', "maxretry", 3);
                    bot.maxretry = atoi(conftok);
                    
    /*pingtimeout*/ irc_subconftok(conftok, 'S', "pingtimeout", 3);
                    bot.ping_timeout = atoi(conftok);
    
    /*antiflood*/   irc_subconftok(conftok, 'S', "antiflood", 5);
                    bot.floodcheck = (atoi(conftok) ? 1 : 0);
                    irc_subconftok(conftok, 'S', "antiflood", 3);
                    q_maxbytes = (unsigned int)atoi(conftok);
    
    /*ctrigger*/    irc_subconftok(conftok, 'S', "ctrigger", 3);
                    conf_replace_alias(conftok);
                    bot.ctrigger = conftok[0];
    
    /*ptrigger*/    irc_subconftok(conftok, 'S', "ptrigger", 3);
                    conf_replace_alias(conftok);
                    bot.ptrigger = conftok[0];
                    
    /*A:Lines*/
    if(bot.admin_array != NULL)
        free_2d_array(bot.admin_array, bot.admin_lines);
    
    acount = get_confitem(&bot.admin_array, 'A');
    bot.admin_lines = acount;
    if(acount) {
        for(i = 0;i < bot.admin_lines;i++) {
            get_itemtok(conftok, bot.admin_array[i], 3);
            if((istrcmp(conftok, ";")) || (istrcmp(conftok, "*")))
                adm_loginuser(get_itemtok(conftok, bot.admin_array[i], 2),
                                get_itemtok(conftok, bot.admin_array[i], 4),
                                atoi(get_itemtok(conftok, bot.admin_array[i], 5)));
        }
    }
    
    freem(conftok);
    free_2d_array(xlines, xcount);
    
    event_call(EVENT_REHASH, 0);
    
    return 1;
}
Esempio n. 9
0
static int nick_hook(int argc, char *argv[])
{
	irc_nick(argv[1]);
	return 0;
}
Esempio n. 10
0
void irc_login(char* nick, char* user_name, char* real_name) {
    irc_nick(nick);
    irc_user(user_name, real_name);
}