Пример #1
0
static channel_type *
qlog_get_channel(const char *msg)
{
    channel_type *chan;
    char *b, *t;
    int l;

    b = strchr(msg, (int) ' ');
    if (b == NULL) {
        return NULL;
    }

    b = strchr(b + 1, (int) ' ');
    if (b == NULL) {
        return NULL;
    }

    l = pos(b + 1, ' ');
    if (l == -1) {
        return NULL;
    }

    t = (char *) xmalloc(l + 1);
    memcpy(t, b + 1, l);
    t[l] = '\0';
    /* Check active/old_channels. */
    chan = channel_find(t, LIST_ACTIVE);
    if (chan == NULL) {
        chan = channel_find(t, LIST_OLD);
    }
    xfree(t);

    return chan;
} /* static channel_type *qlog_get_channel(const char *msg) */
Пример #2
0
static void event_duplicate_channel(IRC_SERVER_REC *server, const char *data)
{
	CHANNEL_REC *chanrec;
	char *params, *channel, *p;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 3, NULL, NULL, &channel);
	p = strchr(channel, ' ');
	if (p != NULL) *p = '\0';

	if (channel[0] == '!' && channel[1] != '!') {
		chanrec = channel_find(SERVER(server), channel);
		if (chanrec != NULL && !chanrec->names_got) {
			/* duplicate channel - this should only happen when
			   there's some sync problem with servers, rejoining
			   after a while should help.

			   note that this same 407 is sent when trying to
			   create !!channel that already exists so we don't
			   want to try rejoining then. */
			channel_rejoin(server, channel);
			signal_stop();
		}
	}

	g_free(params);
}
Пример #3
0
Файл: ignore.c Проект: ahf/irssi
int ignore_check(SERVER_REC *server, const char *nick, const char *host,
		 const char *channel, const char *text, int level)
{
	CHANNEL_REC *chanrec;
	NICK_REC *nickrec;
        IGNORE_REC *rec;
	GSList *tmp;
        char *nickmask;
        int len, best_mask, best_match, best_patt;

        if (nick == NULL) nick = "";

	chanrec = server == NULL || channel == NULL ? NULL :
		channel_find(server, channel);
	if (chanrec != NULL && nick != NULL &&
	    (nickrec = nicklist_find(chanrec, nick)) != NULL) {
                /* nick found - check only ignores in nickmatch cache */
		if (nickrec->host == NULL)
			nicklist_set_host(chanrec, nickrec, host);

		tmp = nickmatch_find(nickmatch, nickrec);
		nickmask = NULL;
	} else {
		tmp = ignores;
		nickmask = g_strconcat(nick, "!", host, NULL);
	}

        best_mask = best_patt = -1; best_match = FALSE;
	for (; tmp != NULL; tmp = tmp->next) {
		int match = 1;
		rec = tmp->data;

		if (nickmask != NULL)
			match = ignore_match_server(rec, server) &&
				ignore_match_channel(rec, channel) &&
				ignore_match_nickmask(rec, nick, nickmask);
		if (match &&
		    ignore_match_level(rec, level) &&
		    ignore_match_pattern(rec, text)) {
			len = rec->mask == NULL ? 0 : strlen(rec->mask);
			if (len > best_mask) {
				best_mask = len;
				best_match = !rec->exception;
			} else if (len == best_mask) {
				len = rec->pattern == NULL ? 0 : strlen(rec->pattern);
				if (len > best_patt) {
					best_patt = len;
					best_match = !rec->exception;
				} else if (len == best_patt && rec->exception)
					best_match = 0;
			}
		}
	}
        g_free(nickmask);

	if (best_match || (level & MSGLEVEL_PUBLIC) == 0)
		return best_match;

        return ignore_check_replies(chanrec, text, level);
}
Пример #4
0
static void os_cmd_mode(sourceinfo_t *si, int parc, char *parv[])
{
        char *channel = parv[0];
	char *mode = parv[1];
	channel_t *c;
	int modeparc;
	char *modeparv[256];

        if (!channel || !mode)
        {
                command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE");
                command_fail(si, fault_needmoreparams, _("Syntax: MODE <channel> <parameters>"));
                return;
        }

	c = channel_find(channel);
	if (!c)
	{
                command_fail(si, fault_nosuch_target, _("Channel \2%s\2 does not exist."), channel);
                return;
	}

	wallops("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)",
		get_oper_name(si), channel, mode);
	logcommand(si, CMDLOG_ADMIN, "MODE: \2%s\2 on \2%s\2", mode, channel);

	modeparc = sjtoken(mode, ' ', modeparv);

	channel_mode(si->service->me, c, modeparc, modeparv);
	command_success_nodata(si, _("Set modes \2%s\2 on \2%s\2."), mode, channel);
}
Пример #5
0
/* check if `text' contains ignored nick at the start of the line. */
static int ignore_check_replies(IGNORE_REC *rec, IRC_SERVER_REC *server,
				const char *channel, const char *text)
{
	CHANNEL_REC *chanrec;
	GSList *nicks, *tmp;

	g_return_val_if_fail(rec != NULL, FALSE);
	g_return_val_if_fail(server != NULL, FALSE);
	g_return_val_if_fail(channel != NULL, FALSE);
	g_return_val_if_fail(text != NULL, FALSE);

	chanrec = channel_find(server, channel);
	if (chanrec == NULL) return FALSE;

	nicks = nicklist_find_multiple(chanrec, rec->mask);
	if (nicks == NULL) return FALSE;

	for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
		NICK_REC *nick = tmp->data;

		if (irc_nick_match(nick->nick, text))
			return TRUE;
	}
	g_slist_free(nicks);

	return FALSE;
}
Пример #6
0
/* SYNTAX: CYCLE [<channel>] [<message>] */
static void cmd_cycle(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
	CHANNEL_REC *chanrec;
	char *channame, *msg, *joindata;
	void *free_arg;

	g_return_if_fail(data != NULL);
	if (!IS_SERVER(server) || !server->connected)
		cmd_return_error(CMDERR_NOT_CONNECTED);

	if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN,
			    item, &channame, &msg))
		return;
	if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);

	chanrec = channel_find(server, channame);
	if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);

	joindata = chanrec->get_join_data(chanrec);
	window_bind_add(window_item_window(chanrec),
			chanrec->server->tag, chanrec->name);

	/* FIXME: kludgy kludgy... */
	signal_emit("command part", 3, data, server, item);

	if (g_slist_find(channels, chanrec) != NULL) {
		chanrec->left = TRUE;
		channel_destroy(chanrec);
	}

	server->channels_join(server, joindata, FALSE);
	g_free(joindata);

	cmd_params_free(free_arg);
}
Пример #7
0
static void event_no_such_channel(IRC_SERVER_REC *server, const char *data)
{
    CHANNEL_REC *chanrec;
    CHANNEL_SETUP_REC *setup;
    char *params, *channel;

    params = event_get_params(data, 2, NULL, &channel);
    chanrec = *channel == '!' && channel[1] != '\0' ?
              channel_find(SERVER(server), channel) : NULL;

    if (chanrec != NULL) {
        /* !channel didn't exist, so join failed */
        setup = channel_setup_find(chanrec->name,
                                   chanrec->server->connrec->chatnet);
        if (setup != NULL && setup->autojoin) {
            /* it's autojoin channel though, so create it */
            irc_send_cmdv(server, "JOIN !%s", chanrec->name);
            g_free(params);
            return;
        }
    }

    check_join_failure(server, channel);
    g_free(params);
}
Пример #8
0
/* received msg to all ops in channel */
static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
				      const char *nick, const char *address,
				      const char *target)
{
	char *nickmode, *optarget, *prefix;
	const char *cleantarget;

	/* only skip here so the difference can be stored in prefix */
	cleantarget = fe_channel_skip_prefix(IRC_SERVER(server), target);
	prefix = g_strndup(target, cleantarget - target);

	/* and clean the rest here */
	cleantarget = get_visible_target(IRC_SERVER(server), cleantarget);

	nickmode = channel_get_nickmode(channel_find(server, cleantarget),
					nick);

	optarget = g_strconcat(prefix, cleantarget, NULL);

	printformat_module("fe-common/core", server, cleantarget,
			   MSGLEVEL_PUBLIC,
			   TXT_PUBMSG_CHANNEL,
			   nick, optarget, msg, nickmode);
	g_free(nickmode);
	g_free(optarget);
	g_free(prefix);
}
Пример #9
0
static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
                                 const char *topic, const char *setby,
                                 time_t settime)
{
    CHANNEL_REC *chanrec;
    char *recoded = NULL;

    chanrec = channel_find(SERVER(server), channel);
    if (chanrec == NULL) return;
    /* the topic may be send out encoded, so we need to
       recode it back or /topic <tab> will not work properly */
    recoded = recode_in(SERVER(server), topic, channel);
    if (topic != NULL) {
        g_free_not_null(chanrec->topic);
        chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
    }
    g_free(recoded);

    g_free_not_null(chanrec->topic_by);
    chanrec->topic_by = g_strdup(setby);

    chanrec->topic_time = settime;

    signal_emit("channel topic changed", 1, chanrec);
}
Пример #10
0
static void cmd_topic(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
	CHANNEL_REC *channel;
	char *timestr, *bynick, *byhost;

	g_return_if_fail(data != NULL);

	channel = *data != '\0' ? channel_find(server, data) : CHANNEL(item);
	if (channel == NULL) return;

	printformat(server, channel->visible_name, MSGLEVEL_CRAP,
		    channel->topic == NULL ? IRCTXT_NO_TOPIC : IRCTXT_TOPIC,
		    channel->visible_name, channel->topic);

	if (channel->topic_time > 0) {
		byhost = strchr(channel->topic_by, '!');
		if (byhost == NULL) {
			bynick = g_strdup(channel->topic_by);
			byhost = "";
		} else {
			bynick = g_strndup(channel->topic_by,
					   (int) (byhost-channel->topic_by));
			byhost++;
		}

		timestr = my_asctime(channel->topic_time);
		printformat(server, channel->visible_name, MSGLEVEL_CRAP,
			    IRCTXT_TOPIC_INFO, bynick, timestr, byhost);
		g_free(timestr);
		g_free(bynick);
	}
	signal_stop();
}
Пример #11
0
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick)
{
	char *params, *target, *msg;
	GSList **list;

	g_return_if_fail(server != NULL);
	if (nick == NULL) return; /* from server */

	params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);

	if (ischannel(*target)) {
		/* channel message */
		CHANNEL_REC *channel;

		channel = channel_find(server, target);
		if (channel == NULL) {
			g_free(params);
			return;
		}

		list = irc_nick_match(server->nick, msg) ?
			&channel->lastownmsgs :
			&channel->lastmsgs;
		nick_completion_create(list, time(NULL), nick);
	} else {
		/* private message */
		add_private_msg(server, nick);
	}

	g_free(params);
}
Пример #12
0
static void send_message(SERVER_REC *server, const char *target,
			 const char *msg, int target_type)
{
	IRC_SERVER_REC *ircserver;
	CHANNEL_REC *channel;
	char *str;
	char *recoded;

        ircserver = IRC_SERVER(server);
	g_return_if_fail(ircserver != NULL);
	g_return_if_fail(target != NULL);
	g_return_if_fail(msg != NULL);

	if (*target == '!') {
		/* !chan -> !12345chan */
		channel = channel_find(server, target);
		if (channel != NULL &&
		    g_ascii_strcasecmp(channel->name, target) != 0)
			target = channel->name;
	}

	recoded = recode_out(SERVER(server), msg, target);
	str = g_strdup_printf("PRIVMSG %s :%s", target, recoded);
	irc_send_cmd_split(ircserver, str, 2, ircserver->max_msgs_in_cmd);
	g_free(str);
	g_free(recoded);
}
Пример #13
0
/* ircd allows forwards to existing channels; the target channel must be
 * +F or the setter must have ops in it */
static bool check_forward(const char *value, channel_t *c, mychan_t *mc, user_t *u, myuser_t *mu)
{
	channel_t *target_c;
	mychan_t *target_mc;
	chanuser_t *target_cu;

	if (!VALID_GLOBAL_CHANNEL_PFX(value) || strlen(value) > 50)
		return false;
	if (u == NULL && mu == NULL)
		return true;
	target_c = channel_find(value);
	target_mc = mychan_from(target_c);
	if (target_c == NULL && target_mc == NULL)
		return false;
	if (target_c != NULL && target_c->modes & CMODE_FTARGET)
		return true;
	if (target_mc != NULL && target_mc->mlock_on & CMODE_FTARGET)
		return true;
	if (u != NULL)
	{
		target_cu = chanuser_find(target_c, u);
		if (target_cu != NULL && target_cu->modes & CSTATUS_OP)
			return true;
		if (chanacs_user_flags(target_mc, u) & CA_SET)
			return true;
	}
	else if (mu != NULL)
		if (chanacs_entity_has_flag(target_mc, entity(mu), CA_SET))
			return true;
	return false;
}
Пример #14
0
static void event_who(const char *data, SERVER_REC *server)
{
	char *params, *nick, *channel, *user, *host, *stat, *realname, *hops;
	CHANNEL_REC *chanrec;
	NICK_REC *nickrec;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 8, NULL, &channel, &user, &host,
				  NULL, &nick, &stat, &realname);

	/* get hop count */
	hops = realname;
	while (*realname != '\0' && *realname != ' ') realname++;
	*realname++ = '\0';
	while (*realname == ' ') realname++;

	/* update host, realname, hopcount */
	chanrec = channel_find(server, channel);
	nickrec = chanrec == NULL ? NULL :
		nicklist_find(chanrec, nick);
	if (nickrec != NULL) {
		if (nickrec->host == NULL)
			nickrec->host = g_strdup_printf("%s@%s", user, host);
		if (nickrec->realname == NULL)
			nickrec->realname = g_strdup(realname);
		sscanf(hops, "%d", &nickrec->hops);
	}

	nicklist_update_flags(server, nick,
			      strchr(stat, 'G') != NULL, /* gone */
			      strchr(stat, '*') != NULL); /* ircop */

	g_free(params);
}
Пример #15
0
static void cmd_join(const char *data, SERVER_REC *server)
{
	WINDOW_REC *window;
        CHANNEL_REC *channel;
	GHashTable *optlist;
	char *channelname;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
			    PARAM_FLAG_UNKNOWN_OPTIONS,
			    "join", &optlist, &channelname))
		return;

	/* -<server tag> */
	server = cmd_options_get_server("join", optlist, server);
	
	channel = channel_find(server, channelname);
	if (channel != NULL) {
		/* already joined to channel, set it active */
		window = window_item_window(channel);
		if (window != active_win)
			window_set_active(window);

		window_item_set_active(active_win, (WI_ITEM_REC *) channel);
	}
	cmd_params_free(free_arg);
}
Пример #16
0
static void sig_message_own_public(SERVER_REC *server, const char *msg,
				   const char *target, const char *origtarget)
{
	const char *oldtarget;
	char *nickmode;

	if (!IS_IRC_SERVER(server))
		return;
	oldtarget = target;
	target = fe_channel_skip_prefix(IRC_SERVER(server), target);
	if (target != oldtarget) {
		/* Hybrid 6 / Bahamut feature, send msg to all
		   ops / ops+voices in channel */
		nickmode = channel_get_nickmode(channel_find(server, target),
						server->nick);

		printformat_module("fe-common/core", server, target,
				   MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
				   MSGLEVEL_NO_ACT,
				   TXT_OWN_MSG_CHANNEL,
				   server->nick, oldtarget, msg, nickmode);
		g_free(nickmode);
                signal_stop();
	}

}
Пример #17
0
static void sig_message_own_public(SERVER_REC *server, const char *msg,
				   const char *target, const char *origtarget)
{
	CHANNEL_REC *channel;
	NICK_REC *nick;
	char *p, *msgnick;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
        if (target == NULL) return;

        channel = channel_find(server, target);
	if (channel == NULL)
		return;

	/* channel msg - if first word in line is nick,
	   add it to lastmsgs */
	p = strchr(msg, ' ');
	if (p != NULL && p != msg) {
		msgnick = g_strndup(msg, (int) (p-msg));
		nick = nicklist_find(channel, msgnick);
		if (nick == NULL && msgnick[1] != '\0') {
			/* probably ':' or ',' or some other
			   char after nick, try without it */
			msgnick[strlen(msgnick)-1] = '\0';
			nick = nicklist_find(channel, msgnick);
		}
                g_free(msgnick);
		if (nick != NULL && nick != channel->ownnick)
			CHANNEL_LAST_MSG_ADD(channel, nick->nick, TRUE);
	}
}
Пример #18
0
static void sig_message_join(SERVER_REC *server, const char *channel,
			     const char *nick, const char *address)
{
	CHANNEL_REC *chanrec;

	chanrec = channel_find(server, channel);
	if (chanrec != NULL)
		CHANNEL_LAST_MSG_ADD(chanrec, nick, FALSE);
}
Пример #19
0
static void cs_fcmd_topicappend(char *origin, char *chan)
{
        char *topic = strtok(NULL, "");
        mychan_t *mc;
        user_t *u = user_find_named(origin);
        char topicbuf[BUFSIZE];
        channel_t *c;

        if (!topic)
        {
                notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "!TOPICAPPEND");
                notice(chansvs.nick, origin, "Syntax: !TOPICAPPEND <topic>");
                return;
        }

        c = channel_find(chan);
        if (!c)
        {
                notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan);
                return;
        }

        mc = mychan_find(chan);
        if (!mc)
        {
                notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan);
                return;
        }

        if (!chanacs_user_has_flag(mc, u, CA_TOPIC))
        {
                notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
                return;
        }
        
        if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer"))
	{
		notice(chansvs.nick, origin, "\2%s\2 is closed.", chan);
		return;
	}

        topicbuf[0] = '\0';

        if (c->topic)
        {
                strlcpy(topicbuf, c->topic, BUFSIZE);
                strlcat(topicbuf, " | ", BUFSIZE);
                strlcat(topicbuf, topic, BUFSIZE);
        }
        else
                strlcpy(topicbuf, topic, BUFSIZE);

	handle_topic(c, origin, CURRTIME, topicbuf);
        topic_sts(chan, origin, CURRTIME, topicbuf);

	logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPICAPPEND", mc->name);
}
Пример #20
0
/* SYNTAX: JOIN [-window] [-invite] [-<server tag>] <channels> [<keys>] */
static void cmd_join(const char *data, SERVER_REC *server)
{
	WINDOW_REC *window;
        CHANNEL_REC *channel;
	GHashTable *optlist;
	char *pdata;
	int invite;
	int samewindow;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
			    PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST |
			    PARAM_FLAG_STRIP_TRAILING_WS,
			    "join", &optlist, &pdata))
		return;

	invite = g_hash_table_lookup(optlist, "invite") != NULL;
	samewindow = g_hash_table_lookup(optlist, "window") != NULL;
	if (!invite && *pdata == '\0')
		cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);

	/* -<server tag> */
	server = cmd_options_get_server("join", optlist, server);

	channel = channel_find(server, pdata);
	if (channel != NULL) {
		/* already joined to channel, set it active */
		window = window_item_window(channel);
		if (window != active_win)
			window_set_active(window);

		window_item_set_active(active_win, (WI_ITEM_REC *) channel);
	}
	else {
		if (server == NULL || !server->connected)
			cmd_param_error(CMDERR_NOT_CONNECTED);
		if (invite) {
			if (server->last_invite == NULL) {
				printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_NOT_INVITED);
				signal_stop();
				cmd_params_free(free_arg);
				return;
			}
			pdata = server->last_invite;
		}
		if (samewindow)
			signal_add("channel created",
				   (SIGNAL_FUNC) signal_channel_created_curwin);
		server->channels_join(server, pdata, FALSE);
		if (samewindow)
			signal_remove("channel created",
				      (SIGNAL_FUNC) signal_channel_created_curwin);
	}
	cmd_params_free(free_arg);
}
Пример #21
0
static void cmd_join(const char *data, SERVER_REC *server)
{
        CHANNEL_REC *channel;

        if (strchr(data, ' ') != NULL || strchr(data, ',') != NULL)
                return;

        channel = channel_find(server, data);
        if (channel != NULL)
                window_item_set_active(active_win, (WI_ITEM_REC *) channel);
}
Пример #22
0
static void sig_message_own_public(SERVER_REC *server, const char *msg,
				   const char *target)
{
	CHANNEL_REC *channel;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);

	channel = channel_find(server, target);
	print_own_channel_message(server, channel, target, msg);
}
Пример #23
0
static void channel_rejoin(IRC_SERVER_REC *server, const char *channel)
{
	CHANNEL_REC *chanrec;
	char *str;

	chanrec = channel_find(server, channel);
	str = chanrec == NULL || chanrec->key == NULL || *chanrec->key == '\0' ?
		g_strdup(channel) : g_strdup_printf("%s %s", channel, chanrec->key);

	server->rejoin_channels = g_slist_append(server->rejoin_channels, str);
}
Пример #24
0
static Quassel_CHANNEL_REC* window2chanrec(WINDOW_REC *window) {
	if(!window)
		return NULL;
	WI_ITEM_REC *wi = window->active;
	if(!wi)
		return NULL;
	Quassel_SERVER_REC *server = (Quassel_SERVER_REC*)wi->server;
	if(!PROTO_CHECK_CAST(SERVER(server), Quassel_SERVER_REC, chat_type, "Quassel"))
		return NULL;
	Quassel_CHANNEL_REC *chanrec = (Quassel_CHANNEL_REC*) channel_find(SERVER(server), wi->visible_name);
	return chanrec;
}
Пример #25
0
static void m_mode(sourceinfo_t *si, int parc, char *parv[])
{
	user_t *u;
	char *p;

	if (*parv[0] == '#')
		channel_mode(NULL, channel_find(parv[0]), parc - 1, &parv[1]);
	else
	{
		/* Yes this is a nick and not a UID -- jilles */
		u = user_find_named(parv[0]);
		if (u == NULL)
		{
			slog(LG_DEBUG, "m_mode(): user mode for unknown user %s", parv[0]);
			return;
		}
		user_mode(u, parv[1]);
		if (strchr(parv[1], 'x'))
		{
			u->flags |= UF_HIDEHOSTREQ;
			check_hidehost(u);
		}
		if (strchr(parv[1], 'h'))
		{
			if (parc > 2)
			{
				/* assume +h */
				p = strchr(parv[2], '@');
				if (p == NULL)
					strlcpy(u->vhost, parv[2], sizeof u->vhost);
				else
				{
					strlcpy(u->vhost, p + 1, sizeof u->vhost);
					strlcpy(u->user, parv[2], sizeof u->user);
					p = strchr(u->user, '@');
					if (p != NULL)
						*p = '\0';
				}
				slog(LG_DEBUG, "m_mode(): user %s setting vhost %s@%s", u->nick, u->user, u->vhost);
			}
			else
			{
				/* must be -h */
				/* XXX we don't know the original ident */
				slog(LG_DEBUG, "m_mode(): user %s turning off vhost", u->nick);
				strlcpy(u->vhost, u->host, sizeof u->vhost);
				/* revert to +x vhost if applicable */
				check_hidehost(u);
			}
		}
	}
}
Пример #26
0
static void sig_message_public(SERVER_REC *server, const char *msg,
			       const char *nick, const char *address,
			       const char *target)
{
	CHANNEL_REC *channel;
        int own;

	channel = channel_find(server, target);
	if (channel != NULL) {
                own = nick_match_msg(channel, msg, server->nick);
		CHANNEL_LAST_MSG_ADD(channel, nick, own);
	}
}
Пример #27
0
static void check_join_failure(IRC_SERVER_REC *server, const char *channel)
{
    CHANNEL_REC *chanrec;
    char *chan2;

    if (channel[0] == '!' && channel[1] == '!')
        channel++; /* server didn't understand !channels */

    chanrec = channel_find(SERVER(server), channel);
    if (chanrec == NULL && channel[0] == '!') {
        /* it probably replied with the full !channel name,
           find the channel with the short name.. */
        chan2 = g_strdup_printf("!%s", channel+6);
        chanrec = channel_find(SERVER(server), chan2);
        g_free(chan2);
    }

    if (chanrec != NULL && !chanrec->joined) {
        chanrec->left = TRUE;
        channel_destroy(chanrec);
    }
}
Пример #28
0
static PyObject *PyServer_channel_find(PyServer *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"name", NULL};
    char *name = "";

    RET_NULL_IF_INVALID(self->data);

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, 
           &name))
        return NULL;

    return py_irssi_chat_new(channel_find(self->data, name), 1);
}
Пример #29
0
static void
sig_history(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, const char *stamp, gpointer gpointer_type)
{
	void *item;
	char *text, *freemsg = NULL;
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);
	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT
	    | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target) : query_find(server, nick);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		CHANNEL_REC *chanrec = item;
		int print_channel;
		char *nickmode;

		print_channel = chanrec == NULL ||
		    !window_item_is_active((WI_ITEM_REC *)chanrec);
		if (!print_channel
		    && settings_get_bool("print_active_channel")
		    && window_item_window((WI_ITEM_REC *)chanrec)->items->next
		    != NULL)
			print_channel = TRUE;
		nickmode = channel_get_nickmode(chanrec, nick);
		text = !print_channel ?
		    format_get_text(CORE_MODULE_NAME, NULL, server,
			target, TXT_PUBMSG, nick, msg, nickmode) :
		    format_get_text(CORE_MODULE_NAME, NULL, server,
			target, TXT_PUBMSG_CHANNEL, nick, target, msg,
			nickmode);
		g_free(nickmode);
	/* General */
	} else
		text = format_get_text(CORE_MODULE_NAME, NULL, server,
		    target, item == NULL ? TXT_MSG_PRIVATE :
		    TXT_MSG_PRIVATE_QUERY, nick, nick, msg);
	printformat_module(MODULE_NAME, server, target,
	    level, XMPPTXT_MESSAGE_TIMESTAMP,
	    stamp, text);
	g_free_not_null(freemsg);
	g_free(text);
}
Пример #30
0
static void cs_cmd_topic(char *origin)
{
	char *chan = strtok(NULL, " ");
	char *topic = strtok(NULL, "");
	mychan_t *mc;
	channel_t *c;
	user_t *u;

	if (!chan || !topic)
	{
		notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "TOPIC");
		notice(chansvs.nick, origin, "Syntax: TOPIC <#channel> <topic>");
		return;
	}

	c = channel_find(chan);
	if (!c)
	{
                notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan);
                return;
        }

	mc = mychan_find(chan);
	if (!mc)
	{
		notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan);
		return;
	}
	
	if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer"))
	{
		notice(chansvs.nick, origin, "\2%s\2 is closed.", chan);
		return;
	}

	u = user_find_named(origin);

	if (!chanacs_user_has_flag(mc, u, CA_TOPIC))
	{
		notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
		return;
	}

	handle_topic(c, origin, CURRTIME, topic);
	topic_sts(chan, origin, CURRTIME, topic);

	logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPIC", mc->name);
	if (!chanuser_find(c, u))
		notice(chansvs.nick, origin, "Topic set to \2%s\2 on \2%s\2.", topic, chan);
}